troubleshooting Question

how do i create a duplicate movie clip in action script 3

Avatar of spearce101
spearce101 asked on
Adobe Flash
1 Comment1 Solution247 ViewsLast Modified:
Dear Experts!!

I am wondering how to create a new movie clip instance in action script 3, that is a copy of another  already existing instance.

Background:

I am building an interactive map. when a region of the map is clicked on I want to make this region appear larger (which successfully works already). The problem is that there is a space left behind in the original map where the region that was clicked on used to be. (Each region is a separate movie clip.)

I would like to make a temporary copy of the original region, and then only move and enlarge the copy, leaving the original behind so as to avoid a blank spot appearing.

I tried making a variable to hold the temporary copy, and assign the value of the original to it before moving one of them, but unfortunately it appears that the assignment operation results in merely a pointer being placed to the original, and not a real copy of the original movie clip.

I would like to avoid having to make a new class in a separate library to create a new instance of the original. Is there a way to accomplish this simply?

Thank you
function doRegionClick(_mc:MovieClip) {
 
	var temporaryMc:MovieClip = new MovieClip();      //tried var temporaryMc:MovieClip = new _mc(); but not a funct
	
        temporaryMc = _mc;      //this is where the problem occurs: temporaryMc just points where  _mc points to
				
	addChildAt(temporaryMc, numChildren - 1);    //doesn't appear to work because a gap appears in map 
	
   	 //   moves temporaryMc to middle of window             			
        animateObject(temporaryMc, (stage.width / 2) - _mc.width, (stage.height / 2) - _mc.height, 300, 400);
 
				
}
ASKER CERTIFIED SOLUTION
scooby_56

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros