Help with flash actionscript
- Started
- Last post
- 7 Responses
- koko
I have a movie with 18 frames, and I want to go to a random frame every 15 sec. (more or less).
Please any help?
Thanks
- koko0
Please anyone?
- blaw0
look into setInterval for your timer, then set it to run the following function:
function getRandomFrame(){
tempNum=Math.random();
tempNum=Math.floor((tempNum*18...
gotoAndStop(tempNum);
}
- joyride0
stop();
clearInterval(_global.randomNum...
_global.randomNum = setInterval(randomFrame = function () {
var myRandomFrame:Number= Math.round(Math.random()*15);
trace(myRandomFrame)
gotoAndStop(myRandomFrame)
}, 15000);you may need to debug some... but it should work
- blaw0
here's the setInterval code, but you'll want to adjust the '2000' to suit your needs:
function getRandomFrame(){
tempNum=Math.random();
tempNum=Math.floor((tempNum*18...
gotoAndStop(tempNum);
}ID = setInterval(getRandomFrame, 2000);
- koko0
Thank you guys.
I just have a quick question for joyride:I am appplying your example, and I like the time that it takes to go from one random frame to another (15000), but my first frame is empty and of course it is too long for the first one.
Is it a way to set the time for the first frame random to shorter?
- joyride0
can just set the function and call it:
randomFrame = function () {
var myRandomFrame:Number = Math.round(Math.random()*15);
trace(myRandomFrame);
gotoAndStop(myRandomFrame);
};
randomFrame();it will happen instantly then. or you can just have the code on frame 1 with a shorter time. then on frame 2-15 have the 15 second set interval
- koko0
You are awesome dide. Thanks a bunch!!!!