It doesn't; developer paranoia.

addChild puts it on the display list.

Currently, if you create a movieclip, it not only exists in memory as a 
variable, but is also on the displaylist, meaning it's rendered.

With this, you can create a movieclip, but not actually have it rendered to 
the screen.  This includes it and all of it's children.

var gameworld:MovieClip = new MovieClip();
addChild( gameworld );

To hide it, but not destroy the clip itself, do:

removeChild(gameworld);

The cool thing about this is, it retains state.  One of the big challenges 
with keeping movieclips around is that they take up resources, even if you 
turn them invisible, and move them off of the stage.

Additionally, creating & destroying movieclips is an expensive CPU 
opertation.  That's why ViewStacks in Flex are a decent implementation 
because they try to balance both.

NOW, we can remove movieclips from being rendered, but keep their state by 
keeping their variable around, and render them only when needed.

It gets even crazier when you start re-parenting stuff.

Pimp!



----- Original Message ----- 
From: "Jon Bradley" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Friday, October 28, 2005 2:53 PM
Subject: Re: [Flashcoders] Newbie AS3 question


On Oct 28, 2005, at 1:55 PM, Shaw, Matt wrote:

> Assuming the Game class is your root/stage class:
>
> ....
> Public class Game extends MovieClip {
> public function Game(){
> var gameworld:MovieClip = new MovieClip(); //new GameWorld()?
> this.addChild( gameworld );
>
> var game_bg:MovieClip = new MovieClip();
> gameworld.addChild( game_bg );
> }

What I don't get is why it needs "this.addChild" instead of just
addChild.  I've been sick of the keyword "this" for a long time and
have since avoided it in AS2.

Any reason that it needs to be back in for AS3?

- Jon

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to