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
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
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
...@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
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
] 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
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
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
);
}
}
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
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
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
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
);
}
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
, 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
...@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
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);
{
: 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
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
...@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
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
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();
...
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++)
{
-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
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
...@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
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 :-)
-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
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
-
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
: [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
[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
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
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();
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
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
35 matches
Mail list logo