-
check variable through loop
I have a loop that is check to see if three variables are true if so then play animation.
The problem with my code is it triggers the animation if one out of the three is =true; when it should check if all three are true then and only then should it play the animation
Code:
function loopShowsAnim() {
for (var i = 0; i < plantArr.length; i++) {
if (plantArr[i].deleted) {
trace("DELETED = "+plantArr[i].deleted);
animation.gotoAndPlay(1);
} else {
trace("ELse")
ranShowsAnim();
// ranShowsAnim calls the function again to see if all three variables called "deleted" are == true;
}
}
}
What happens is if one is ==true it plays the animation and also goes to the else statement which calls the function again.
I need to only play the animation if all three are true;
-
Flashkit Veteran
You won't be able for it to stop doing that unless you redo part of the function, i am still thinking about that i don't have time to rewrite it right now i am at work, sorry.
-
Ok great but if anyone else that has the time can let me know how I can fix this that would be great.
Thanks,
-
Flashkit Veteran
code:
this.onLoad = function() {
checkdelete = 0;
};
function loopShowsAnim() {
for (var i = 0; i < plantArr.length; i++) {
if (plantArr[i].deleted) {
trace("DELETED = "+plantArr[i].deleted);
checkdelete++;
}
if(checkdelete == plantArr.length) {
animation.gotoAndPlay(1);
}
if((i == plantArr.length) && (checkdelete !== plantArr.length)) {
trace("ELse");
ranShowsAnim();
}
}
}
sorry it might not work it is worth a try i haven't scripted since Halo 2 came out
Last edited by joejoe2288; 01-12-2005 at 09:05 PM.
-
Thanks for the code but I tried it and it didn't work?????????
-
Flashkit Veteran
-
Flashkit Veteran
add some traces to check what part ain't workin
-
Here is the file.
I have changed a few things and it gets to the animation if statement but it won't clear the interval to shut off the loop.
Here is the file
FLA FILE
-
Unexpected file format! Can't open your .fla.
You'd have a better chance of getting an answer if your .fla was in a MX only format.
You would have to save a copy of your MX2004 .fla, (using Save as...) and changing the Document type to MX only in the Save as... window.
Joe is on MX2004, but probably playing Halo!
-
Here you go let me know if this works for you. Thanks for taking the time to look at this file.
FLASH 5 file
-
Flashkit Veteran
LOL you are psycic you newb i was playing Halo, i will check it out when i get home.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|