4/30/2010 12:03:27 AM
Title:
generate random moviclip without repeat
i declare the movieclips in an array then i generate the movieclip randomly without repeat and also position the movieclips with x and y position of random mcs.
4/30/2010 2:21:43 AM
Already replied to very similar question on this thread , check that and see if it helps you
http://askmeflash.com/qdetail/259/movieclips-on-screen
5/1/2010 10:37:43 AM
Hi Sandy,
Here;s the source code which will guide you ..
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initializeApp()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.utils.setTimeout;
private var interval:uint;
private var myMovieClip:MovieClip;
private var movieClipArray:Array = new Array("Cir", "Square", "Rect");
private function initializeApp():void{
var movieClipArrlength:Number = movieClipArray.length;
interval = setInterval(getTime, 1000)
myMovieClip = new MovieClip();
board.rawChildren.addChild(myMovieClip);
}
private var count:int = 0;
private function getTime():void {
if(movieClipArray[count] == "Cir"){
myMovieClip.graphics.clear();
myMovieClip.graphics.beginFill(0x009900);
myMovieClip.graphics.drawCircle(board.x, board.y +20, 100);
myMovieClip.graphics.endFill();
} else if(movieClipArray[count] == "Square"){
myMovieClip.graphics.clear();
myMovieClip.graphics.beginFill(0x990000);
myMovieClip.graphics.drawRect(board.x, board.y, 150, 150);
myMovieClip.graphics.endFill();
} else if(movieClipArray[count] == "Rect"){
myMovieClip.graphics.clear();
myMovieClip.graphics.beginFill(0x990099);
myMovieClip.graphics.drawRect(board.x, board.y, 350, 150);
myMovieClip.graphics.endFill();
}
count++;
if(count > 2){
count = 0;
}
}
]]>
</mx:Script>
<mx:Canvas id="board" width="650" height="300" x="280" y="100" backgroundColor="#FFFFFF" borderStyle="solid" borderColor="#0096FF" borderThickness="4"/>
</mx:Application>
Regards:
ANKUSH