homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
attachMovie() deletes the old
MartinWeb




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

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!

 

rocknbil




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

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());

MartinWeb




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

Great, thank you so much!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved