header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
sandy
Points:0
Posts:0

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.



1
Orian
Points: 0
Posts:0
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

2
Ankush
Points: 240
Posts:0
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


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+8 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions