Forum ActionScript 3.0 addChild from library not showing?

Problems and discussions relating to ActionScript 3.0 here.

addChild from library not showing?

Postby twick » November 25th, 2010, 5:36 am

I've just finished planning out a turn-based game and got the basics working through trace. However, I'm having some trouble with showing stuff on stage. I've looked online but all the solutions posted don't work!

My first issue was loading a movieclip from within my library. It's just a circle, converted it to movieclip, checked the export to AS3 button, declared the variable and added it as a child. The problem is that it won't show on stage, but the position is correct (I send the position to the server for validation and the coordinates are sent back fine). If I add a rectangle with fill, it will show, but not my movieclip. I've tried stage.addChild, this.addChild, etc etc with no luck. I can add the movieclip directly on stage manually (and it will show) but not through AS3. I've even tried changing the alpha of the movieclip.

I'm trying to work out how I can add a movieclip on handleJoin() that will show on other player's screens (ie, when logging in, show a circle, and when another player logs in his circle is added onto your screen (and if he moves it, it wont move yours).

I'm also wondering how a second player could add movieclips (from the library) and have them show on all player's stages.

Any help is much appreciated!
twick
 
Posts: 15
Joined: October 13th, 2010, 5:27 pm

Re: addChild from library not showing?

Postby Benjaminsen » November 25th, 2010, 10:12 am

The Multiplayer Tutorial has an example that does almost exactly what you want to do.

The example can be seen here and the source be downloaded here
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: addChild from library not showing?

Postby twick » November 25th, 2010, 4:15 pm

That's exactly what I wanted to try out! Got it working now, I guess I needed addChildAt instead of just addChild.

Thanks for pointing me in the right direction!
twick
 
Posts: 15
Joined: October 13th, 2010, 5:27 pm


Return to ActionScript 3.0