Labels

Saturday, November 14, 2009

Flex: Error #2148

Only local-with-filesystem and trusted local SWF files may access local resources.

Solution (a workaround maybe):

Add the following arguments to the compiler (via Properties - Flex Compiler) :

-use-network=false

Tuesday, November 10, 2009

Flex: Slow response time of weborb/remote object call?

If you are experiencing very slow response time of weborb or a remote object call in flex, just make sure you have installed latest version of flash player and flash player debugger for whichever browser you are using to run your swf or flex application. This is my experience and the trick worked. Hope it might solve your problem.

Get them here:
http://www.adobe.com/support/flashplayer/downloads.html

Monday, November 9, 2009

Flex: Stop Event Propogation

Stopping propagation

During any phase, you can stop the traversal of the display list by calling one of the following methods on the Event object:

You can call either the event's stopPropagation() method or the stopImmediatePropagation() method to prevent an Event object from continuing on its way through the event flow. The two methods are nearly identical and differ only in whether the current node's remaining event listeners are allowed to execute. The stopPropagation() method prevents the Event object from moving on to the next node, but only after any other event listeners on the current node are allowed to execute.

The stopImmediatePropagation() method also prevents the Event objects from moving on to the next node, but it does not allow any other event listeners on the current node to execute.

(source: Adobe Livedocs)

Flex: Magic line to remove event listener.

event.currentTarget.removeEventListener( event.type, arguments.callee);

Sunday, November 8, 2009

Flex: Difference between event.target and event.currentTarget properties in an event object.

In Flex, an event object is created whenever an event is dispatched. The event object has two important properties – event.target and event.currentTarget. The event.target property references the event dispatcher while event.currentTarget property refers to the node which is currently being checked for event listeners. While event.target property stays the same throughout the event flow (capturing, targeting and bubbling phases), the event.currentTarget property changes on each node.

For example, if an event is fired from a TextInput component placed inside a Panel, event.target in this case will be TextInput throughout the event flow while event.currentTarget will vary from Application to Panel to TextInput as the event object goes up or down the flow chain.

An important point to note over here is that when an event is fired from a component, event.target property does not necessarily reference the component which dispatched the event. It may refer to a subcomponent which is part of that component. This means that if you click on a button’s label, the event object’s event.target property won’t be button (as you might have hoped) but will be a subcomponent (within the button class) – UITextField (renders label in a button).This is a very important point while handling events. In this case, if the button component was listening for the click event, the event handler will be called if you are using event.currentTarget property since (sooner or later) event.currentTarget will refer to the button component as the mouse event bubbles through the chain. But, if you were using event.target property, the event handler will never get called as a subcomponent (UITextField) fired the event and is referred to in event.target property. Hence, you should always use event.currentTarget property instead of event.target.