PDA

View Full Version : CREATION_COMPLETE loading problem


CraigL
07-16-2007, 04:31 AM
Problem:
In flex I cannot set the value of a variable before the component has been shown on the screen once (creationComplete). Say for example that I have a ViewStack with two children (childX and childY). In childX I press a button and it sets a variable in childY to "hello world." This works if childY has become visible once, but not before. I tried attaching a FlexEvents.CREATION_COMPLETE to the component, but that did not work. I am assuming there is some sort of event listener that I am missing here that will tell me when a component is done being created.

(Mods if you think this would be better under Flex please move it there, It is 50% an AS3 problem, 50% Flex)

flexy
07-16-2007, 09:52 AM
CreationComplete is the way to go. Assuming this is a Flex UIComponent:

myUIComponent.addEventListener( FlexEvent.CREATION_COMPLETE, callback );

hangalot
07-16-2007, 04:51 PM
this is a completly flex question actually.

ViewStack has a creation policy that can be specified which would influence when the creation complete event is fired.
the recomended way of doing this is to use binding on mxml level

dr_zeus
07-16-2007, 05:08 PM
this is a completly flex question actually.

ViewStack has a creation policy that can be specified which would influence when the creation complete event is fired.
the recomended way of doing this is to use binding on mxml level

To clarify, instead of setting the value directly on the child in the second page of the ViewStack, you should save it in a variable within your component. Bind that variable to the property on the child that you want to ultimately change. The change will happen once it gets created.