FORUMS: list search recent posts

Flash Banner that jumps to specified random frame

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Flash Banner that jumps to specified random frame
on Dec 21, 2007 at 9:24:05 pm

Hello everyone,

I'm looking to make a flash banner that is just 6 different pictures randomly showing every few seconds. I've tried several different ideas but I seem to be running into an issue when it comes to creating a random actionscript.

Any suggestions would be much appreciated.


Return to posts index

Pieter Helsen
Re: Flash Banner that jumps to specified random frame
on Dec 21, 2007 at 11:17:55 pm

Have 6 different MCs in your library. Right-click on all of them and click on Linkage...

In the window that pops up, tick the box that says something like "Export for Actionscript" and give each of them a linkage name.

Then open the actionscript window and select the first frame of the first layer (you'll only need one layer, call it actions or something similar). Put in the following code:

// This is the array filled with the linkage names
var mcArray:Array = new Array("myLinkageName1", "myLinkageName2", ...);
of the MCs
var container_mc:MovieClip = this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());

function randomImg(){
var randNr:Number = Math.floor(Math.random()*_root.mcArray.length);
var randImg = _root.mcArray[randNr];

_root.container_mc.attachMovie(randImg, "myAdvertisement", 1);
// 2000 is the number of milliseconds after which the function is called.
//So right now, the function gets called every 2 seconds.
var myInterval:Number = setInterval(randomImg, 2000)

Kind regards,

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved