all groups > flash actionscript > october 2005 >
You're in the

flash actionscript

group:

Attaching a movie to a duplicated movie


Attaching a movie to a duplicated movie flashStuck
10/16/2005 11:09:03 PM
flash actionscript:
Hi there, I'm trying to load an image (as a movie clip) into a duplicate of
another movie clip. I have one movie clip on my stage which is a template
movie clip. I want to duplicate this movie clip, and load my image into it.
The problem I'm running into is that I don't seem to be able to attach or load
my image into the duplicated movie. Here's what I'm trying:

duplicateMovieClip("rightTemplate", "newPage1_mc",
this.getNextHighestDepth());
newPage1_mc.attachMovie("mc_1", "np1", this.getNextLowestDepth());

I have previously loaded my image into mc_1 using an empty movie clip via:

createEmptyMovieClip("mc_1", 1);
mc1.loadMovie(urlToMyImage);

Any suggestions on how I could get this to work?!...
Re: Attaching a movie to a duplicated movie NSurveyor
10/16/2005 11:13:48 PM
Look up attachMovie in the AS Dictionary... it only attaches clips from the
LIBRARY. You CAN'T attach a clip that is on the stage, to another clip. So,
you'll have to use createEmptyMovieClip to create an empty clip in the the
duplicate clip, and then use loadMovie again to attach the image.
Re: Attaching a movie to a duplicated movie flashStuck
10/17/2005 12:00:00 AM
OK, so now my code looks like this:

duplicateMovieClip("rightTemplate", "newPage1_mc", this.getNextHighestDepth());
newPage1_mc.createEmptyMovieClip("np1_mc", this.getNextHighestDepth());
np1_mc.loadMovie(urlToMyImage);
newPage1_mc._x = 0;
newPage1_mc._y = 0;

And my "rightTemplate" is duplicated and placed in the correct location, but
my image is still not showing up (I checked to make sure the url is correct).

Any further tips?...
Re: Attaching a movie to a duplicated movie flashStuck
10/24/2005 5:12:11 PM
There was just one mistake with the code above, and someone from the LA Flash
Users Group helped me find it. The problem was that the "np1_mc" is now a
child of "newPage1_mc", so the simple fix is:

duplicateMovieClip("rightTemplate", "newPage1_mc", this.getNextHighestDepth());
newPage1_mc.createEmptyMovieClip("np1_mc", this.getNextHighestDepth());
newPage1_mc.np1_mc.loadMovie(urlToMyImage);
newPage1_mc._x = 0;
newPage1_mc._y = 0;


AddThis Social Bookmark Button