Actionscript problems

  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Joined: Aug 16, 2003
  • Posts: 2297
  • Loc: UK - England
  • Status: Offline

Post April 19th, 2004, 10:55 am

I am not much of a scripter lol...
and this is relatively new to me..
but i asked a question about something like this a long time a go...
so i am going to ask here again, because now i know a little more about what i am on about :roll:

anyway
I have this code on a button in my movie
Code: [ Select ]
on (release)
{
    errorMsg.text = 'Please insert a username'
    if((Name.length > 0))
    errorMsg.text = 'Please insert a password'
    if((Password.length > 0))
    errorMsg.text = 'Please insert an email address'
    if((Email.length > 0))
    errorMsg.text = 'Please insert a team name'
    if((Team.length > 0))
    if((errorMsg.text == errorMsg.text))
}
  1. on (release)
  2. {
  3.     errorMsg.text = 'Please insert a username'
  4.     if((Name.length > 0))
  5.     errorMsg.text = 'Please insert a password'
  6.     if((Password.length > 0))
  7.     errorMsg.text = 'Please insert an email address'
  8.     if((Email.length > 0))
  9.     errorMsg.text = 'Please insert a team name'
  10.     if((Team.length > 0))
  11.     if((errorMsg.text == errorMsg.text))
  12. }


I wanted this to check some text fields, to make sure the user inputs the all the right data into the input fields
now i want to add this code to the same button
Code: [ Select ]
var regVars = new LoadVars();
            regVars.action = 'Submit';
            regVars.Name = Name.text;
            regVars.Password = Password.text;
            regVars.Email = Email.text;
            regVars.location = location.text;
            regVars.Favourite_Team = Favourite_Team.text;
            regVars.Team = Team.text;
            regVars.sendAndLoad("Registration.php", regVars, "POST");
  1. var regVars = new LoadVars();
  2.             regVars.action = 'Submit';
  3.             regVars.Name = Name.text;
  4.             regVars.Password = Password.text;
  5.             regVars.Email = Email.text;
  6.             regVars.location = location.text;
  7.             regVars.Favourite_Team = Favourite_Team.text;
  8.             regVars.Team = Team.text;
  9.             regVars.sendAndLoad("Registration.php", regVars, "POST");


this should in effect send all the data from the text boxes to a phpscript, which i have set up to send to a Mysql database.

What i want to do is have both scripts on the same button...
whenever i try this i just get loads of errors...
this is what i thought it should look like originally
Code: [ Select ]
on (release)
{
    errorMsg.text = 'Please insert a username'
    if((Name.length > 0))
    errorMsg.text = 'Please insert a password'
    if((Password.length > 0))
    errorMsg.text = 'Please insert an email address'
    if((Email.length > 0))
    errorMsg.text = 'Please insert a team name'
    if((Team.length > 0))

var regVars = new LoadVars();
            regVars.action = 'Submit';
            regVars.Name = Name.text;
            regVars.Password = Password.text;
            regVars.Email = Email.text;
            regVars.location = location.text;
            regVars.Favourite_Team = Favourite_Team.text;
            regVars.Team = Team.text;
            regVars.sendAndLoad("Registration.php", regVars, "POST");
}
  1. on (release)
  2. {
  3.     errorMsg.text = 'Please insert a username'
  4.     if((Name.length > 0))
  5.     errorMsg.text = 'Please insert a password'
  6.     if((Password.length > 0))
  7.     errorMsg.text = 'Please insert an email address'
  8.     if((Email.length > 0))
  9.     errorMsg.text = 'Please insert a team name'
  10.     if((Team.length > 0))
  11. var regVars = new LoadVars();
  12.             regVars.action = 'Submit';
  13.             regVars.Name = Name.text;
  14.             regVars.Password = Password.text;
  15.             regVars.Email = Email.text;
  16.             regVars.location = location.text;
  17.             regVars.Favourite_Team = Favourite_Team.text;
  18.             regVars.Team = Team.text;
  19.             regVars.sendAndLoad("Registration.php", regVars, "POST");
  20. }

but, it seems that the code only gets to the
Code: [ Select ]
errorMsg.text = 'Please insert a team name'
    if((Team.length > 0))
  1. errorMsg.text = 'Please insert a team name'
  2.     if((Team.length > 0))

and stops...
i dont know why

can someone please re-arrange this code for me, so it runs smoothly, and sends the variables properly
Codebuddies - Website Development Resource
|INCLUDE(), INCLUDE_ONCE(), REQUIRE() IN PHP | - / - |MICROSOFT CRM 4.0 ONCLICK EVENT WITHIN FORM |
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 19th, 2004, 10:55 am

  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Joined: Aug 16, 2003
  • Posts: 2297
  • Loc: UK - England
  • Status: Offline

Post April 22nd, 2004, 7:31 am

please lol...
Codebuddies - Website Development Resource
|INCLUDE(), INCLUDE_ONCE(), REQUIRE() IN PHP | - / - |MICROSOFT CRM 4.0 ONCLICK EVENT WITHIN FORM |
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post April 22nd, 2004, 1:06 pm

I could be wrong, but your 'if' statements in the first snippet don't look properly formed. Maybe it's just that I've never done it the way you have. I'm used to:

Code: [ Select ]
on (release)
{
  errorMsg.text = 'Please insert a username'
  if(Name.length > 0) {
   errorMsg.text = 'Please insert a password'
  }
  if(Password.length > 0) {
   errorMsg.text = 'Please insert an email address'
  }
  1. on (release)
  2. {
  3.   errorMsg.text = 'Please insert a username'
  4.   if(Name.length > 0) {
  5.    errorMsg.text = 'Please insert a password'
  6.   }
  7.   if(Password.length > 0) {
  8.    errorMsg.text = 'Please insert an email address'
  9.   }

...with single parenthesis aroung the CONDITION and the curly brackets holding the THEN if the IF returns true.

Like I said, I may just be ignorant, but it doesn't look like ActionScript to me.
- dM
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post April 22nd, 2004, 4:41 pm

Semi-Correct.

Not sure if it is the cause of the problem. But 1 of the if statements is set up correctly.

You can only write an if statement without curly brackets if the code block being executed consists of one line and one line only.


I see your last if statement executes more than 1 line of code, so your code is improperly being triggered.


I can't really see any other direct problems. But server-side flash isn't exactly my forte.


Edit:
Code: [ Select ]
variable = false;
if (variable)
trace("its true, it's really true!")
trace("you are all crazy!")
  1. variable = false;
  2. if (variable)
  3. trace("its true, it's really true!")
  4. trace("you are all crazy!")


In that code, only "you are all crazy!" gets outputted to the output window. Set variable to true and they both get outputted.



Edit2:

Same goes for "for" loops as well.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 49 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.