|
|
|
#1 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
If i make a whole bunch of movieclips using a for loop how would i beable to identify them if an event listener was added to them and i wanted each movieclip created to do something different?
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2008
Posts: 168
|
__________________
Check out my blog showing the development of my flash game, the Dregs of War |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
Well, yeah...I figured as much. Imean, ...sigh yeah that will work i gues
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Nov 2008
Posts: 168
|
Sorry, I wasn't very helpful.
PHP Code:
Are you unhappy about using arrays? If you give some more detail maybe we can give you a more satisfactory answer!
__________________
Check out my blog showing the development of my flash game, the Dregs of War |
|
|
|
|
|
#5 |
|
Mod
Join Date: Mar 2002
Location: press the picture...
Posts: 12,127
|
Give each MovieClip a name:
for(var i:int=0; i<numClips;i++) { var myClip:MovieClip = new MovieClip(); myClip.name = "myClip"+i; myClip.addEventListener(MouseEvent.CLICK, cHandler); } function cHandler(event:MouseEvent):void { trace(event.currentTarget.name); }
__________________
![]() - The right of the People to create Flash movies shall not be infringed. - | www.Flashscript.biz | Help a little girl, Ana, who has cancer. | Flashscript Biz Classes/Components | Flash-Model-View-Controller-Modul | |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
Basically im creating many movieclips on stage. All of them will esentially load the same thing (which is load the a bigger movieclip on stage to load a picture). The problem is which picture to load. I was thinking of something like this...
PHP Code:
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
Ok so I have generated this. Now I am stuck. The code is heavily commented. It goes through all the trace statements, but I see nothing on stage, and if I click everywhere on the stage, nothing is traced...
PHP Code:
|
|
|
|
|
|
#8 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
oh and randomF is a function used to generate a random number.
PHP Code:
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
ok...if you alter the for statement like this, you see a movieclip but only one movieclip...
and i click on it...its card60....i guess its somehow looping through it 3 times...and only creating one....help? PHP Code:
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
ok i adjusted the code so that I could identify each movieclips number. Every time the movieclip is added to stage it is triggered by an event listener... how would I call it? using an Event.ADDED_TO_STAGE, how would i call it? i try e.target but it doesnt work. So when I try e.target.x, i cant change it....
private function addedToStageF(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, addedToStageF); trace(e.target.name); e.target.width = 12211; trace(e.target.width);//I get 0.....as for all of them... { |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: May 2009
Posts: 205
|
oh..e.target...ok..resolved...
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|