Re: [Flashcoders] removeChild Question

2010-02-25 Thread Susan Day
Thank you everyone for your replies. Turns out the culprit was that I called
a certain function iteratively and I had placed those children in that fn.
Therefore, when I removed the children, I presumably only removed the final
iteration. So, I took the children out of that loop and they were removed
with no problem. My bad.
Susan
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild Question

2010-02-25 Thread John McCormack

Susan, have a look at these examples:

http://www.actionscript.org/resources/categories/Tutorials/
http://www.kirupa.com/developer/flash/index.htm
http://www.flashandmath.com/
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/#contents

John

Susan Day wrote:


There is nothing in your response that indicates what I
should research, other than "property" and "function", which I feel is way
too general.




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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Henrik Andersson

John McCormack wrote:

I was careless.

I am not sure about your objection about the stage. I never mentioned
time lines, I assumed Susan was adding to the stage at the start of her
program.

Can you have a main SWF without a timeline (single frame)?
Can you have a program without a stage?

What is more fundamental to a SWF, a stage or timeline?

Maybe I am missing something.



You forgot a minor detail, don't worry about that. You get corrected and 
move on, it happens to everyone.


The stage is the player. The main timeline is the content that you 
create. You need both. The stage is needed so that something is visible. 
The main timeline is the frames stored in the swf. Even a one frame swf 
has a timeline, that lone frame.

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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread John McCormack

Henrik,

I was careless.

The code and properties of a class, such as Math and Math.PI, are 
accessible and you can pass objects, such as the number 0.1 into the 
class methods, as in Math.sin(0.1), and so there is memory associated 
with them. It's worth noting that a static property for a class belongs 
to all instances whereas other properties exist - one copy for each 
object. I should have said that there was no separate memory existing 
solely for them. Rather, it exists for their instances.


I am not sure about your objection about the stage. I never mentioned 
time lines, I assumed Susan was adding to the stage at the start of her 
program.


Can you have a main SWF without a timeline (single frame)?
Can you have a program without a stage?

What is more fundamental to a SWF, a stage or timeline?

Maybe I am missing something.

John

Henrik Andersson wrote:

John McCormack wrote:
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.



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


There are two things here that I have to disagree with. To begin with, 
classes does too exist in memory. They are real objects and they have 
properties as well.


And more importantly, your explanation about the stage is not even 
remotely true. The stage is not the same as the main timeline. You 
also seem to imply that no matter where someone calls addChild, it 
will add to the main timeline. Now, I am fairly sure that this was not 
your intention, but you really need to be more clear about these things.

___
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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Paul Andrews

Susan Day wrote:

On Wed, Feb 24, 2010 at 9:44 AM, Geografiek 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?
  


Susan,

Your tiny amounts of code hide the many reasons that you may be getting 
errors.


I know others have made some suggestions but here are things to think about.

1)By convention classes are named with capital letters at the start, 
instances with a lower case letter. This makes it easy to tell apart 
classes from instance in the code.


When you write

MyClass.removeChild(my_obj);

It sets alarm bells ringing about whether you really mean what you write or are 
simply not following coding conventions. In most cases it will result in an 
error.

2) Classes that have parents must be descended from some kind of DisplayObject. 
The obvious candidates are MovieClip and Sprite.

So to play around with parent, your class must extend MovieClip or Sprite or.. 
another class descended from DisplayObject.

We can't tell if you've done that.

3) The parent property will be null even after you've created a class instance 
and will remain null until the instance is attached to a container of some form 
such as a MovieClip, or Sprite or the stage.

addChild() will add a child instance to the "current" object (depends what 
"this" is referring to and where your code is). This is not synonymous with adding 
something to the stage, but may be.

Only when you have added an instance as a child will the parent property of the 
instance be other than null.


So, plenty of ways to trip up, and with tiny code snippets and clear mistakes 
you can see why everyone has to second guess what's going on.

Paul


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.
  
I think Mook is heavy for a first intro to OO and AS3 and I'd suggest 
something lighter to get going.


Paul

TIA,
Susan
___
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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Henrik Andersson

John McCormack wrote:

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.



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


There are two things here that I have to disagree with. To begin with, 
classes does too exist in memory. They are real objects and they have 
properties as well.


And more importantly, your explanation about the stage is not even 
remotely true. The stage is not the same as the main timeline. You also 
seem to imply that no matter where someone calls addChild, it will add 
to the main timeline. Now, I am fairly sure that this was not your 
intention, but you really need to be more clear about these things.

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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Jared

And you wrote addchild(mc) - that's like writing this.addchild(mc).

Also parent is a property so mc.parent should always trace, like  
mc.alpha etc...


Hth


Sent from my iPhone

On Feb 24, 2010, at 8:08 AM, Geografiek   
wrote:


I don't think a class can have children, only instances of classes  
can. (skating on thin ice now ;-))
Also I don't know by heart all the error codes. So please, if you  
refer to an error code give the full text.


I bet your trace resulted in something like [object, MyClass],  
litteraly meaning that the parent is an object and an instance of  
MyClass.

Somewhere you have created that instance with myVar = new MyClass();
so the parent is accessible through myVar.

Also: somewhere you have added my_obj to myVar with myVar.addChild 
(my_obj)

Remove it with myVar.removeChild(my_obj)
If you did just 'addChild(my_obj)' (that is within myVar) you can  
say 'removeChild(my_obj)' (of course also within myVar)

