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
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. 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.
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.
<mx:Application
xmlns:mx=”http://www.adobe.com/2006/mxml”
xmlns:custom=”components.*”
width=”220″ height=”115″
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.
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
component:
preInitialize
Dispatched when a component has been created in a rough state, and no children have been created.
initialize
Dispatched when a component and all its children have been created, but before the component size
has been determined.
creationComplete
Dispatched when the component has been laid out and the component is visible (if appropriate).
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”;
stream.writeUTFBytes(str);
stream.close();
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
component.
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
]]>
</mx:Script>
<mx:Panel title=”Repeater: emulating a for loop” paddingBottom=”10″ paddingLeft=”10″
paddingRight=”10″ paddingTop=”10″>
</mx:Repeater>
</mx:Panel>
</mx:Application>
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”/>
<mx:Style>
.myclass { background-color: xFF0000 }
TextInput { font-family: Helvetica; font-size: 12pt }
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.
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
Person p= new Person();
p.name=”Joe”;
p.age=25;
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
3. Behavioral Patterns
* Command Pattern
* Observer Pattern
* Template Metod Pattern
* State Pattern
* Strategy Pattern
4. Multiple Patterns
* MVC Pattern
* Symetric Proxy Pattern
34.Explain how binding works in mxml components.
A: Binding in MXML
Lets look at the following code…
<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.
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” }},
handler);
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”);
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.
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?
A:
* 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.
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
methods.
effectListener
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″
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
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
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
design.
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.
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.
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.
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.
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.
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.
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.
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);
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
]]>
</mx:Script>
<mx:TextArea id=”textArea” verticalScrollPolicy=”on” width=”160″
</mx:Script>
<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”
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.
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
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:
public function doubleClickHandler( evt:Object ):Void {
var now = getTimer();
// we got a double-click
if( ( now – someTimestamp ) < 500 ) {
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
included.
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.
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
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:
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
correctly.
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.
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:
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
description.
Here it is in a nutshell. This example uses HTTPService but will be similar for RemoteObject and
WebService:
//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.
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
“WhateverIWanttoUseToIdentifyThisCall”;
trace(sQueryId);
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:
In MXML:
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
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.
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
Recent Comments