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
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; } }
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.
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!
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