Where is the "int main ()" in my Flex application?

Well, not literally, of course, but:

I'm new to Flex, and I'm trying to figure out where to put the code that I want to run when my application starts. In my example, I have a tree pointer defined in the markup, and I have AS code that can populate it from a local file or web service. How to connect one with another so that when creating a control code is executed?

In the examples I found in the documentation, everyone uses event handlers, i.e. E. They put 'creationComplete = "myInitFunction (evt)"' in the control's open tag. This would mean that I am writing a small glue function that initializes things.

Now, as I understand it, Markup is really converted to AS classes inside. Can I not just define the class created by the engine and put the startup code in the constructor? Maybe even like extending the Tree class?

EDIT

After a few months I’m much wiser. After trying to abuse the constructors of extended component classes, I had to find out that Flex does not expect designers to do much - of course, without downloading data from the network.

Explaining the component life cycle in Flex 3 Programming was really helpful. Now my constructors are empty, and I redefine lifecycle methods, such as createChildrenfor many things, and use events for something that is related to delay or depends on external factors, especially network materials.

, creationComplete ( HTTPService), , ResultEvent FaultEvent, ResultEvent , , . , -, .

+3
3

creationComplete ( Application) Application. applicationComplete ( ..) ( ).

, , - - creationComplete , , ( ), . , , , , (, HTTPService).

, MXML AS3, . , AS3 ( ). . () UIComponent (, , ..), , createComplete ( ).

+5

, int main() actionscript 3. Flex, , node mxml ( mx: Application), int main().

, , , mx: Application. - , , , - , . createComplete , , , .

applicationComplete.

+2

.

"" Flex, , http://www.wietseveenstra.nl/blog/2007/02/understanding-the-flex-application-startup-event-order:

applicationComplete () dispatches events after the application has been initialized, processed by the LayoutManager and added to the display list. This latest event is dispatched during the launch request. This is later than the creation of the applicationComplete () event, which is sent before the preloader is deleted, and the application is attached to the display list.

0
source

All Articles