PDA

View Full Version : Jumping to specific frames within 1 scene and playing (help please)


Tangerine Dream
11-27-2008, 12:52 PM
I have one scene with many frames, and i want to jump to a series of different frames within the time line (in this case, frames: 2,86,171,256,341,426,511)

and then play from there. So at start of movie it will start in a different random position and play through, in order - then looping.

I have this but I know it is totally wrong, it wasn't designed to do what I want:

// define a array with all your previously defined labels
labelarray=[2,86,171,256,341,426,511];

// calculate a random index for this array
randomidx = random(labelarray.length);

// jump to the label at the random index
gotoAndPlay(labelarray[randomidx]);

Any help greatly appreciated :)

I'm sure it can't be that hard... but I've had no luck and been trying for a while now :(


EDIT (this is something else I came with, hat doesnt work either...)


num = Math.floor(Math.random() * (6 - 1)) + 1;


//Depending on which random number
//was chosen, go to a flash scene
if (num = 0)
{
gotoAndPlay(2)
}
if (num = 1)
{
gotoAndPlay(86)
}
if (num = 2)
{
gotoAndPlay(171)
}
if (num = 3)
{
gotoAndPlay(256)
}
if (num = 4)
{
gotoAndPlay(341)
}
if (num = 5)
{
gotoAndPlay(426)
}
if (num = 6)
{
gotoAndPlay(511)
}

rudrapradeepta.k
11-27-2008, 03:42 PM
Hi,

Usage of math has changed in actionscritp3.0.
try this code.

var array:Array=new Array(2,86,171,256,341,426,511);
var dummy:Number;
dummy=Math.floor(Math.random()*array.length)
gotoAndPlay(array[dummy]);

Tangerine Dream
11-27-2008, 04:00 PM
Hi,

Usage of math has changed in actionscritp3.0.
try this code.

var array:Array=new Array(2,86,171,256,341,426,511);
var dummy:Number;
dummy=Math.floor(Math.random()*array.length)
gotoAndPlay(array[dummy]);

Thanks for the help. It appears to randomly start on only a couple of the keyframes listed in the array though? Strange...

rudrapradeepta.k
11-27-2008, 04:10 PM
your code will work but ther u have made a mistake,
if(x=5) must be replaced with if(x==5);

regards,
rudrapradeepta.k@gmail.com

Mazoonist
11-27-2008, 04:11 PM
Usage of math has changed in actionscritp3.0.
What usage of math changed in actionscript 3.0? The code you gave works identically in actionscript 2.0 with no changes.

rudrapradeepta.k
11-27-2008, 04:12 PM
do u want to play randomly at all points???
which are in array????

rudrapradeepta.k
11-27-2008, 04:15 PM
What usage of math changed in actionscript 3.0? The code you gave works identically in actionscript 2.0 with no changes.

my intension was to say him to change the way of using random();
i never tried it in 2.0 if so sorry....

Tangerine Dream
11-27-2008, 04:17 PM
do u want to play randomly at all points???
which are in array????

I want it to start on each of those frame numbers in the array - it will then play through in the correct order and loop. so on each page load - the flash animation starts on a certain (predefined) frame (all those in the array) and plays through in order...

I have this set up by having the code you gave me on frame 1. then at the end of the scene it has a goto and play frame 2 script.

so then it bypasses the randomiser and just plays most of the scene in the correct order. Only on each page load / page refresh should frame 1 of the flash animation load (and the randomiser should point to a random one of the predefined frame numbers)

hope that made sense!

http://www.progressdebtrecovery.co.uk/

See the blue box flash animation half way down the page? Thats where the code I recieved has got me so far. As you reload the page it seems to pick certain keyframes far more often than others?

Mazoonist
11-27-2008, 04:17 PM
Oh, okay, I get it now! Yes, I believe there used to be a top-level random() method that was deprecated, and now you have to use Math.random().

rudrapradeepta.k
11-27-2008, 04:39 PM
I believe there used to be a top-level random() method


what do u mean by top-level random()