Welcome to WebmasterWorld Guest from 54.197.94.141

Forum Moderators: open

Message Too Old, No Replies

attachMovie() deletes the old

   
1:58 am on Feb 1, 2010 (gmt 0)

5+ Year Member



When I attempt to use attachMovie(), the last thing that I attached disappears. Here is my code.


on(press){
_root.bananas++;
now=_root.bananas;
_root.platform.attachMovie("banana","banana"+now,0);
setProperty ("_root.platform.banana"+now, _x, _root.platform.character._x);
setProperty ("_root.platform.banana"+now, _y, _root.platform.character._y);
}

Any help would be greatly appreciated. Thanks!

5:37 pm on Feb 1, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I think it might be your depth assignment parameter. From the help files:

This example creates a new movie clip with a depth of 10 within the z-order space of container_mc.

The following code attaches two new movie clips to container_mc. The first clip, named clip1_mc, is rendered behind clip2_mc because it was assigned a lower depth value.

container_mc.attachMovie("symbolID", "clip1_mc", 10);
container_mc.attachMovie("symbolID", "clip2_mc", 15);

Depth values for movie clips can range from -16384 to 1048575. If you create or attach a new movie clip on a depth that already has a movie clip, the new or attached clip overwrites the existing content. To avoid this problem, use the MovieClip.getNextHighestDepth() method; however, do not use this method with components that use a different depth-management system. Instead, use DepthManager class with component instances. For more information, see ActionScript 2.0 Components Language Reference.

So, instead, try

_root.platform.attachMovie("banana","banana"+now,_root.platform.getNextHighestDepth());

11:25 pm on Feb 1, 2010 (gmt 0)

5+ Year Member



Great, thank you so much!