HTH
Willem

On 24-feb-2010, at 15:24, Susan Day wrote:

On Wed, Feb 24, 2010 at 9:44 AM, Geografiek  
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)30-2719512 
 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=




___
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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread John McCormack

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 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
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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Geografiek
I don't think a class can have children, only instances of classes  
can. (skating on thin ice now ;-))
Also I don't know by heart all the error codes. So please, if you  
refer to an error code give the full text.


I bet your trace resulted in something like [object, MyClass],  
litteraly meaning that the parent is an object and an instance of  
MyClass.

Somewhere you have created that instance with myVar = new MyClass();
so the parent is accessible through myVar.

Also: somewhere you have added my_obj to myVar with myVar.addChild 
(my_obj)

Remove it with myVar.removeChild(my_obj)
If you did just 'addChild(my_obj)' (that is within myVar) you can say  
'removeChild(my_obj)' (of course also within myVar)

HTH
Willem

On 24-feb-2010, at 15:24, Susan Day wrote:

On Wed, Feb 24, 2010 at 9:44 AM, Geografiek  
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=




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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Susan Day
On Wed, Feb 24, 2010 at 9:44 AM, Geografiek 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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Geografiek

Susan,
Coming from a non-coders background I learned a lot from Colin Moocks  
books. Essential ActionScript 3 and Actionscript for Flash MX. (the  
last one is AS2 but very readable if you want an understanding of  
concepts like variables, properties, methods, functions, arrays etc.)  
Also Actionscript 3.0 cookbook is very handy.

Al books are published by O'Reilly.
Feel free to ask for directions on lists like these though. I learned  
a lot here and don't mind sharing.

Willem van den Goorbergh

On 24-feb-2010, at 14:48, Susan Day wrote:

On Wed, Feb 24, 2010 at 8:28 AM, Henrik Andersson  
wrote:



Susan Day wrote:


Ok, I'm embarrassed, but the following doesn't work:

addChild(my_obj);
trace(my_obj(parent));


Ok, sounds like you need to learn what a property is. I will leave  
it up to

other people to explain such a fundamental thing.

Your error is treating my_obj as a Function. It clearly is not a  
Function.
So the second line is just garbage logic wise. Your syntax is  
simply way

bellow the minimum requirements for this task.



Yes, I knew that when I wrote my last email. Can you at least point  
me in
the right direction? There is nothing in your response that  
indicates what I
should research, other than "property" and "function", which I feel  
is way

too general.
TIA,
Susan
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=




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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Susan Day
On Wed, Feb 24, 2010 at 8:28 AM, Henrik Andersson wrote:

> Susan Day wrote:
>
>> Ok, I'm embarrassed, but the following doesn't work:
>>
>> addChild(my_obj);
>> trace(my_obj(parent));
>>
>>
> Ok, sounds like you need to learn what a property is. I will leave it up to
> other people to explain such a fundamental thing.
>
> Your error is treating my_obj as a Function. It clearly is not a Function.
> So the second line is just garbage logic wise. Your syntax is simply way
> bellow the minimum requirements for this task.
>

Yes, I knew that when I wrote my last email. Can you at least point me in
the right direction? There is nothing in your response that indicates what I
should research, other than "property" and "function", which I feel is way
too general.
TIA,
Susan
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Geografiek

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

On 24-feb-2010, at 13:28, Henrik Andersson wrote:


Susan Day wrote:

Ok, I'm embarrassed, but the following doesn't work:

addChild(my_obj);
trace(my_obj(parent));



Ok, sounds like you need to learn what a property is. I will leave  
it up to other people to explain such a fundamental thing.


Your error is treating my_obj as a Function. It clearly is not a  
Function. So the second line is just garbage logic wise. Your  
syntax is simply way bellow the minimum requirements for this task.

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




=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=




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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Henrik Andersson

Susan Day wrote:

Ok, I'm embarrassed, but the following doesn't work:

addChild(my_obj);
trace(my_obj(parent));



Ok, sounds like you need to learn what a property is. I will leave it up 
to other people to explain such a fundamental thing.


Your error is treating my_obj as a Function. It clearly is not a 
Function. So the second line is just garbage logic wise. Your syntax is 
simply way bellow the minimum requirements for this task.

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


Re: [Flashcoders] removeChild Question

2010-02-24 Thread Susan Day
On Tue, Feb 23, 2010 at 2:14 PM, Henrik Andersson wrote:

> Susan Day wrote:
>
>> Hi;
>> How do I determine what the parent object is of a child I have added and
>> want to remove?
>>
>
> Usually, there is only one possible candidate and you know what that one is
> ahead of time.
>
> But there is an embarrassingly simple way: the parent property.
>

Ok, I'm embarrassed, but the following doesn't work:

addChild(my_obj);
trace(my_obj(parent));

Please advise.
TIA,
Susan
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild Question

2010-02-23 Thread Henrik Andersson

Susan Day wrote:

Hi;
How do I determine what the parent object is of a child I have added and
want to remove?


Usually, there is only one possible candidate and you know what that one 
is ahead of time.


But there is an embarrassingly simple way: the parent property.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] removeChild Question

2010-02-23 Thread Susan Day
Hi;
How do I determine what the parent object is of a child I have added and
want to remove?
TIA,
Susan
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders