1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

swishmax question....

Discussion in 'Programming' started by SedNaX, Jun 21, 2007.

  1. #1
    I am creating a registration page in a flash movie, but i´m encountering a really weird error...

    I have defined regusername as target, and as input text, and when you press the registration button, i have the following code:

    name = regusername.text;

    what is wrong with that? It says that regusername is undefined...

    Thanks :)
     
    SedNaX, Jun 21, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    would you mind posting your flash code? it's to hard to tell when you only post 1 line of code ;)
     
    UnrealEd, Jun 21, 2007 IP
  3. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #3
    here it is :)

    on (rollOver) {
    register._alpha = 50;
    }
    on (rollOut) {
    register._alpha = 100;
    }
    on (release) {

    Name = regusername.text;
    Password = regpassword.text;
    Password2 = regpassword2.text;
    Email = regemail.text;
    Bonus = regbonus.text;
    Race = regrace.text;
    if (!Name) {
    Errorstring=1;
    Errortext='Please insert a username';
    }
    if (!Password) {
    Errorstring=1;
    Errortext='Please enter a password';
    }
    if (Password!=Password2) {
    Errorstring=1;
    Errortext='Passwords do not match';
    }
    if (!Email) {
    Errorstring=1;
    Errortext='Please insert your email address';
    }
    if (!Race) {
    Errorstring=1;
    Errortext='You must select a race!';
    }
    if (!Errorstring) {
    loadVariables("index_register.php",'POST');
    } else {
    errorcapt.text=Errortext;
    }
    }
     
    SedNaX, Jun 21, 2007 IP
  4. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Where did you place this code. The on(...) events tell me that this is written in the actionframe of a button?

    If so, you will have to access the textfields on the root frame, using the _root prefix (it might also be _level0, not sure 100%):
    Name = _root.regusername.text;
    Code (markup):
    Also: it's best to define the type of each variable when you declare it:
    var Name:String = _root.regusername.text;
    Code (markup):
    This keeps your code nice and clean, and helps you to debug the code (Flash will throw an error if an invalid datatype is assigned to that variable, or when a invalid datatype is passed on to a function)

    Just to let you know: when everything is left empty, it will only say "You must select a race!", and not all the other errors.
     
    UnrealEd, Jun 21, 2007 IP
    SedNaX likes this.
  5. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #5
    actually it's when you click on a text (that says register), not a button element. It is on a on(release) event.

    but it works now :) thanks a lot!
     
    SedNaX, Jun 21, 2007 IP
  6. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, it's probably easier if you just code all this in the root frame. The only changes you need to make is give the "text" a name and change the on(release) event to onRelease:
    my_text.onRelease = function () {
      // all the code goes here
    };
    Code (markup):
    the same goes for on(rollOver) (=> onRollOver) and on(rollOut) (=> onRollOut)

    This is of course just a matter of personal choice, but it's nicer if you have loads of code, that way all code can be found in the same frame, you don't have to check each component on your frame
     
    UnrealEd, Jun 21, 2007 IP
  7. tecmaster

    tecmaster Peon

    Messages:
    96
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks everyone it also helped me.
     
    tecmaster, Jun 21, 2007 IP