add event into the loader in flex 4 air - apache-flex

I would like to know if it's possible to add some jobs on the onload of my air app, what I mean is:
I have an eventHandler which get the event "FlexEvent.APPLICATION_COMPLETE" but this event it`s dispatched after the progress bar ends, I would like to know if there is some event that I can handler and add my jobs there?!?
Or the only way to do this, it's doing a custom preloader??, like the link bellow:
Custom Preloader in Flex 4?
Thanks for all!

There are four events that an Application dispatches during its creation and initial display:
preinitialize
initialize
creationComplete
applicationComplete
More info at Adobe: About Startup Order
EDIT:
However, the Application itself is not instantiated until after all the RSL's have loaded, ie., when the Preloader fires an Event.COMPLETE (for that part of the preload). The preinitialize event on the Application should get fired while the Preloader is still displayed, but the initialization phase might just be much faster relative to the other loading phases. So, yes, if you want to do something concurrent to the Preloader loading RSL's, you have to write a custom preloader.

Related

FullCalendar event editable callback

I am implementing a FullCalendar Scheduler where the client can drag the events around the timeline.
When an event is dragged and dropped somewhere, an ajax call is made, where the backend perform some operations on the database, and possibly reverts the event if something went wrong.
What I want to achieve, is to block the event dragging possibility, while the backend script runs, so the users can not drag and drop anything until the backend code finishes. This could be easily achievable, by having a callback function for the event objects editable property where I check a global variable to determine if any event is in the upgrading process currently, or not, but unfortunatly, it seems that FullCalendar does not support this.
Do you know of any other solution to achieve my desired behaviour?
At the moment I am using FullCalendar V3, so I would prefer a solution to that version, but if an easy to implement solution shows itself with V4, I am willing to upgrade.

Flex Events flow in non hierarchy e.g via framework responder

say an application has panel and panel has button and textField or textArea. we click on a button to hit a service say via cairngorm framework.
The Events lifecycle follows the capture-target-bubble cycle in the display hierarchy like the MouseClick event on button will call the handlers for the listeners attached to button and/or panel and/or application and/or stage since the flow moves in this direction.
How do the event on non hierarchy works e.g the result from the service fires a custom event DataRecieved. we have a listener attached to the panel/button for this dataRecieved event. How do this listener gets the information? how the event lifecycle comes into this picture?
Can anyone explain this?
Thanks!
Since it's a non-DisplayObject, the Event only has a target phase. That means that only listeners attached to the Object which is identical to the Object in the target property of the Event work. Hence, non-DisplayObject's can only dispatch Events to themselves. At least that's how I understand it.
In answer to a related question there is some discussion of writing custom EventDispatcher's that would enable a bubbling for non-DisplayObject's.
If you dispatch a custom event on a Flex UIComponent via dispatchEvent, the UIComponent takes care of bubbling the event through the display hierarchy, as long as the bubbles flag in the Event object is true.
I found out the concept of GlobalEventDispatcher to which we can attach listeners and dispatch from the same.
a ref from another question was helpful - Flex Custom Event dispatching
The important point is that - the instance of dispatcher must be same. we can keep a Custom Global singleton event dispatcher for our application or we can use stage/systemManager/FexGlobals.toplevelapplicaton for the purpose which might not be a good Practice.

Flex - Difference between creationComplete and ApplicationComplete event?

Folks,
I didn't get the difference between those two event.
What is the difference between them ?
Explanation with e.g will always be appreciated.
Thanks.
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ee6.html
Each component dispatches a creationComplete message during application startup - if it is meant to be created at startup. Otherwise each component will dispatch the message whenever it is actually created.
From the documentation link above:
After all components are created and
drawn, the Application object
dispatches an applicationComplete
event. This is the last event
dispatched during an application
startup.
*Edited to reflect other times when creationComplete events get dispatched, besides just the context of application startup.
See this link with the full explanation. In addition, creationComplete is dispatched by every Flex component but applicationComplete dispatched only one time by Application itself.
Both the Creationcomplete and application complete is part of the flex application life cycle. For more information and examples you can go to the following link:
http://technobytz.com/flex-preinitialize.html
Another important difference is your application doesn't have a reference to the stage until the applicationComplete is dispatched

Mate not listening to events - Flex

I am working on a simple project involving flex 4 and Mate framework. When I am including Mate event map in fx:declarations tag in mxml file, and when I fire up an event, Mate event handlers listen to events and act upon it.
The issue is this, in action script based project, when I instantiate the eventmap class(this is in mxml file only) and keep it in top and fireup an event, instantiated eventmap is not listening to event fired up from action script class.
What do you think is going wrong?
Thanks in advance.
Antony. Just a suggestion, getting an example CafeTownSend http://mate.asfusion.com/page/examples/cafe-townsend is not a bad idea.
Build your application using that example will be much more easy. You can learn the event handling of MATE from that project too.
For some reason, the events dispatched by actionscript classes cannot be listened to by Mate event handlers.
To ensure, event handlers definitely receive events appropriately, we should make use of the class defined in mate called, com.asfusion.mate.events.Dispatcher. we just need to instantiate and dispatch an event with this class.

Flex Component Lifecycle with Menus - best practice

I have built a multiplage application in Flex with different user roles. I use a View Stack with a Menu Bar to navigate between the different pages.
However - each time a page gets opened, I need to do some database calls, apply User Role settings, etc. in an init() function. This init function may reference some UI elements of this page.
I tried to load it with the "creationComplete" event, but this one gets only triggered once (since the page is not rebuilt each them the view stack shows it).
Now I have put it on the "show" event, but this seems not to get triggered consistently, or before the page is fully created the first time.
Whats the best practice for this case?
* I have to pass in data
* Call init functions (database calls)
* Manipulate components
Ideally I would need a way to call init each time the page is loaded and after all components are created.
Thanks for your help,
Martin
Just an idea but why not trying to do your remote call on ViewStack change effect. You could use an interface for this that your views implements.
Try updateComplete event.
Dispatched when an object has had its commitProperties(), measure(), and updateDisplayList() methods called (if needed).
This is the last opportunity to alter the component before it is displayed. All properties have been committed and the component has been measured and layed out.
I had the same kind of problem when I wrapped the s:Group with wrapper class to put inside TabNavigator. The result, show event is not being called. Finally I changed all my s:Group with mx:Canvas, directly put them into TabNavigator(The same thing goes for ViewStack too). After that creationComplete event was called once and subsequent page visits call show of mx:Canvas

Resources