Re: [Flashcoders] Finding and Removing a Sprite
Lehr, Theodore wrote: How can I find it an remove it? You need to get a reference to it. I recommend simply storing the one you used with addChild. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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] Finding and Removing a Sprite
that does help - thanks... I traced the parent and get: [object MainTimeLine] How would I incorparate that into: removeChild(mySprite) ? TIA From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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] Finding and Removing a Sprite
I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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] Finding and Removing a Sprite
You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, In your case try root.removeChild(mySprite); btw: the use of root is not recommended though. There was a discussion lately why. Maybe Jason is willing to illustrate in the case of this example? Willem On 23-feb-2010, at 15:31, Lehr, Theodore wrote: I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ 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] Finding and Removing a Sprite
Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ 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] Finding and Removing a Sprite
I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http
RE: [Flashcoders] Finding and Removing a Sprite
tried that... no dice - just not seem to be able to find it From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 10:10 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, In your case try root.removeChild(mySprite); btw: the use of root is not recommended though. There was a discussion lately why. Maybe Jason is willing to illustrate in the case of this example? Willem On 23-feb-2010, at 15:31, Lehr, Theodore wrote: I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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 ___ 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] Finding and Removing a Sprite
Bingo! Try this instead: var mySprite:Sprite = new Sprite(); function createBar(dfile:String):void { ... function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:21:26 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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
Re: [Flashcoders] Finding and Removing a Sprite
I have no clue why you have a function inside a function. I am going to assume you have a good reason for it. Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:21:26 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ 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
Re: [Flashcoders] Finding and Removing a Sprite
you could also make createBar return a reference to the sprite... function createBar(dfile:String):Sprite { ... mySprite = new Sprite(); // do stuff addChild(mySprite); return mySprite; } var mySprite:Sprite = createBar(string); then you can remove it using your stored reference to the sprite... function blah():void { removeChild(mySprite); } On 23 February 2010 16:35, Geografiek geograf...@geografiek.nl wrote: Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders List flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [ nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [ geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) t From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes [tom.rho...@gmail.com] Sent: Tuesday, February 23, 2010 10:50 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite you could also make createBar return a reference to the sprite... function createBar(dfile:String):Sprite { ... mySprite = new Sprite(); // do stuff addChild(mySprite); return mySprite; } var mySprite:Sprite = createBar(string); then you can remove it using your stored reference to the sprite... function blah():void { removeChild(mySprite); } On 23 February 2010 16:35, Geografiek geograf...@geografiek.nl wrote: Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders List flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [ nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [ geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010
RE: [Flashcoders] Finding and Removing a Sprite: PART II
So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
bar.name = bar_ + i; function destroyBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = getChildByName(bar_ +i) as Sprite; if(bar) { ... removeChild(bar); } } } Lehr, Theodore wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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] Finding and Removing a Sprite: PART II
Thanks man - that did it From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ 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] Finding and Removing a Sprite: PART II
ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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] Finding and Removing a Sprite: PART II
Lehr, Theodore wrote: Any ideas? Store a reference to each object in a vector like this: var bars:Vector.Bar=new Vector.Bar(); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Bar = new Bar(); ... addChild(bar); bars.push(bar); } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
You could create an empty array (outside the functions) And add each newly created bar to the array. Afterwards, say in another function, you can reference the array indexes. Something like: myBarsArray = new Array(); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); myBarsArray.push(bar); { } function removeBars(i:uint):void { removeChild(myBarsArray[i]); //don't remove the bar from the array } HTH, Willem On 23-feb-2010, at 17:55, Lehr, Theodore wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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] Finding and Removing a Sprite: PART II
Inside your loop, you can add the sprite to a movieclip and give each movieclip a name using the variable in your loop like: mcName.name = mc+i; //or whatever your for loop var is And then remove it by getChildByName(mc#); --Original Message-- From: Lehr, Theodore Sender: flashcoders-boun...@chattyfig.figleaf.com To: Flash Coders List ReplyTo: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II Sent: Feb 23, 2010 10:55 AM So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ 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] Finding and Removing a Sprite: PART II
I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Theodore Lehr wrote: thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) Glad you got it fixed. I'm late to the discussion, so didn't contribute anything yet--but I will now :-) Do yourself a favor now. One of the real advantages of AS3 is eliminating timeline code--you have to do that eventually to take advantage of AS3's OOP capabilities. Make a backup of your .fla before you do this, in case something goes wrong. In the same folder where your .fla file is, create an ActionScript file called Main.as. Inside it, use this: package { public class Main extends Sprite { //functions go here } } Now cut and paste all your code from the timeline and put it after the line //functions go here. You can overwrite that line--just keep your functions in between the inner set of curly brackets. In the .fla file, in the Properties window, set your document class to Main. Remember, ActionScript is case sensitive. It should compile and run the same as before, but you will have taken a good first step towards utilizing AS3's power. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
I think it depends on the circumstances: If you are not manipulating the child sprites in any way, just adding them at the start, removing at the end and possibly listening for events on them, why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? If I was needing to move things around, or juggle the display order, or manipulate sprites in the container, I may want to store a reference to them, but if they are just display elements, it's even simpler just to add them to a container sprite then iterate through the container when you are done with them if you need to remove listeners. Obviously this is purely down to coding preferences, but why waste arrays, when your DisplayObjectContainer does it for you... Glen Merrill, Jason wrote: I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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 ___ 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] Finding and Removing a Sprite: PART II
addChildAt(child:DisplayObject, index:int) So: this.addChildAt(barMom, 0); Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 11:29 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ 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 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
You can use the addChildAt method and tell it where to add the object in the displaylist. addChildAt(objectName, 0); will add the objectName to the bottom of the display list. Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 12:28:39 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
awesome - thanks From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kerry Thompson [al...@cyberiantiger.biz] Sent: Tuesday, February 23, 2010 12:36 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Theodore Lehr wrote: thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) Glad you got it fixed. I'm late to the discussion, so didn't contribute anything yet--but I will now :-) Do yourself a favor now. One of the real advantages of AS3 is eliminating timeline code--you have to do that eventually to take advantage of AS3's OOP capabilities. Make a backup of your .fla before you do this, in case something goes wrong. In the same folder where your .fla file is, create an ActionScript file called Main.as. Inside it, use this: package { public class Main extends Sprite { //functions go here } } Now cut and paste all your code from the timeline and put it after the line //functions go here. You can overwrite that line--just keep your functions in between the inner set of curly brackets. In the .fla file, in the Properties window, set your document class to Main. Remember, ActionScript is case sensitive. It should compile and run the same as before, but you will have taken a good first step towards utilizing AS3's power. Cordially, Kerry Thompson ___ 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] Finding and Removing a Sprite: PART II
IMO, an array is hardly a waste of space, and allows for expanding your app easier if need be, but you're right, could come down to coding preferences in that case. More often though I think, the benefits of storing them in an array outweigh the benefits of dynamic naming. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Tuesday, February 23, 2010 12:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II I think it depends on the circumstances: If you are not manipulating the child sprites in any way, just adding them at the start, removing at the end and possibly listening for events on them, why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? If I was needing to move things around, or juggle the display order, or manipulate sprites in the container, I may want to store a reference to them, but if they are just display elements, it's even simpler just to add them to a container sprite then iterate through the container when you are done with them if you need to remove listeners. Obviously this is purely down to coding preferences, but why waste arrays, when your DisplayObjectContainer does it for you... Glen Merrill, Jason wrote: I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ 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 ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
On Tue, Feb 23, 2010 at 6:43 PM, Glen Pike g...@engineeredarts.co.uk wrote: why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? We're talking about only nine instances here. It would be a different matter if it were tens or hundreds of thousands, but even then the additional memory required to store another reference to them would be insignificant compared to the memory the Sprites themselves would use, and performance would be the far bigger issue. So, a descriptively named collection has a higher benefit, for readability alone. Preferably a Vector, so casting isn't necessary even when the Sprites for the bars become a proper Bar class, as they probably should. I'd still put them in their own container, though. Then the container goes on top of another with the lines. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
More than one way to get things done. Depends on your needs. Check out DisplayObjectContainer in the docs. var barMom:Sprite = new Sprite(); this.addChildAt(barMom, 0); function createBars():void { for (var i:int=0; i 9; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat + i; barMom.addChild(bar); } } function spankABrat(container:Sprite, childName:String):void{ container.removeChild(container.getChildByName(childName)); } function eightySixBrats(container:Sprite):void { var len:uint = container.numChildren; for (var i:uint = 0; i len; i++) { container.removeChildAt(0); } } trace(barMom.numChildren =,barMom.numChildren);// 0 createBars(); trace(barMom.numChildren =,barMom.numChildren);// 9 spankABrat(barMom, barBrat3); trace(barMom.numChildren =,barMom.numChildren);// 8 eightySixBrats(barMom); trace(barMom.numChildren =,barMom.numChildren);// 0 Jason: Doesn't storing them in an array create a set of references that will need to be cleaned up? Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
Doesn't storing them in an array create a set of references that will need to be cleaned up? Absolutely (if the app performance even needs cleaning up and/or the items are even removed). But that's easily taken care of with a cleanup function. So for small uses, as I mentioned, may not be worthwhile, but I am thinking long term scalability. I just hate to see people default to dynamic naming all the time when architecturally, using arrays as storage is better in the long run. For this, the dynamic naming would be fine. I'd just be careful to make it a habit for everything. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
yeah, horses for courses... if you want to better encapsulate stuff, i find it easier to work with arrays (in fp10 vectors) and pass them around if needs be. tying your code to specific timelines gives you more work to do if you want to reuse that code imho. for something quick and dirty in timeline code though that you know you don't want to reuse then whatever's clever. Mr. Jason Merrill is right though about having cleanup functions for whatever you create being a great way to not getting into trouble later i reckon... On 23 February 2010 20:47, Merrill, Jason jason.merr...@bankofamerica.comwrote: Doesn't storing them in an array create a set of references that will need to be cleaned up? Absolutely (if the app performance even needs cleaning up and/or the items are even removed). But that's easily taken care of with a cleanup function. So for small uses, as I mentioned, may not be worthwhile, but I am thinking long term scalability. I just hate to see people default to dynamic naming all the time when architecturally, using arrays as storage is better in the long run. For this, the dynamic naming would be fine. I'd just be careful to make it a habit for everything. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) ___ 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