Join Login


Video Tutorials
Blog



Adobe CS5.5 Design Premium

Generate a Random Frame with AS3


By: RiverCityGraphix      Views: 6557      Share: Bookmark and Share

In this tutorial, you will learn how to create a random frame generator using AS3 in Flash CS4.

This random frame generator can be very helpful when trying to keep your site looking fresh. If you have an image gallery start on a different image each time, it looks like your site is being updated even when it is not. This can also be a helpful tool in delivering a unique user experience on your site or in games. There are many applications for this method, you just need to find them.

Actionscript 3 (AS3)
stop();

random_btn.addEventListener(MouseEvent.CLICK, choose);

function choose(event:MouseEvent):void{
var pic_number : Number = 6;
var randomFrame:Number = Math.ceil(Math.random() * pic_number);
trace(randomFrame);
gotoAndStop(randomFrame);

}





Free Source Files Zip

99Designs.com