Groups | Blog | Home
all groups > flash actionscript > september 2006 >

flash actionscript : FLash 7 vs 8 , AS 2.0 script


devunit
9/23/2006 4:08:03 PM
Can anyone give me an idea why this script will work in Flash 7 , but gives the
error code in Flash 8?

on (release, keyPress "<Enter>") {
if (user add pass eq "xxxxx" add "xxxxx!") {
gotoAndPlay("Scene 5", 3);
} else if (user add pass ne "xxxxx" add "xxxxx!") {
gotoAndPlay("tryagain", 1);
}
}

Here's the error message

**Error** Scene=animated opening, layer=Layer 3, frame=6:Line 2: ')' expected
if (user add pass eq "xxxxx" add "xxxxx") {

**Error** Scene=animated opening, layer=Layer 3, frame=6:Line 3: Statement
must appear within on handler
gotoAndPlay("Scene 5", 3);

**Error** Scene=animated opening, layer=Layer 3, frame=6:Line 4: Unexpected
'}' encountered
} else if (user add pass ne "xxxxx" add "xxxxx!") {

Thanks!
devunit
9/23/2006 6:10:50 PM
Manno,

Thank you for your help and advice.

Working now.

Manno Bult
9/23/2006 8:04:56 PM
the add, eq and ne keywords don't exist in AS2. They were marked
deprecated in MX 2004, and appearantly gotten rid of in 8.

add is now + or the String .concat() method
eq is now == or ===
ne is now != or !==


What you want is:

on (release, keyPress "<Enter>") {
if (user + pass == "xxxxx" + "xxxxx!") {
gotoAndPlay("Scene 5", 3);
} else if (user + pass != "xxxxx" + "xxxxx!") {
gotoAndPlay("tryagain", 1);
}
}

BTW: The second condition can even be removed entirely. If the first
condition is not true, the second will always be true. So:

on (release, keyPress "<Enter>") {
if (user + pass == "xxxxx" + "xxxxx!") {
gotoAndPlay("Scene 5", 3);
} else {
gotoAndPlay("tryagain", 1);
}
}

Will suffice.

Manno

[quoted text, click to view]

--
----------
Manno Bult
AddThis Social Bookmark Button