While I was making a custom component which would take certain data which would then create objects that were then added dynamically to a ViewStack. This was all done with Actionscript and I was wondering why all the object were being created the second they were added to the ViewStack. This confused me because the standard behaviour when using ViewStacks in Flex is that nothing is created until it’s needed. It’s called deferred instantiation and it’s something that Flex does quite a bit in it’s process to reduce load time and memory consumption.
However, I quickly learned that when you use Flex based components and you create them with Actionscript, their behaviours change. This annoyed me because it’s another bad development design implemented in Flex (behavior change) which doesn’t make any sense. But yet again, there is a workaround for it.
What needs to be done is when you add whatever component to your Viewstack, you just need to set the creationPolicy to ‘none’. This will prevent the early instantiation of your component until the Viewstack actually needs it.
Copyright © Thinking in Code. All Rights Reserved. Powered by Wordpress