Susan,

A class is a template - usually written with a capital letter at the start.
A class doesn't exist in the memory of the program.
It's something you use to define the 'type' of objects you want.
Other 'types' might be: int, Number, MyClass, etc.

An instance is an object based on that template - usually starting with a lower case letter (so we can tell the difference).

For example...
var my_obj:MyClass = new MyClass;
is a real object, called my_obj, based on the template for that 'type' of thing.

You can only remove an instance with removeChild if it is a child sitting on another instance (i.e. you used addChild to add it).

MyClass.removeChild(my_obj);
tries to remove an instance from MyClass but MyClass doesn't exist (outside of the template).

If you use
addChild(my_obj);
you add it to the stage (this is the main program's instance).

If you then use
removeChild(my_obj.parent);
then you are trying to remove the stage - i.e. remove the program itself.

Try
var my_obj1:MyClass = new MyClass;
var my_obj2:MyClass = new MyClass;

my_obj1.addChild(my_obj2);

Then you will be okay.
This list of add instances when added to the stage becomes a display list.
Read about the display lists.

I read Mook's comepletely before doing any coding and it really helped.

John

Susan Day wrote:
On Wed, Feb 24, 2010 at 9:44 AM, Geografiek <[email protected]>wrote:

Well,
You could at least give a hint as to what _does_ work:
trace(my_obj.parent);


Thanks. That traced out the name of the class/*.as file, but when I put that
value in, as in:

MyClass.removeChild(my_obj);

it throws an error (1061). What do?

With respect to Moock, yeah, got it, and it's the only reason I still
haven't pulled out all the hair in my head. Maybe get the cookbook too.
TIA,
Susan
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to