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
-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
[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
18 matches
Mail list logo