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.com<nat...@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 List<flashcoders@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
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders