Home > Flex/Air > interview questions – adobe flex and air

interview questions – adobe flex and air

1. Good understanding and working knowledge of object oriented programming
2. Good understanding of Flex SDK
3. Event handling model of Flex
4. Custom component development
5. Experience of developing loosely-coupled components
6. Interacting with remote data
7. Understanding of J2ee architecture (or any other server side technology)
8. Cairngorm micro architecture
9. Unit Testing Framework for Flex
10. Logical thinking

A few interview questions with answers on flex,

1. Is it possible to make httpService Requests synchronous?
A: No.
Solution : Basically, what we are about to do is creating XMLHttpRequest with Javascript in Flex,
and calling a server data with the parameters we will give to the object.
For example: xmlHttpRequest.open(“GET”,”http://localhost/Default.aspx”,false);
1. Request Type: GET or POST

2. Requested URL
3. Communication Type: true for asynchronous, false for synchronous.

2. I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?
A: File is already there , we need to register our ip address to flicker’s crossdomain.xml
? : Since the images are located on a flickr server like farm1.static.flickr.com and there is no
crossdomain.xml file on that server (there is a crossdomain.xml for api.flickr.com so you can use the
api) that means you can’t get access to the bitmapData of the loaded images when you load them
from flickr. This is dumb, but that’s the way it is. So you can load images just fine, but the reflection
class copies the bitmapData of the image, so that doesn’t work if you load them straight from the
flickr server. I also wanted to set bitmap smoothing to true on the images so the thumbnails don’t
look as pixelated, and that also requires access to the bitmapData of the loaded image.

So the answer is to create a proxy that loads the flickr image so it appears to come from the same

3. What is the difference between httpService and Data Service?
A: The services-config.xml configuration file is required at compile time if the Flex application uses
Flex Data Services. In the case of RPC services, this applies to all applications that use
RemoteObject or proxy-based WebService or HTTPService.

4. How do you generate random numbers within a given limit with actionscript?
A: Math.round(Math.random() * (high – low)) + low
5. Have you built any components with actionscript? If so explain how you did it?
package components
{ import mx.controls.ComboBox;
public class CountryComboBox extends ComboBox
public function CountryComboBox()

dataProvider = [ “United States”, “United Kingdom” ];
}<?xml version=”1.0″ encoding=”utf-8″?>

width=”220″ height=”115″

<custom:CountryComboBox />
6. How do you implement push on a flex applications?
A: Using BlazeDS Server, LiveCycle Data Services,

7.I am going to add images into a tag. How will it resize itself?
A1: To let Flex resize the image as part of laying out your application, set the height or width
properties to a percentage value. Flex attempts to resize components with percentage values for these
properties to the specified percentage of their parent container.
A2 : By default, Flex does not resize the image. The scaleContent property has a default value of
true, therefore, Flex scales the image as it resizes it to fit the specified height and width. The aspect
ratio is maintained by default, so the image may not completely fill the designated space. Set the
scaleContent property to false to disable scaling. Set the maintainAspectRatio property to false to
allow an image to fill all available space regardless of its dimensions.

8. What is a resource Manager??
A : the ResourceManager — now handles access to all localized resources in an application. Any
components that extend UIComponent, Formatter, or Validator now have a new resourceManager
property, which lets you easily access the singleton instance of this manager. If you’re writing some
other kind of class that needs to use the ResourceManager, you can call
ResourceManager.getInstance() to get a reference to it.

9.What are the similarities between java and flex?
A : Both can be used as client application, both have packages, OOP based , support XML , import
external packages, up casting, support ArrayCollection ,almost same primitive data types, both
support class library packaging( .jar , .swc).

10. What is the dynamic keyword used for?
A : Specifies that instances of a class may possess dynamic properties added at runtime. If you use
the dynamic attribute on a class, you can add properties to instances of that class at runtime. Classes
that are not marked as dynamic are considered sealed, which means that properties cannot be added
to instances of the class.

11.How do you implement push with flex data services?
A : Using Blaze DS Server & LCDS

12. What are the methods called when a UI component is intialized?
A : all components dispatch the following events that let you specify ActionScript to initialize a

Dispatched when a component has been created in a rough state, and no children have been created.
Dispatched when a component and all its children have been created, but before the component size
has been determined.
Dispatched when the component has been laid out and the component is visible (if appropriate).

13. How do you implement drag and drop on components that do not support ondrag and ondrop?
14.Can you write to the file system from flex?
A: Yes .

import flash.filesystem.*;
private var stream:FileStream;
private function saveFile():void{
var file:File = File.desktopDirectory.resolvePath(“HelloWorld.txt”);
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
var str:String = “Congratulations on your 1st file, Rich Tretola – EverythingFlex.com”;
mx.controls.Alert.show(“File has been saved to \n” + file.nativePath, “Notice”);

15. What is a drag manager?
A : The Flex Drag and Drop Manager lets you select an object, such as an item in a List control, or a
Flex control, such as an Image control, and then drag it over another component to add it to that

16 . HOw do you call javascript from Flex?
A : Using the ExternalInterface API to access JavaScript from Flex and Using the navigateToURL()
method in Flex. The navigateToURL() method is in the flash.net package
flash.external.ExternalInterface.call(function_name:String[, arg1, …]):Object;
navigateToURL(request:URLRequest, window:String):void

17. How do you use a repeater?
public var myArray:Array=[1,2,3,4];

<mx:Panel title=”Repeater: emulating a for loop” paddingBottom=”10″ paddingLeft=”10″
paddingRight=”10″ paddingTop=”10″>

<mx:Repeater id=”myRep” dataProvider=”{myArray}”>
<mx:Label id=”myLabel” text=”This is loop #{myRep.currentIndex}”/>


18. what are three ways to skin a component in flex?

A : Skinning is the process of changing the appearance of a component by modifying or replacing its
visual elements. These elements can be made up of images, SWF files, or class files that contain
drawing API methods.
There are several ways that you can define skins: inline, by using the setStyle() method, and by using
Cascading Style Sheets (CSS).
19. How do you use css styles in flex?
External styles are defined in a separate file and can be used in any MXML file that references the

CSS file. You reference a CSS file into an MXML file with the source property of the <mx:Style>
tag, as follows:
<mx:Style source=”../siteStyles.css”/>

Embedded styles are defined in an MXML file and can only be used in that file. Embedded styles
are defined with the <mx:Style> tag, as follows:

.myclass { background-color: xFF0000 }
TextInput { font-family: Helvetica; font-size: 12pt }

<mx:Button styleName=”myclass”>
Inline styles are defined in an MXML tag and can only be used in that tag. Inline styles are defined

as follows:
<mx:Button color=”red”…>
<mx:TextInput fontFamily=”Helvetica” fontSize=”12″…>

20. What is the difference between sealed class and dynamic classes?
A : Classes are sealed by default, i.e. properties cannot be added dynamically at runtime.
* Dynamic classes can add additional dynamic properties at runtime; sealed classes cannot.
* Sealed classes conserve memory because no internal hash table is needed to store dynamic
properties, and the compiler can provide better error feedback.

21.what is MVC and how do you relate it to flex apps?
A : (Separation of concerns) The goal of the Model-View-Controller (MVC) architecture is that by
creating components with a well-defined and limited scope in your application, you increase the
reusability of the components and improve the maintainability of the overall system. Using the MVC
architecture, you can partition your system into three categories of components:
* Model components Encapsulates data and behaviors related to the data.
* View components Defines your application’s user interface.
* Controller components Handles the data interconnectivity in your application.

22.what is state? what is the difference between states and ViewStack?
A : The State class defines a view state, a particular view of a component. For example, a product
thumbnail could have two view states; a base view state with minimal information, and a rich view
state with additional information. The overrides property specifies a set of child classes to add or
remove from the base view state, and properties, styles, and event handlers to set when the view state
is in effect.
You use the State class in the states property of Flex components. You can only specify a states
property at the root of an application or a custom control, not on child controls.
Diff :
* View Stack is to handle different MXML file eg TAB control and states is the transition within
single MXML file.
* ViewStack should be used were there is complete change in the controls used and States should be
used when you just want to add or remove a

few components based on certain conditions.
* ViewStates are virtual state of an existing page apearing at an instance i.e. only one state can be
shown at a time
while viewStack are collection of different view containers which can be shown at a time

23.how does item renderer work? How do I add item renderer at runtime?
A : Each list control has a default mechanism for controlling the display of data, or view, and lets
you override that default. To override the default view, you create a custom item renderer.
Note: With reusable inline item renderers you use data binding to bind to the item renderer. When
you use a component as an item renderer, you do not use data binding but specify the name of the
custom component to use as an item renderer.

Add itemrendrer at run time: Create the basic item renderer. One of the things I needed to accomplish
with my item renderer was the ability to add it to different columns (ie the dataField was not always
the same). This meant I needed a way from within the renderer to determine what column it was
bound to so I could get and display the correct data. To do this the renderer needs to implement the
IDropInListItemRenderer. This interface allows the renderer to have access to information about the
list and column it is in via the BaseListData and DataGridListData classes. The DataGridListData
gives you everything you need to get the data required to make a flexible, reusable renderer.
To Modify itemrenderer at runtime we Need to use mx.core.ClassFactory. Basically, in order to
change a Flex itemRenderer at runtime, you need to cast it to a type ClassFactory.

24. What keyword allows you to refer to private variables of a class?
A : private keyword , this keyworld (? )
25.how polymorphism works on actionscript?
class UnpaidIntern extends Employee {
override public function receivePayment():Number {
return 0;
}class Manager extends Employee {
override public function receivePayment():Number {
return baseSalary*3;
}class Engineer extends Employee {
override public function receivePayment():Number {
return this.baseSalary*2;
}}class Employee {
internal var baseSalary:Number = 1000;
public function receivePayment():Number {
return this.baseSalary;
26.how do you overload functions in actionscript?
A : Method overloading using namespaces. (?)
27.what is dynamic keyword used for?
A: Dynamic classes, which allow you to programmatically add new properties and behavior to
classes during the run-time. Just add the magic keyword dynamic to the class definition:
dynamic class Person {
var name:String;
}Now let’s add dynamically two variables name and age and the function printme() to the object of

type Person:

Person p= new Person();
p.printMe = function () {
trace (p.name, p.age);
}p.printMe(); // Joe 25

28.what are sealed classes ?
A : A sealed class possesses only the fixed set of properties and methods that were defined at
compile-time; additional properties and methods cannot be added. This makes stricter compile-time
checking possible, resulting in more robust programs.

29 what are runtime shared libraries?
Macromedia Flex 1.5 you can build runtime shared libraries (RSLs) that can be individually loaded,
cached, and used by multiple applications.
Use Flex 3 runtime-shared-libraries (RSLs) to reduce the size of your applications and thereby
reduce the time required to download the application. RSLs are just SWF files whose code is used as
a shared library between different application SWF files. There are two kinds of RSLs, signed and
unsigned. Signed RSLs are libraries that are signed by Adobe and may be stored in the Flash Player
Cache, which can be accessed by applications from any domain. This means if your application is
using a signed RSL, the RSL may not even need to be downloaded if the RSL is already in the Flash
Player Cache. The signed RSL may have been put into the Flash Player Cache by visiting another
web site that was using the same signed RSL. Signed RSLs have a “swz” extension.
Unsigned RSLs are normal SWF files and are not loaded into the Flash Player Cache. Instead, these
RSLs rely on the browser’s cache to keep them from being downloaded.

30.What is cairnghorm ? how do you use it?Have you worked with Cairnghorn?
A : Cairngorm is the lightweight micro-architecture for Rich Internet Applications built in Flex or
AIR. A collaboration of recognized design patterns, Cairngorm exemplifies and encourages best-
practices for RIA development advocated by Adobe Consulting, encourages best-practice leverage of
the underlying Flex framework, while making it easier for medium to large teams of software
engineers deliver medium to large scale, mission-critical Rich Internet Applications.
The benefits of the Cairngorm architecture are realized when developing complex RIA applications
with multiple use-cases and views, with a team of developers, and with a multi-disciplinary
development team that includes designers as well as creative and technical developers.
How is the MVC pattern carried out in a Flex + Cairngorm application?

– Model:???? Role of the ModelLocator & Model Objects
– View:???? Role of View Components & Event Objects
– Controller: Role of the FrontController & Command Objects

31.What keyword allows you to implement abstraction better?
A: Flex does not support abstart class directly. (?)
32.What design patterns have you used? in Actionscript and java?
A:1. Creational Pattern
* Factory Method Pattern
* Singleton Pattern
2. Structural Patterns
* Decorator Pattern
* Adapter Pattern
* Coposite Pattern

3. Behavioral Patterns
* Command Pattern
* Observer Pattern
* Template Metod Pattern
* State Pattern
* Strategy Pattern

4. Multiple Patterns
* MVC Pattern
* Symetric Proxy Pattern

33.What’s the difference between Java and AS3 getters and setters?

34.Explain how binding works in mxml components.
A: Binding in MXML
Lets look at the following code…

<mx:TextInput id=”ti1?/>

<mx:Label id=”label1? text=”{ti1.text}”/>
Here you are binding the text property of the TextInput to the label. So whatever you type in the
textInput automatically reflects in the label. That’s the power of Binding…

The best practice for defining components that return information back to the main application is to
design the component to dispatch an event that contains the return data. In that way, the main
application can define an event listener to handle the event and take the appropriate action. You also
use events in data binding. The following example uses the Bindable metadata tag to make
useShortNames a bindable property. The implicit setter for the useShortNames property dispatches
the change event that is used internally by the Flex framework to make data binding work.

35.What’s the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?

Acts like the watch on AS2. It watches a variable for changes and when something happens fires an
event. Make sure you call the canWatch to ensure that you can watch it!
There are 3 ways to specify the second parameter, the chain.
1. A String containing the name of a public bindable property of the host object.

ChangeWatcher.watch(this, “myvar”, handler)
2. An Object in the form: { name: property name, access: function(host) { return host[name] } }.
The Object contains the name of a public bindable property, and a function which serves as a getter
for that property.

ChangeWatcher.watch(this, { name:”myvar”, getter: function():String { return “something” }},
3. A non-empty Array containing any combination of the first two options. This represents a chain
of bindable properties accessible from the host. For example, to watch the property host.a.b.c, call
the method as: watch(host, [“a”,”b”,”c”]


Works pretty much the same way as the watch, but instead of having to handle and event it allows
you to immediately bind two properties one-way.
The first two parameters are for the the target, the second parameters are the triggers.
BindingUtils.bindProperty( this, “va1”, this, “var2”);

Note : Make sure you add the flex framework.swc to your project Library Path to have access to the
mx.binding.util class.

36.Why would you want to keep a reference to a ChangeWatcher and call unwatch()?
A: So we can reattach the watcher again & We can change the source object (of changewatcher) by
reset method.

The ChangeWatcher class defines utility methods that you can use with bindable Flex properties.
These methods let you define an event handler that is executed whenever a bindable property is
() method:

Detaches this ChangeWatcher instance, and its handler function, from the current host. You can use
the reset() method to reattach the ChangeWatcher instance, or watch the same property or chain on a
different host object.
public function unwatch():void

37.How do you add event listeners in mxml components. Now AS3 components?
* addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0,
useWeakReference:Boolean = false):void
* removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
* dispatchEvent(event:Event):Boolean
* hasEventListener(type:String):Boolean
* willTrigger(type:String):Boolean

38.What does calling preventDefault() on an event do? How is this enforced?
A: Cancels an event’s default behavior if that behavior can be canceled.. For example, the
doubleClick event has an associated default behavior that highlights the word under the mouse
pointer at the time of the event. Your event listener can cancel this behavior by calling the
preventDefault() method.
You can use the Event.cancelable property to check whether you can prevent the default behavior
associated with a particular event. If the value of Event.cancelable is true, then preventDefault() can
be used to cancel the event; otherwise, preventDefault() has no effect.

39.Explain the lifecycle of a Cairngorm action.
A: Here’s a normal flow of operations and the Cairngorm classes that are exercised.
When the user takes some sort of action on the view, such as clicking a button, the view dispatches a
CairngormEvent. This event informs the FrontController, which instantiates a Command. The
command executes the business logic, and the event is responsible for passing data to the command
about the user interaction.

The command can either take some action on theModel, or instantiate and act on a Business
Delegate. The Business Delegate, or delegate for short, wraps the code required for a service call, so
it acts like the service API to the rest of the application. This is important because when the service

changes, the changes to the application can be minimized and ideally only the delegate needs to
change. The delegate calls the service and then depending on the kind of service involved makes sure
that the command is informed when the service call has returned. Then the command changes the
state of the model, if necessary, and the model, through Flex’s binding, updates the view.

40.What is the problem with calling setStyle()
A : Calling the setStyle() method can result in decreased performance. Use it only when necessary.
You should try to apply style sheets rather than use the setStyle() method because it is
computationally expensive. This method should only be used when you are changing an object’s
styles during run time.
You cannot get or set style properties directly on a component as you can with other properties.
Instead, you set style properties at run time by using the getStyle() and setStyle() ActionScript

41.Explain the difference between creating an effect and setting the target as opposed to adding an

A: To create a behavior, you define a specific effect with a unique ID and bind it to the trigger.
For example, the following code creates two zoom effects: one for shrinking the component slightly,
and one for reverting it to its original size. These effects are assigned, by using their unique IDs, to
the mouseDownEffect and mouseUpEffect triggers on the Button component.
<mx:Application …>

<mx:Zoom id=”shrink” duration=”100″ zoomHeightTo=”.9″ zoomWidthTo=”.9″ />
<mx:Zoom id=”revert” duration=”50″ zoomHeightTo=”1″ zoomWidthTo=”1″ />
<mx:Panel title=”Bouncy Button” paddingTop=”10″ paddingBottom=”10″

paddingLeft=”10″ paddingRight=”10″ autoLayout=”false” left=”41″ top=”24″ right=”42″>
<mx:Button id=”bouncyButton” label=”Click me!”
mouseDownEffect=”{shrink}” mouseUpEffect=”{revert}”/>

42.How do you identify a component created in a repeater?
A: If currentIndex value is greater than startIndex value means a component is created in Repeater.
We can use count property to find number of children.
A Repeater component executes initially when it is instantiated. If the Repeater component’s

dataProvider property exists, it proceeds to instantiate its children, and they instantiate their

children, recursively.
The Repeater component re-executes whenever itsdataProvider,startingIndex, orcount
properties are set or modified either explicitly in ActionScript, or implicitly by data binding.
When a Repeater component re-executes, it destroys any children that it previously created
(assuming therecycleChildren property is set tofalse), and then reinstantiates its children based
on the currentdataProvider property.

43. Differences between defining bindings in MXML and ActionScript?
A: There are a few differences between defining data bindings in MXML at compile time and in
defining them at runtime in ActionScript:

* You cannot include ActionScript code in a data binding expression defined by the bindProperty()
or bindSetter() method. Instead, use the bindSetter() method to specify a method to call when the
binding occurs.

* You cannot include an E4X expression in a data binding expression defined in ActionScript.
* You cannot include functions or array elements in property chains in a data binding expression
defined by the bindProperty() or bindSetter() method. For more information on property chains, see

Working with bindable property chains.
* The MXML compiler has better warning and error detection support than runtime data bindings
defined by the bindProperty() or bindSetter() method.

****************** get from net ****************
I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?

Of course it’s Adobe’s problem. The player work “as designed”, but it’s a poor design.
The idea behind crossdomain.xml files is to prove that the site hosting the SWF file also controls the
domain the data is being loaded from. Unless you think that you should need to own Flickr to be able
to host a SWF that can access Flickr images, I can’t see how you could possibly think this is a good
At best it can be said that Flash isn’t designed to do that you’re trying to do, in which cse you’ve
made a bad choice in using it at all. It’s either Adobe’s fault or yours, but certainly not Flickr’s.

What is the difference between httpService and Data Service?

The Flex presentation layer communicates with the business layer by using Flex
data services, which are objects you insert in a Flex file. Specifically, you can use Flex data services
to interact with the following:
* Web services
* HTTP services
* Remote objects
A Flex data service is an object you insert in an MXML file to communicate with the business layer
of a multi-tier application. You use data services to send and receive data from web services, HTTP
URLs, and remote objects such as server-based Java objects.
An HTTP service is nothing more than an HTTP request to a URL. The primary purpose of HTTP
services is to retrieve XML data from an external source.

How do you generate random numbers within a given limit with actionscript?
publicfunction randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max – min + 1)) + min;
returnran domNum;
What are the methods called when a UI component is intialized?
What is a drag manager?

The DragManager class manages drag and drop operations, which let you move data from one place
to another in a Flex application. For example, you can select an object, such as an item in a List
control or a Flex control, such as an Image control, and then drag it over another component to add it
to that component.

All methods and properties of the DragManager are static, so you do not need to create an instance of
All Flex components support drag and drop operations. Flex provides additional support for drag and
drop to the List, Tree, and DataGrid controls.
When the user selects an item with the mouse, the selected component is called the drag initiator. The
image displayed during the drag operation is called the drag proxy.
When the user moves the drag proxy over another component, thedragEnter event is sent to that
component. If the component accepts the drag, it becomes the drop target and receivesdragOver,
dragExit, and dragDropevents.
When the drag is complete, adragComplete event is sent to the drag initiator.
How do you call javascript from Flex?

The ExternalInterface class is the External API, an application programming interface that enables
straightforward communication between ActionScript and the Flash Player container– for example,
an HTML page with JavaScript. Adobe recommends using ExternalInterface for all JavaScript-
ActionScript communication.

You can call an ActionScript function in Flash Player, using JavaScript in the HTML page. The
ActionScript function can return a value, and JavaScript receives it immediately as the return value
of the call.

This functionality replaces thefscommand() method.

The ExternalInterface class requires the user’s web browser to support either ActiveX® or the
NPRuntime API that is exposed by some browsers for plug-in scripting. Even if a browser and
operating system combination are not listed above, they should support the ExternalInterface class if
they support the NPRuntime API. Seehttp ://www. mozilla.org /projects/plug ins/nprunti me.ht ml.

Note: When embedding SWF files within an HTML page, make sure that theid andname attributes
of theobject andembed tags do not include the following characters: . – + * / \
From ActionScript, you can do the following on the HTML page:
Call any JavaScript function.
Pass any number of arguments, with any names.
Pass various data types (Boolean, Number, String, and so on).
Receive a return value from the JavaScript function.
From JavaScript on the HTML page, you can:
Call an ActionScript function.
Pass arguments using standard function call notation.
Return a value to the JavaScript function.
Flash Player does not currently support SWF files embedded within HTML forms.
How do you use a repeater?

The Repeater class is the runtime object that corresponds to the<mx:Repeater> tag. It creates
multiple instances of its subcomponents based on its dataProvider. The repeated components can be
any standard or custom controls or containers.

You can use the<mx:Repeater> tag anywhere a control or container tag is allowed, with the
exception of the<mx:Application> container tag. To repeat a user interface component, you place
its tag in the<mx:Repeater> tag. You can use more than one<mx:Repeater> tag in an MXML
document. You can also nest<mx:Repeater> tags.

You cannot use the<mx:Repeater> tag for objects that do not extend the UIComponent class.
MXML SyntaxHide MXML Syntax
The <Repeater> class has the following properties:
id=”No default”
count=”No default”
dataProvider=”No default”
recycleChildren=”false|true” startingIndex=”0″
repeat=”No default”
repeatEnd=”No default”
repeatStart=”No default” >
What is state? what is the difference between states and ViewStack?
View Stack is to handle different MXML file eg TAB control. And states is the transition within
single MXML file
ViewStack should be used were there is complete change in the controls used and States should be
used when you just want to add or remove a few components based on certain conditions.
Login/Registration/Forgot password is the best example for using States as each page will either add
or remove to the already existing one.

What’s the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?

The ChangeWatcher class defines utility methods that you can use with bindable Flex properties. These methods let you define an event handler that is executed whenever a bindable property is updated.

public function initWatcher():void {
// Define a watcher for the text binding.
ChangeWatcher.watch(textarea, “text”, watcherListener);

}// Event listener when binding occurs.
public function watcherListener(event:Event):void {
myTA1.text=”binding occurred”;
The BindingUtils class defines utility methods for performing data binding from ActionScript. You
can use the methods defined in this class to configure data bindings.
private function init():void {
BindingUtils.bindProperty(textInputDst, “text”, textInputSrc,
What does calling preventDefault() on an event do? How is this enforced?
public function preventDefault():void
Cancels an event’s default behavior if that behavior can be canceled.

Many events have associated behaviors that are carried out by default. For example, if a user types a
character into a text field, the default behavior is that the character is displayed in the text field.
Because theTextEvent.TEXT_INPUT event’s default behavior can be canceled, you can use the

preventDefault() method to prevent the character from appearing.
An example of a behavior that is not cancelable is the default behavior associated with the
Event.REMOVED event, which is generated whenever Flash Player is about to remove a display object
from the display list. The default behavior (removing the element) cannot be canceled, so the
preventDefault() method has no effect on this default behavior.
You can use theEvent.cancelable property to check whether you can prevent the default behavior
associated with a particular event. If the value ofEvent.cancelable istrue, then
preventDefault() can be used to cancel the event; otherwise, preventDefault() has no effect.
private function textArea_textInput(evt:TextEvent):void {
if (evt.text == “\n”) {

<mx:TextArea id=”textArea” verticalScrollPolicy=”on” width=”160″

height=”120″ textInput=”textArea_textInput(event);”>
<mx:text>The quick brown fox jumped over the lazy dog.</mx:text>
LifeCycle of Flex-application?

initialized:Boolean[read- wri te]
A flag that determines if an object has been through all three phases of layout: commitment,
measurement, and layout (provided that any were required).
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Applicationx mlns:mx=”http://www.adobe.com/2006/mxml&#8221; la you t=”absolute”width=”349″
height=”319″ viewSourceURL=”../files/LifeCycleEventsTutorial.mxml”
preinitialize=”recordEvent(event)” initialize=”recordEvent(event)”
creationComplete=”recordEvent(event)” applicationComplete=”recordEvent(event)”>
importmx.ev ents.FlexEv ent;
importflash.ut ils.getTimer;
privatevarreportTxt:String= “”;
privatefu nctionrecord Event(event:F lexEvent):void
reportTxt += (event.type + ” event occured at ” + flash.utils.getTimer() +” ms” +”\n”);

<mx:Panelx=”0″ y=”0″width =”349″heigh t=”319″ la yo ut=”absolute” ti tle=”Life Cycle Events”>
<mx:TextAreax=”10″ y=”10″width =”309″heigh t=”259″ editab le=”false” id=”txtReport”

Q. Can I dynamically instantiate a WebService or HTTPService in ActionScript?
Flex 1.5 does not support this. First declare the tags in MXML and then manipulate the URLs,
request objects, and so forth using ActionScript.
Q. Can I load CSS style sheets dynamically at runtime?

Dynamic loading of CSS files is not supported in Flex. CSS in Flex is processed on the server side during MXML compilation rather than on the client side at runtime. There is a trick though: A CSS file can be compiled into a separate SWF file and loaded dynamically into the application using the Loader component.

Q. When I setvisible=”false”, the component still takes up space and appears in the tab order. Why is
You can often achieve the “display=none” effect by setting the height/width to zero when you set it
invisible, and then set it back to a fixed value or toundefined when you make it visible again.
Q. Why are my ValueObject member variables undefined in the results from my RemoteObject requests?

Flash Player deserializes objects in a special order that can confuse developers used to object
serialization from other RPC systems. When a strongly typed object is returned to the player, it first
creates an instance from the prototype of the registered class without calling the constructor. It then

populates the object with the properties sent in the result. Finally, it calls the constructor without
If your ValueObject constructor expects arguments to initialize an instance, be sure to check whether
arguments were actually sent to the constructor before overriding member variable values.
Q. Why do strongly typed objects appear as “undefined” in the NetConnection Debugger?
The NetConnection Debugger is an old utility from the early days of Flash Remoting that some
developers still find useful. It has an issue, however, displaying types that have been registered with
Object.registerClass(). If your Flex server is installed locally, we suggest enabling server-side
“debug” level logging in /WEB-INF/flex/gateway-config.xml to watch the raw trace information in
the Flex server console/logs from the AMF Gateway as it processes your RemoteObject requests.
Flex Builder also includes a Network Debugger that allows you to monitor AMF traffic.
Q. How do I get access to the J2EE session from my RemoteObjects?
The AMF Gateway provides access to the currentHttpServletRequest instance in a thread local
variable. The session can be obtained from the request, as follows:
12. Can I resize the Internet Explorer browser window from Flex?
UsegetURL() to communicate with JavaScript in the HTML wrapper:
13. Can Flex applications communicate with each other on the client?
See theLocalConnection API in the documentation.
14. Is double-clicking supported on various components?

Unfortunately, double-clicking is not supported by default. If you wish to add this functionality to, say, a List or DataGrid component, you will have to add the following ActionScript 2.0 code to your application:

var someTimestamp:Number;

public function doubleClickHandler( evt:Object ):Void {
var now = getTimer();
// we got a double-click
if( ( now – someTimestamp ) < 500 ) {

// do something here …
}someTimestamp = now;
15. Why are there errors with the macromedia.css.LocatorParser class and WebLogic?

WebLogic ships with its own version of the fop.jar, which in turn includes the batik.jar, which is
older and breaks Flex. To resolve this issue, remove the fop.jar from the CLASSPATH in the
startWebLogic.cmd file. This may apply to non-WebLogic servers as well, where batik.jar was

16. What does “The URL is not in the Proxy’s whitelist” mean?
The whitelist is a security feature in Flex that requires you to define explicitly which URLs a data
service call can access.
You set this by editing the following file: …\[flexroot]\WEB-INF\flex\flex-config.xml
There are three sections, one each for WebService, HTTPService, and RemoteObject. Be sure you
edit the correct section! Each has a subsection which contains nodes. To enable a URL for access by
a Flex dataService call, enter that URL between the tags.
For development phaseonly, you can allow global access with the wildcard rows. The flex-config
file is heavily commented. Open it up and you will see more detailed instructions there.

17. Sometimes, if I don’t move the mouse, “click” and “mouseDown” don’t work. Why is that?
This is a focus issue with Flash Player; usually when the UI changes “underneath” the mouse pointer,
as in a ViewStack navigation where the buttons are in the same screen location.
19. Why ismyTreeNode.label ormyTreeNode.attributes.label undefined?
Make sure you use theTreeDataProvider methods to modify a node. Don’t rely on the node being
XML. For example, the above should bemyTreeNode.getProperty(“label”) instead.

20. When I add or modify an item in my dataProvider, why doesn’t it show up in my DataGrid?
Low-level methods likeArray.push() or myArray[0] = “whatever” do not cause the
dataProvider’smodelChanged event to fire.
When you work with a dataProvider, it is always best to use the dataProvider API. In the above
example, you might code:myDataProvider.addItem(myItemObject) to add an item or use

editField() to modify a value programmatically.
Alternatively, you can callmyDataProvider.modelChanged yourself or reassigndataProvider to
the control, as follows: myDataGrid.dataProvider = myDataProvider;
21. myTree appears just fine but why can’t I access the node attributes?
Select a node in your myTree. In ActionScript, you can reference this node by using the following
code: myTree.selectedNode;

To access the attributes of the node, use the treeDataProvider API. These methods will work for
any formatdataProvider item, which might be an object, array, or XML node.
The following examplemight work: myTree.selectedNode.attributes.myAttribute
But the following example is far more reliable:

23. How do I pass parameters to a pop-up window?
Three different ways to pass data into a title window.
It uses the initobj to pass in several built-in properties plus two user defined

One is a simple string, the other is a reference to the main application that can
be used for binding. Note the variable that holds the application reference is
typed to the name of the application. this is critical for binding to work

27. How do I run Flex as a service?

Flex is not a server that you deploy and run. It is simply deployed as part of your web application. So it will work, no matter which web container you are using: Tomcat, JRun 4, WebLogic, and so forth. To learn how to deploy Tomcat, JRun 4, or any other Java server as a service, refer to the appropriate documentation for the server you are using.

29. How do I get Flex to query my database?

Flex does not have any native database integration functionality. You must have your own server-side
tier that provides the database-access tier and sends the data back to Flex through one of the
following protocols:

RemoteObjects: This is the fastest. It communicates with server-side EJBs or POJOs using
AMF, a binary compressed format.
HTTPService: This one uses the HTTP protocol. Sources can be JSP, ASPx, .NET, or any
URL that returns HTTP.
WebService: This is the slowest. It uses the SOAP protocol. Sources can be .NET or any web
30. I’m sending my request, and I see the data traffic in the command window, but why is the result always
You are probably trying to read the result immediately after thesend(), right? You’re expecting
synchronous behavior?
31. How do I make synchronous data calls?
Youcannot make synchronous calls. Youmust use the result event. No, you can’t use a loop,
setInterval, or even doLater. This paradigm is quite aggravating at first. Take a deep breath,

surrender to the inevitable, resistance is futile.
There is a generic way to handle the asynchronous nature of data service calls, called ACT
(Asynchronous Call Token). Search for this in the Developing Flex Applications LiveDocs for a full
Here it is in a nutshell. This example uses HTTPService but will be similar for RemoteObject and

1. Create a function to handle the data return, likeonResult().
2. In the HTTPService tag, put this function name in theresult property and pass “event” in
3. Invoke the call in the script:

//invokes the call to the HTTP data service
var oRequestCallbject = app.mxdsGetData.send(oRequest);
//Next, define a string to identify the call. We will use this string value
in the result handler.

oRequestCall.MyQueryId = “WhateverIWanttoUseToIdentifyThisCall” ;
//Yes, you CAN set this AFTER you invoke send()
4. In the result handler, which will be called every time the data service call returns, identify
what the returned data contains, as follows:

var callResponse = oEvent.call; //get the call object
//gets the value of this property you set in the call
var sQueryId = callResponse.MyQueryId; //will be

You can use thesQueryId value in a switch to do the correct processing. Alternatively, you can pass
reference to a handler function directly.

32. When I have only a single record, why doesn’t it appear in my DataGrid?
This is a known issue that is caused by the inability of Flex to differentiate between an object and an
array with a single row. The solution is toalways usetoArray(), as in the following examples:

The inline format:
In ActionScript:
myControl.dataProvider = mx.utils.ArrayUtil.toArray(testSrv.result.result.error)
34. Why are the columns in my DataGrid in some strange order?
The order is typically the reverse of the order in which they were added. If you need a specific order,
specify that and many other good things by usingDataGridColumn tags.

35. Can I embed HTML in my Flex application?
Flex supports a limited subset of HTML in itsTextArea and some other text-related classes.
There is also a new article by Christophe Coenraets on his blog discussing how to fake HTML with

an IFRAME:http ://coenrae ts.co m/viewart icle.jsp?art icleId=95
38. Are there frameworks available for Flex?
Yes there are:
Cairngorm:http ://www.it erationtwo.co m/open_source_ca irngorm.ht ml
FlexUnit:http://www.iterationtwo.co m/open_source_f lexuni t.ht ml
SynergyFLEX:http ://www. moss ybl og.co m/archiv es/473.cf m (this link is for 1.0.0a)
AsUnit:http ://www.asunit.org
39. Is vertical text possible in Flex?
Yes, that is possible. You have to embed the font outlines and then use the_rotation property of the
For example, you can use the Label_rotation property. But you would need to embed the font if
you want to rotate a Label, TextInput, or TextArea





Initialization Stage :
a) Construction Stage (Initialization Phase):

In this stage of initialization Phase, the constructor of the component is called by component tag in MXML
or usingnew operator . We can use this stage to;
1) Set some of initial values for the component properties.
2) To add event listeners to the component.
3) And initialize the other objects.

b) Configuration Stage (Initialization Phase):
This stage occur only once in component life cycle. During this step the values assigned for properties of the
component using setters are set internally to refer them later in configuration of component.
c) Attachment Stage (Initialization Phase):
This stage of Initialization Phase gets triggered when component is added to the display list using either
addChild(), addChildAt() Or component created in MXML tags. In this stage the components parent is
defined because the component is now added to the display list. When this component is added to display
list it calls initialize () method to initiate the next stage of this phase, i.e. Initialization Stage.
d) Initialization Stage (Initialization Phase):

After component is attached (Attachment Stage) to the display list, initialization Stage starts. This is
important Stage of the component life cycle. This is responsible to create children objects of the component,
sizing and placing the component and its children, and applying the property, style values to the component.
During this stage following steps occurs;

Step1: Dispatch preinitialize event.
Step2: Callscreat eChildren() method to create children of the component.
Step3: DispatchInitia lize event
Step4:Inval idation: Marks the component for Invalidation which results the component to go with methods

invalidateProperties(), invalidateSize()and invalidateDisplayList(). (We see more about Invalidation after
some lines)
Step5:Val idation: Invalidation of last step results to validation methods like commitProperties(), measure()
andupdateDisplayL iIst().(we see more about Validation after some lines)
Step6: Dispatchcreat ionCom ple te event.
  1. August 3, 2013 at 7:26 PM

    Then, write a short ad copy that lays more emphasis on the product’s benefits. The only factor an online writer needs to be concerned with is if the words and sentences are easy to read and be understood by the average individual. For more details and information, follow the links below.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: