PDA

View Full Version : If then


truckeetrash
08-21-2002, 08:05 PM
On my main time line I have three layers each with a graphic or movie in the first and only frame. On layer one I have my navigation or buttons and on layer 2 I have a movie in which a photo fades from 100% to 0% then back up to 100%. My goal is to have the buttons on layer one tell that movie to either fade or not depending on its current position. If it is already faded to 0 then it needs to stay there. here is the script I have come up with.

on (release) {
if (_root.homephoto.frame=1) {
_root.homephoto.gotoAndPlay(2);
} else (_root.homephoto.gotoandstop(10); {
}
}


The problem here is that it always goes to and plays frame 2 regardless of what frame the play head is on within that movie.

Please help...

tg
08-21-2002, 08:12 PM
change:
if (_root.homephoto.frame=1) {
to
if (_root.homephoto.frame== 1) {

truckeetrash
08-21-2002, 08:29 PM
now it simply does what the else comand tells it to. It does not believe the play head is on frame one of the homephoto movie even though the first frame has a stop command on it so it can not move unless told to.

on (release) {
if (_root.homephoto.frame == 1) {
_root.homephoto.gotoAndPlay(2);
} else {
_root.homephoto.gotoAndStop(10);
}
}

so when the button is clicked, even though the frame of the homephoto is on frame one, it jumps to 10.

Thanks for the help.

WM.

tg
08-21-2002, 10:02 PM
try:

on (release) {
trace("'"+_root.homephoto.frame+"'");//insert the quotes, cause it will show whitespace.
if (_root.homephoto.frame == 1) {
_root.homephoto.gotoAndPlay(2);
} else {
_root.homephoto.gotoAndStop(10);
}
}

my guess is that _root.homephoto.frame is not equal to 1.
should it be "1" instead of 1
or are you trying to see if _currentFrame == 1??
lots of possibilites.

truckeetrash
08-21-2002, 10:41 PM
Trace did not work. Simplifying this even more, the script below should work, it should only go to the frame "IF" the play head is on 1. And it does this, however after you click on it and the play head moves, and you then click on it again, with the play head stoped on frame 10, it still plays from frame 1 to 10 and stops. The script below always sends it from 1-10, even when the head is stoped on 10.


on (release) {
if (_root.homephoto_currentFrame="1") {
_root.homephoto.gotoAndPlay(2);
}
}

tg
08-21-2002, 10:48 PM
post your test fla.

truckeetrash
08-21-2002, 11:09 PM
Too large to upload? here is a link to the zip on my server.

www.magnesiumproductions.com/RealEstate.zip

thanks

tg
08-22-2002, 02:00 AM
ok, my fault. its not _currentFrame, its _currentframe (case sensitive).

also in all your if statements change your "=" to "==" heres why:
assignment operator("=") assigns a value to a variable.
comparison operator("==") compairs two values to see if they are equal.

so in an if statement if(a=b) will ALWAYS be true, because you are assigning the value of b to a. whereas in if(a==b) it will check if they have the same value and return true or false.

one last thing in your statement. make sure you dont forget the '.' between photo._currentframe

so your code should look like this (cut and past this into your project)

on (release) {
//trace(_root.homephoto._currentframe);
if (_root.homephoto._currentframe == 1) {
_root.homephoto.gotoAndPlay(2);
}
}


hope its all sorted now.

truckeetrash
08-22-2002, 08:26 PM
Works great now, thanks. I am not familiar with the trace command. Why was this necessary for it to work?

Thanks again.

Billy.

tg
08-22-2002, 09:34 PM
trace doesn't make it work, trace is a debugging tool. the '//' i put infront of the trace command keeps it from running. if you remove those ('//') then when you run the fla in test mode, when flash gets to this command it will open the output window and display the value inside the command. it only works in test mode, so if you forget to comment them out (by putting the // infront of it) the user wont see anything from the web page.

truckeetrash
08-22-2002, 09:38 PM
Very nice, Thanks again for the help. I'm stoked to have this working across different time lines.

Thanks again.

WM.