[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

AS3 naming dynamic movie clips

Posted on 2009-07-08
4
Medium Priority
?
512 Views
Last Modified: 2013-11-11
Hi,

I have dynamically created two movieclips in an array and  am using the startDrag handler to drag one on top of each other, then using  hittest to check when they intersect.

I can't figure out how to track the dynamic movieclips I've created, and then put the correct names into the hittest??
//SETTING UP THE TWO ARRAYS:
 
for (var n:Number = 0; n < my_total; n++) { //MAIN LOOP
		//IMAGE///////////////////////////////////////
		IMAGE_URL_ARRAY[n] = my_Haiku[n].@IMAGE;
		 var imgLoader:Loader = new Loader();
		 	 imgLoader.load(new URLRequest(IMAGE_URL_ARRAY[n])); 
			 
		//trace(imgLoader.name);
		 	imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
			imgLoader.name = String(n);
			trace('imgLoader: '+imgLoader.name);
			txt_Array_1[n] = my_Haiku[n].@WORD//add to array every loop
				if((my_Haiku[n].@NEWLINE =="YES")&&(CURRENTSENTENCE == 'ONE')){
				FIRSTNUM = n+1;//capture where word is in array
				CURRENTSENTENCE = 'TWO'
				}else if((my_Haiku[n].@NEWLINE =="YES")&&(CURRENTSENTENCE == 'TWO')){
				//CURRENTSENTENCE = 'THREE';
				SECONDNUM = n;
				CURRENTSENTENCE = 'THREE'
				}
				
			//trace(txt_Array_1);
			//trace(img_arr[1]);
		
 
}//end of process XML
writeTxt();
}
function loadComplete(e:Event):void {
							 img_arr.push(e.target.content);
							 //trace(e.target.content.name)
							 //this.buttonMode = true;
								//this.addEventListener(MouseEvent.MOUSE_OVER, pickUp);
								dragger = new MovieClip();
								var thumb:Loader = Loader(e.currentTarget.loader);
								scroller_mc.addChild(dragger);//add to main parent
								dragger.addChild(thumb);
 
									dragger.buttonMode = true;
									
									dragger.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
									dragger.addEventListener(MouseEvent.MOUSE_UP, dropIt);
									
							 	
								y_pos=y_pos+e.target.content.height+10;
								//scroller_mc.addChild(e.target.content);
							
								e.target.content.y=y_pos;
								e.target.content.x=x_pos;
 
								  if(img_arr.length==(my_total)){
									
									trace('might not need to break out??');
 
								 }
				
				}
//when picked up:
function pickUp(event:MouseEvent):void {
	
	trace('@haiku_collision'+haiku_txt.name);
	event.target.parent.alpha = 0.7;
	event.currentTarget.startDrag();
	event.target.parent.x=0;
	event.target.parent.y=0;
//////////SOMETHING IN HERE PLEEASE!////////////////////////////////////////////
	
}

Open in new window

0
Comment
Question by:nimuse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
rascalpants earned 1500 total points
ID: 24808873
I believe this line....

img_arr.push(e.target.content);

should be something more like this...

img_arr.push(e.target);   or   img_arr.push(e.currentTarget);


rp
0
 
LVL 1

Author Closing Comment

by:nimuse
ID: 31601004
Thanks for your reply.

Did that, but am still stumped as how to reference the object in the array using the hittest handler?  May be better to use bounding box??

Nick
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24813851
you should open up a new question so that other experts can help you out a well.

rp
0
 
LVL 1

Author Comment

by:nimuse
ID: 24817033
ah, new at using the system - how do I open it up:

I solved my problem in the end using this:
if(event.currentTarget.dropTarget.text==txt_Array_1[n]){

the requirement was to drop a picture onto a textfield so I used the textfield to test - seems to work!

So I just leave the question OPEN, or do I have to specify??

Thanks again,

Nick
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question