Dynamically creating states causes a memory leak.
Hi
I've created a custom component that all children elements of are dynamically
created. Adding a new child to this component will cause all other children to
move and or resize. I am using states to animate this resize or movement.
Whenever someone resizes the window, drags and drops a component adds or
removes a component I need to animate this process. I'm creating states on the
fly and adding them to the states array. This means however that the states
array will fill up.
I tried doing the following.
however that means that I can't set the state to tempstate again as this is
the current state name.
My working example requires that each state is given a unique name.
However trying to pop the state off the states array give me an error when I
navigate to the next state. So I just didn't remove the state. However since
the state is one shot doesn't that mean I'm just filling up memory with
something that isn't necessary?
Is there any work arround for this. Or do my animations even need states to
function? (just Move and Resize effects)
Thanks for any light you may shed on this matter.
---------------------------------------
OFF TOPIC
When adding an element to the beginning of an array I tend to reverse the
array, push the element and then reverse again. Is this really the best way of
doing things?
var state:State= new State
state.name="tempstate"
// set state properties here.
currentState="tempstate";
//will never navigate to this state again so safe to remove it.
states.pop()
|