Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Henrik Andersson
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Geografiek
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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
...@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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Nathan Mynarcik
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Geografiek
] 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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Nathan Mynarcik
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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
); } } 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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Nathan Mynarcik
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Nathan Mynarcik
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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Geografiek
); } 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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread tom rhodes
, 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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
...@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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Lehr, Theodore
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); {

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Keith Reinfeld
: 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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Glen Pike
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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Lehr, Theodore
...@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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread tom rhodes
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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Henrik Andersson
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(); ...

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Geografiek
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++) {

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Nathan Mynarcik
-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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Lehr, Theodore
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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Merrill, Jason
...@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

Re: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Kerry Thompson
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 :-)

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Glen Pike
-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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Keith Reinfeld
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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Nathan Mynarcik
- 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

RE: [Flashcoders] Finding and Removing a Sprite

2010-02-23 Thread Lehr, Theodore
: [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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Merrill, Jason
[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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Mark Winterhalder
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

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Keith Reinfeld
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();

RE: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread Merrill, Jason
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

Re: [Flashcoders] Finding and Removing a Sprite: PART II

2010-02-23 Thread tom rhodes
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