|
-
goto a frame when an array is empty
Im wondering, I have this script courtesy of MD004 (thanks again)
and Im wondering how I can make it goto the frame labeled "congradulations" when the array is empty. this is what I have.
Code:
function arrayRandomizer(a, b) {
var value = (random(2)==0) ? -1 : 1;
return value;
}
frames = [2,3,4,5,6,7,8,9,10,11,12,13]; // this is the array of frames
frames.sort(arrayRandomizer);
currentFrameCount=0;
function nextFrame() {
gotoAndStop( frames[currentFrameCount] );
currentFrameCount++;
}
I tried just putting a
Code:
if( frames == "" ){
_root.gotoAndPlay("congradulations");
}
but it doesn't goto the frame
any suggestions?
thanks in advance
Mark
Last edited by MarkSensei; 06-21-2006 at 09:42 AM.
-
Hype over content...
You're nearly there with it, just remember to use trace() whenever you can, it'll help with debugging so much.
Give this a try mate:
Code:
function nextFrame() {
if(++currentFrameCount<frames.length){
gotoAndStop(frames[currentFrameCount]);
} else {
_root.gotoAndPlay("congradulations");
}
}
Squize.
-
What about a simple
Code:
if (frames.length == 0) {
_root.gotoAndPlay("congradulations");
}
Hope nobody knows I am still on Flash 5 
______________________________________
All artists are prepared to suffer for their work
but why are so few prepared to learn to draw?(Banksy)
-
Hype over content...
Because the frames array isn't being spliced, it's just the contents being randomised, so you have to use the array offset and compare that to the length, rather than the length property itself ( Which will never change ).
Squize.
-
Thanks so much! I will give that a go!
Man I can't wait until I can just look at a piece of code and understand it inside and out like alot of the folk on this forum.
I was under the impression that the piece of code I was working with was splicing the array...
Thanks again!
Mark
-
Senior Member
trace, trace, trace!
And watch your spelling. ;-)
-
I've never really taken to "trace" yet, maybe I should look into it more. Thanks
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
|