removing and readding is a bit expensive.  Are you scaling the content
of a component?  You should just set the scaleX,scaleY and reposition.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Wednesday, March 28, 2007 9:57 AM
To: [email protected]
Subject: [flexcoders] Re: Scaling Custom Components



Thanks everyone for your response. Now that I understand how children
are added/removed i can take out some of my work arounds in other
projects!

The scaling works great now.

New question:
Is this the best way to scale? Is it expensive to remove and re-add
all the components when I want to redraw? In this component I have
graphics and text and it seems really fast. But what if I used more
complex things like sprites or containers? Would removing all of them
then re-adding them be the best way to redraw?

Thanks guys. 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "g_odds" <[EMAIL PROTECTED]> wrote:
>
> If you just want to remove all the children, do something like this:
> 
> while (this.numChildren() > 0)
> this.removeChildAt(0);
> 
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <aharui@> wrote:
> >
> > Nope, it is essentially an array. If I have
> > 
> > var a:Array = [ "Nate", "Alex"];
> > a[2] = "Bjorn";
> > a.shift();
> > a[2] is no longer "Bjorn", you are now at a[1].
> > 
> > ________________________________
> > 
> > From: [email protected]
<mailto:flexcoders%40yahoogroups.com> 
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> > Behalf Of Bjorn Schultheiss
> > Sent: Tuesday, March 27, 2007 6:19 PM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com>

> > Subject: Re: [flexcoders] Scaling Custom Components
> > 
> > 
> > 
> > Hey Alex,
> > 
> > if 0 == childA
> > can you insert childB at 99 for example.
> > 
> > if so if you remove childA does childB's index change?
> > 
> > can you ensure that you're child will remain at an index?
> > 
> > 
> > 
> > On 28/03/2007, at 11:12 AM, Alex Harui wrote:
> > 
> > 
> > 
> > 
> > Children renumber after one is removed
> > 
> > 0 = childA
> > 1 = childB
> > 2 = childC
> > 
> > After removeChildAt(0)
> > 
> > 0 = childB
> > 1 = childC
> > 
> > Look at the code for removeAllChildren.
> > 
> > It will either removeChildAt(0) j times or iterate backwards.
> > 
> > ________________________________
> > 
> > From: [email protected]
<mailto:flexcoders%40yahoogroups.com> 
> > [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com> ] On Behalf Of Nate Pearson
> > Sent: Tuesday, March 27, 2007 5:22 PM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com>

> > Subject: [flexcoders] Scaling Custom Components
> > 
> > 
> > 
> > I have a custom component that adds multiple shapes during
> > UpdateDisplayList. When I scale the browser it calls update
> > display
> > list and draws over all of my shapes.
> > 
> > I have tried:
> > 
> > j = this.numChildren;
> > for (i=0; i<j; i++){
> > this.removeChildAt(i);
> > }
> > 
> > Before I write redraw my shapes in UpdateDisplayList. I always
> > get an
> > outofbounds error after i exceed numAutomationChildren(?). If i
> > try
> > the same loop with numAutomationChildren nothing disappears.
> > 
> > It won't let me call this.removeAllChildren (i think because I'm
> > extending an UIComponent and not a Container)! Isnt there a way
> > for
> > me to get all those shapes outta there?
> > 
> > Maybe I'm taking the wrong approach.
> > 
> > Thanks in advance,
> > 
> > Nate
> >
>



 

Reply via email to