Tuesday, April 27, 2010

Collection of Flex Interview Questions

Flex interview questions

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,

Flex is the way to make rich Internet applications (RIAs) quickly and easily.
At its basic level, it’s a framework for creating RIAs based on Flash Player.
Along with being a framework, Flex is also a new language. At its heart is
MXML, a markup language based on Extensible Markup Language (XML)
that makes it really easy and efficient to create applications. Unlike developing
for some desktop platforms requiring a proprietary binary file format,
MXML is just text, so it’s easy to read and modify using just a text editor.
Therefore, sharing code is as easy as sharing a simple text file.

Q 1. Types of Binding
Ans: Using the curly braces ({}) syntax
Using ActionScript expressions in curly braces
Using the tag in MXML
Using bindings in ActionScript(BindingUtils)

Q 2. How to create your own event
Ans: Creating a subclass from the Event class
Using the Event metadata tag
Dispatching an event

Q 3. Event Bubbling
Ans: The mechanism through which event objects are passed from the objects that generates an event up through the containership hierarchy

Q 4. Life cycle of Flex Application/Component?
Ans: Preinitialize: The application has been instantiated but has not yet created any child components.
Initialize: The application has created child components but has not yet laid out those components.
creationComplete: The application has been completely instantiated and has laid out all components

Q 5. How you implement MVC in your Application
Ans: Cairngorm is based on the MVC model. It is specifically designed to facilitate complex state and data synchronization between the client and the server, while keeping the programming of the View layer detached from the data implementation.
The role of the View layer in a Cairngorm application is to throw events and bind to data stored in the Model. Components on the View can bind to Value Objects or other properties in the Model (data) layer.
In a Cairngorm Model, related data are stored in Value Objects (VOs), while simple variables can be stored as direct properties of the ModelLocator class. A static reference to the ModelLocator singleton instance is used by the View layers to locate the required data.
The Controller is the most sophisticated part of the Cairngorm architecture. The Controller layer is implemented as a singleton FrontController. The FrontController instance, which receives every View-generated event, dispatches the events to the assigned Command class based on the event's declared type.
The Command class then processes the event by running the Command class' execute() method, which is an ICommand interface method. The event object may include additional data if required by the developer. The execute() method can update the central Model, as well as invoke a Service class which typically involves communication with a remote server. The IResponder interface, which is also implemented by the Command class, includes onResult and onFault methods to handle responses returned from the invoked remote service.

Q 6. Difference btw Java and Flex Getters Setters
Ans: When it comes to getters and setters, Java and AS are quite different, in that getters and setters are part of the core ECMAScript language, whereas in Java, getters and setters are done through a naming convention.
In Java, it is almost never a good idea to make member variables public. If you do decide to make member variables public and then later want to change the interface to use getter/setter functions, you will have to modify all callers of your interfaces, which is onerous at best and in many cases, not possible (expecially when you are creating code that is used by other people).
Meanwhile, in ECMAScript, the externally visible interface doesn’t change when I go from a member variable to a getter/setter and back again. In some sense, the interface hiding is already accomplished in the language. Creating public member variables is “safe” in this sense.
Perhaps this is already obvious to all the AS-heads out there, but it took me a bit of time to get used to the concept.

Q 7. How many events are fired when your focus goes in one text box, you enter some text and then press tab.
Ans: PreinitializeHandler(), initializeHandler(), itemEditBegin, itemEditEnd, creationComplete()

Q 8. How you use styles different ways of using Style sheet
Ans: Using external style sheets, Using local style definitions, Using the StyleManager class ,Using the setStyle() and getStyle() methods, Using inline stylesLoading style sheets at run time

Q 9. How can you use two Styles at the same time
Ans: Using external style sheets and use Inline style commands

Q 10. Try to remember properties of few imp components
Ans:
< id="WeatherService" wsdl="http:/example.com/ws/WeatherService?wsdl" useproxy="false">
< !-- Bind the value of the ZIP code entered in the TextInput control to the ZipCode parameter of the GetWeather operation. -->
< name="GetWeather">

<>{zip.text}
< /mx:request>
< /mx:operation>

Q 11. What is the difference between Flex 2.0 and Flex 3.0
Ans: Enhanced Features like Faster compilation time, SWF file size reduction, Flex/Ajax bridge, Advanced Datagrid, Interactive debugging, Cross-Domain, Versionable, Easy to Use,Security and Code Signing,Failover and Hosting,Cross-Domain RSL, Advanced DatagridDeep Linking, Resource Bundles and Runtime Localization, Flex Component Kit for Flash CS3, Compilation, Language IntelligenceRefactoring, Class Outline,Code Search, Profiler, Module Support, Multiple SDK Support, Skin Importer, Design View Zoom/Pan,Design Mode support for ItemRenderers, Advanced Constraints, CS3 Suite integration, CSS Outline, CSS Design View, Flex 3 SDK Skinning/Style Enhancements

Q 12. How will you call Java method from Flex?
Ans: Using RemoteObject. Explain the process to interviewer

Q 13. What are the config files used for connecting Java and Flex?
Ans:
data-management-config.xml,
messaging-config.xml,
proxy-config.xml,
remoting-config.xml,
services-config.xml

Q 14. What are the channels and their types
Ans: The Channel class is the base message channel class that all channels in the messaging system must extend.
Channels are specific protocol-based conduits for messages sent between MessageAgents and remote destinations. Preconfigured channels are obtained within the framework using the ServerConfig.getChannel() method. You can create a Channel directly using the new operator and add it to a ChannelSet directly
In Flex AMFChannel is used mostly. Action Message Format
Methods
applySettings (),connect(),connectFailed(),connectSuccess(), connectTimeoutHandler()
disconnect(),disconnectFailed(),disconnectSuccess(),flexClientWaitHandler(), getMessageResponder(),internalConnect(),internalDisconnect(),internalSend(),logout()
send(),setCredentials()
Properties
authenticated,channelSets,connected,connectTimeout,endpoint,failoverURIs,protocol,
reconnecting,recordMessageSizes,recordMessageTimes,requestTimeout,uri

Q 15. Give the name of Collection which can be mapped to java and Flex and vice-versa
Ans: java.lang.String String
java.lang.Boolean, boolean Boolean
java.lang.Integer, int int
java.lang.Short, short int
java.lang.Byte, byte[] int
java.lang.Byte[] flash.utils.ByteArray
java.lang.Double, double Number
java.lang.Long, long Number
java.lang.Float, float Number
java.lang.Character, char String
java.lang.Character[], char[] String
java. math.BigInteger String
java.math.BigDecimal String
java.util.Calendar Date
java.util.Date Date
java.util.Collection mx.collections.ArrayCollection(for example, java.util.ArrayList)java.lang.Object[] Arrayjava.util.Map Object (untyped). For example, a java.util.Map[] is converted to an array (of objects).
java.util.Dictionary Object (untyped)
org.w3c.dom.Document XML object
java.lang.Object (other than previously listed types) Typed Object
Objects are serialized by using JavaBean introspection rules and also include public fields. Fields that are static, transient, or nonpublic, as well as bean properties that are nonpublic or static, are excluded.

Q 17. How can you access a var defined in 1 MXML flex in to another MXML file
Ans: Create 1 object of MXML fiel into another MXML File

Q 18. Is it possible to make httpService Requests synchronous?
Ans: var mytoken:AsyncToken = yourservice.send();
mytoken.addResponder(new ItemResponder(function,errorFunction));
or
You can create a result handler to your HTTPService.
remoteObjectName.Your method
name.addEventListener("result",HandlerFunction,false,0,true);

Ans: 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.

Q 19. I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?
Ans: every SWF file you view runs locally on your machine. This means that a SWF would have HTTP access to all machines behind the company firewall. To prevent this, every server other than the one the SWF is loaded from, needs to have a crossdomain.xml file in its root, listing all domains that have access to that particular server.

Ans: 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 domain.

Ans:

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.


Q 20. What is the difference between httpService and Data Service?
Ans:
Basically, Flex allows three types of RPC services: HttpService, WebServices, and RemoteObject Services. In Flex, using the “RemoteObjects specifies named or unnamed sources and connects to an Action Message Format (AMF) gateway, whereas using the HTTPService and WebService use named services or raw URLs and connect to an HTTP proxy using text-based query parameters or XML”. Specifically, HTTPServices use raw HTTP requests, WebServices use the SOAP protocol and RemoteObjects uses AMF3.

Ans: 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.

Ans: 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.

Q 21. How do you generate random numbers within a given limit with actionscript?
Ans:

var randNum:Number = Math.random()*100;

Math.round(Math.random() * (high - low)) + low

public function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}

Ans: Math.round(Math.random() * (high - low)) + low


Q 22. Have you built any components with actionscript? If so explain how you did it?
Ans:
package myComponents{
import mx.controls.Button;
public class MyButton extends Button {
public function MyButton() {
super();
label="Submit";
}}}

Ans:

CountryComboBox.as

package components

{ import mx.controls.ComboBox;

public class CountryComboBox extends ComboBox

{ public function CountryComboBox()

{ dataProvider = [ "United States", "United Kingdom" ];

}

}

}

xmlns:mx="http://www.adobe.com/2006/mxml"

xmlns:custom="components.*"

width="220" height="115"

>


Q 23. How do you implement push on a flex applications?
Ans Using BlazeDS Server, LiveCycle Data Services,

Messaging systems let separate applications communicate asynchronously as peers by passing packets of data called messages back and forth through a Message Service. A message usually consists of a header and a body. The header contains an identifier and routing information. The body contains application data.

So, you will be building an application that allows you to asynchronously send data through the DS message service to our Flex client application. Here are some key DS messaging terms:

Producer: Producers are applications that create/send messages to the destination.
Consumer: Consumers are applications that receive messages from the destination.
Message Destination: Destinations are the resources used for both publish-subscribe and point-to-point messaging.
Message Channel: The channel is the method for connecting producers and consumers to the destination (using an endpoint).
Message Endpoint: An endpoint is the interface responsible for encoding and decoding data into messages.
Message Adaptor: The adaptor defines the messaging implementation. Options include using the ActionScriptAdapter provided with DS, or an external Java Message Service (JMS) provider.
Q 24. I am going to add images into a tag. How will it resize itself?

Ans: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

Ans : 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.


Q 25. What is a resource Manager?
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.


Q 26. What are the similarities between java and flex?

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).

Q:Is it possible to make httpService Requests synchronous?
Answer:: No, 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

Q 27. What is the dynamic keyword used for?

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

Q 28. How do you implement push with flex data services?

Using BlazeDS server and LCDS

Q 29. What are the methods called when a UI component is intialized?
Ans: 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).

Ans: createChildren()

Q 30. How do you implement drag and drop on components that do not support ondrag and ondrop?

DragManager.doDrag( componentname, new Datasource, mouseevent);
Accept drag on DestinationPlace.


Q 31. Can you write to the file system from flex?

Answer: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";
stream.writeUTFBytes(str);
stream.close();
mx.controls.Alert.show("File has been saved to \n" + file.nativePath, "Notice");


Q 32. What is a drag manager?
Ans: Manages the drag-and-drop operations; for example, its doDrag() method starts the drag operation.

Ans : 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.


Ans:
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 it.

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, the dragEnter event is sent to that component. If the component accepts the drag, it becomes the drop target and receives dragOver, dragExit, and dragDrop events.

When the drag is complete, a dragComplete event is sent to the drag initiator.

Q 33. How do you call javascript from Flex?
Ans:flash.external.ExternalInterface.call(function_name: String[, arg1, ...]):Object;

Ans : 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

Ans: IExternalInterface.call()

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


Ans:

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 the fscommand() 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. See http://www.mozilla.org/projects/plugins/npruntime.html.

Note: When embedding SWF files within an HTML page, make sure that the id and name attributes of the object and embed 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.


Q 34. How do you use a repeater?
Ans:
< id="rp" dataprovider="{dp}">
< height="49" width="50" click="Alert.show(String (event.currentTarget.getRepeaterItem()) + ' pressed')" label="{String (rp.currentItem)}">
< /mx:repeater>

The Repeater class is the runtime object that corresponds to the 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 tag anywhere a control or container tag is allowed, with the exception of the container tag. To repeat a user interface component, you place its tag in the tag. You can use more than one tag in an MXML document. You can also nest tags.

You cannot use the tag for objects that do not extend the UIComponent class.

MXML SyntaxexpandedHide MXML Syntax

The class has the following properties:

      Properties     id="No default"     childDescriptors="No default"   count="No default"     dataProvider="No default"     recycleChildren="false|true" startingIndex="0" 
     Events
    repeat="No default"     repeatEnd="No default"     repeatStart="No default" >

Ans:

[Bindable]

public var myArray:Array=[1,2,3,4];

]]>



Q 35. What are three ways to skin a component in flex?
Ans: Graphical skins: Images that define the appearance of the skin. These images can JPEG, GIF, or PNG files, or they can be symbols embedded in SWF files. Typically you use drawing software such as Adobe® PhotoShop® or Adobe® Illustrator® to create graphical skins.
Programmatic skins: ActionScript or MXML classes that define a skin. To change the appearance of controls that use programmatic skins, you edit an ActionScript or MXML file. You can use a single class to define multiple skins.
Stateful skins: A type of programmatic skin that uses view states, where each view state corresponds to a state of the component.The definition of the view state controls the look of the skin. Since you can have multiple view states in a component, you can use a single component to define multiple skins.

Ans:

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).


Q 36. How do you use css styles in flex?
Ans: Using external style sheets, Using local style definitions, Using the StyleManager class ,Using the setStyle() and getStyle() methods, Using inline stylesLoading style sheets at run time.

Ans:

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 tag, as follows:

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

.myclass { background-color: xFF0000 }

TextInput { font-family: Helvetica; font-size: 12pt }

Inline styles are defined in an MXML tag and can only be used in that tag. Inline styles are defined as follows:



Q 37. What is the difference between sealed class and dynamic classes?
Ans: Sealed Classes: ActionScript 3.0 introduces the concept of sealed classes. 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 enables stricter compile-time checking, resulting in more robust programs. It also improves memory usage by not requiring an internal hash table for each object instance. Dynamic classes are also possible using the dynamic keyword. All classes in ActionScript 3.0 are sealed by default, but can be declared to be dynamic with the dynamic keyword.
Dynamic classes A dynamic class defines an object that can be altered at run time by adding or changing properties and methods. A class that is not dynamic, such as the String class, is a sealed class. You cannot add properties or methods to a sealed class at run time.
dynamic class Protean
{ //Use dynamic keyword before the name of class
}

Q 38. What is e4X and XML?
Ans: E4X means "ECMAScript For XML
Using E4X, we can develop code with XML data faster than was possible with previous programming techniques. E4X provides a set of classes and functionality for working with XML data. ActionScript 3.0 includes the following E4X classes: XML, XMLList, QName, and Namespace.
Here is an example of manipulating data with E4X:
var myXML:XML =
<>
< id="'1'">
<>burger
<>3.95
< /item>
< id="'2'">
<>fries
<>1.45
< /item>
< /order>
trace (myXML.item[0].menuName); // Output: burger
trace (myXML.item.(@id==2).menuName); // Output: fries
trace (myXML.item.(menuName=="burger").price); // Output: 3.95

Q 39. What is state? What is the difference between states and ViewStack?
Ans : 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

Q 40. How does item renderer work? How do I add item renderer at runtime?

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.

Q 41. What keyword allows you to refer to private variables of a class?

Ans: this

Q 42. 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;
}
}

POLYMORPHISM

The final concept I cover in this article is polymorphism. The concept behind polymorphism is based on the idea of different classes implementing the same method names.

Even though this is a very simple concept, polymorphism has some interesting implications. The first major advantage is that it allows classes to be interchangeable at runtime. There are no hard-coded references to specific method names for specific classes.

For example, imagine you have a Teacher class and a Student class. You could implement a teach method for the teacher and a study method for the student, but polymorphism allows you to write the code so that the two classes both implement a work method. Although a Teacher and Student class will clearly have a different implementation of a work method (one teaches, the other studies), you can use a shared generic method name, creating a single interface through which they can be accessed:

Q 43. How do you overload functions in actionscript?
Method overloading using namespaces.


Q 44. What is dynamic keyword used for?

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.name=”Joe”;

p.age=25;

p.printMe = function () {

trace (p.name, p.age);

}

p.printMe(); // Joe 25

Q 45. What are sealed classes?
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.


Q 46. 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.


Q 47. What is cairngorm? How do you use it? Have you worked with Cairngorms?

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

Q 48. What keyword allows you to implement abstraction better?
Flex does not support abstract class directly. (?)


Q 49. What design patterns have you used? In Actionscript and java?

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


Q 50. What's the difference between Java and AS3 getters and setters?

Ans: I have to explicitly call a setter/getter function in Java, while AS3 allows me to Access my setters and getters as though they are variables.


Q 51. Explain the component lifecycle.
Q 52. Tell me about dataServices
Q 53. understanding of MVC


Q 54. They ask what frameworks you aree familiar with When getting developers to help create "standard" application, I'd weight a lot more heavily on the as3 questions. Aside from basic "show me how you'd write X" algorithm questions, you can ask more in depth ones about the workings of the language:

Q 55. Explain how binding works in mxml components.

Binding in MXML

Lets look at the following code…

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.



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

Answer:ChangeWatcher: 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"]
BindingUtils.bindProperty
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.

Ans: 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, "text");
            }


Q 56. Explain the ChangeWatcher.Wach()
Ans: You can detect when a binding occurs in your application. Flex includes the mx.binding.utils.ChangeWatcher class that you can use to define a watcher for a data binding. Typically, your event watcher invokes an event listener when the binding occurs

Q 57. Why would you want to keep a reference to a ChangeWatcher and call unwatch()?

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 updated.

unwatch () 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

Q 58. 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

Q 59. What does calling preventDefault() on an event do? How is this enforced?
Ans: Prevent defaults helps skipping the default behaviour or any componnent. Like in radio Button when you will click it will get selected, but if you want only the skin to be changed you can use preventDefault()

Ans: public function preventDefault():void

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.

            private function textArea_textInput(evt:TextEvent):void {
                if (evt.text == "\n") {
                    evt.preventDefault();
                }
            }
        ]]>
    
    
            height="120" textInput="textArea_textInput(event);">
        The quick brown fox jumped over the lazy dog.
    

Q 60. (If applicable) 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 aCommand. 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 the Model, 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.

Q 61. I was interviewed for a Flex position. The hiring manager kept on asking Java and J2EE questions. So, I asked him politely: you are hiring me for a flex position, why do you keep on asking Java questions?

Q 62. What are some ways to specify styles on components?

Q 63. What is the problem with calling setStyle()
Ans: When you are instantiating an object and setting the styles for the first time, 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.

Ans: 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.

Q 64. Explain the difference between creating an effect and setting the target as opposed to adding an effectListener

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.

paddingLeft="10" paddingRight="10" autoLayout="false" left="41" top="24" right="42">

mouseDownEffect="{shrink}" mouseUpEffect="{revert}"/>

Q 65. What do repeater components do?

You use the tag to declare a Repeater component that handles repetition of one or more user interface components based on dynamic or static data arrays at run time. The repeated components can be controls or containers. Using a Repeater component requires data binding to allow for run-time-specific values. For more information about data binding, see Storing Data.


Q 66. How do you identify a component created in a repeater?

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 its dataProvider, startingIndex, or count 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 the recycleChildren property is set to false), and then reinstantiates its children based on the current dataProvider property.


Q 67. What is state? What is the difference between states and ViewStack?

Ans: View Stack is to handle different MXML file eg TAB control.And states is the transition within single MXML file ViewStack should be used where there is complete change in the controls used and States should be used when you just want to add or remove afew 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.

Q 69. Why you don’t Embed all images in your application
Ans: That increases the size of the SWF File

Q 70. What type of images can be loaded
Ans: (PNG, GIF, JPEG, SWF at run time and PNG, GIF, JPEG, SWF, SVG at compile time)

Q 71. Explain ContainerCreationPolicy
Ans: This is used with the containers like Accordian, ViewStack etc. depending upon the ContainerCreationPolicy you have set accordingly the child pages will be loaded.
ALL Immediately create all descendants.
AUTO: Delay creating some or all descendants until they are needed.
NONE: Do not create any children.
QUEUED: Add the container to a creation queue.

Q 72. What are the factory classes
Ans: Factory class The factory class creates an object of the instance class to perform the effect on the target. You create a factory class instance in your application, and configure it with the necessary properties to control the effect, such as the zoom size or effect duration.

Q 73. Explain Metadata
Ans: You insert metadata tags into your MXML and ActionScript files to provide information to the Adobe Flex compiler. Metadata tags do not get compiled into executable code, but provide information to control how portions of your code get compiled.

Q 74. I was asked too many questions on the event bubbling, Like how to capture and event if the component is disabled.
Ans: addEventListner on the parents and enable the component in that handler

Q 75. obj.addEventListener(MouseEvent.CLICK, MouseClickHAndler); in this obj should inherit which class?
Ans: DispachEvent
You can manually dispatch events using a component instance's dispatchEvent() method. All components that extend UIComponent have this method
objectInstance.dispatchEvent(event:Event):Boolean

Q 76.Why we extent Sprite Class in our Graphical Classes?

Q 77.What is Layout Manager and explain the Properties and Methods?
AnsThe LayoutManager is the engine behind Flex's measurement and layout strategy. Layout is performed in three phases; commit, measurement, and layout.
The commit phase begins with a call to validateProperties(), which walks through a list (sorted by nesting level) of objects calling each object's validateProperties()method.

The objects in the list are processed by nesting order, with the most deeply nested object accessed first. This can also be referred to as bottom-up inside-out ordering.

The measurement phase begins with a call to validateSize(), which walks through a list (sorted by nesting level) of objects calling each object's validateSize() method to determine if the object has changed in size.

The layout phase begins with a call to the validateDisplayList() method, which walks through a list (reverse sorted by nesting level) of objects calling each object's validateDisplayList() method to request the object to size and position all components contained within it (i.e. its children).

Property of LayoutManager
usePhasedInstantiation : Boolean

A flag that indicates whether the LayoutManager allows screen updates between phases.

Q 78.How do you call a method in particular ItemRenderer. Also the ItemRenderer is your own Custom Component.
Ans
<>
< id="comboBox" dataprovider="{statesXMLList}" labelfield="@name" itemrenderer="ComboBoxItemRenderer">
< /mx:Application>
View ComboBoxItemRenderer.mxml
< ?xml version="1.0" encoding="utf-8"?>

< mx="http://www.adobe.com/2006/mxml" stylename="plain">
< text="{data.@name}" onclick="MyOwnMethodThatIWantToCall()">
< /mx:VBox>

Q 79.How can you implement Singleton in Flex Application?
Ans:If you are a Java Programmer dont be mistaken by saying create Private Constructor. We cant create private Constructor in Flex.

Q 80.Give similiarities btw Java and Flex
Ans: Both are object Oriented, Encapsulation, Inheritance, Abstraction and Polymorphism are implemeted in both of the technologies.
*The package like imports
*Availability of Classes in the scripting language
*Capabilities Arrays & ArrayCollections
*On the UI end, similarities to SWING

Q81.what is MVC and how do you relate it to flex apps?

Ans : (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.

Q82. Differences between defining bindings in MXML and ActionScript?

Ans: 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.

Q83.LifeCycle of Flex-application??

initialized

property

initialized:Boolean [read-write]

A flag that determines if an object has been through all three phases of layout: commitment, measurement, and layout (provided that any were required).

Ex:

xml version="1.0" encoding="utf-8"?>
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="349" height="319" viewSourceURL="../files/LifeCycleEventsTutorial.mxml" preinitialize="recordEvent(event)" initialize="recordEvent(event)" creationComplete="recordEvent(event)" applicationComplete="recordEvent(event)">

[CDATA[
import mx.events.FlexEvent;
import flash.utils.getTimer;
[Bindable]
private var reportTxt:String = "";
private function recordEvent(event:FlexEvent):void
{
reportTxt +
= (event.type + " event occured at " + flash.utils.getTimer() + "ms" + "\n");
}
]]>

x="0" y="0" width="349" height="319" layout="absolute" title="Life Cycle Events">
x="10" y="10" width="309" height="259" editable="false" id="txtReport" text="{reportTxt}"/>

Q84. 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.

Q85. 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.

Q86. When I set visible="false", the component still takes up space and appears in the tab order. Why is that?

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 to undefined when you make it visible again.

Q87. 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 arguments.

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.

Q88. 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.

Q89. How do I get access to the J2EE session from my RemoteObjects?

The AMF Gateway provides access to the current HttpServletRequest instance in a thread local variable. The session can be obtained from the request, as follows:

            flashgateway.Gateway.getHttpRequest().getSession();

Q90. Can I resize the Internet Explorer browser window from Flex?

Use getURL() to communicate with JavaScript in the HTML wrapper:

            getURL('javascript:window.resizeTo(1050,900)');

Q91. Can Flex applications communicate with each other on the client?

See the LocalConnection API in the documentation.

Q92. 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 ) <>

// do something here ...

}

someTimestamp = now;

}

Q93. 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 included.

Q94. 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 phase only, 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.

Q95. 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.

Q96. Why is myTreeNode.label or myTreeNode.attributes.label undefined?

Make sure you use the TreeDataProvider methods to modify a node. Don't rely on the node being XML. For example, the above should be myTreeNode.getProperty("label") instead.

Q97. When I add or modify an item in my dataProvider, why doesn't it show up in my DataGrid?

Ans: Low-level methods like Array.push() or myArray[0] = "whatever" do not cause the dataProvider's modelChanged 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 call myDataProvider.modelChanged yourself or reassign dataProvider to the control, as follows: myDataGrid.dataProvider = myDataProvider;

Q98. myTree appears just fine but why can't I access the node attributes?

Ans: 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 tree DataProvider API. These methods will work for any format dataProvider item, which might be an object, array, or XML node.

The following example might work: myTree.selectedNode.attributes.myAttribute

But the following example is far more reliable:

myTree.selectedNode.getProperty("myAttribute");
Q99. 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 properties.
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.
 

Q100. How do I run Flex as a service?

Ans: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.

Q101. 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 service.

Q102. I'm sending my request, and I see the data traffic in the command window, but why is the result always empty?

You are probably trying to read the result immediately after the send(), right? You're expecting synchronous behavior?

Q103. How do I make synchronous data calls?

You cannot make synchronous calls. You must 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 description.

Here it is in a nutshell. This example uses HTTPService but will be similar for RemoteObject and WebService:

1. Create a function to handle the data return, like onResult().

2. In the HTTPService tag, put this function name in the result property and pass "event" in too.

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 "WhateverIWanttoUseToIdentifyThisCall";
trace(sQueryId);

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

Q104. 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 to always use toArray(), as in the following examples:

In MXML:

{mx.utils.ArrayUtil.toArray(modelAccidents1.accidents.accident)}

The inline format:

dataProvider={mx.utils.ArrayUtil.toArray(testSrv.result.result.error)}

In ActionScript:

myControl.dataProvider = mx.utils.ArrayUtil.toArray(testSrv.result.result.error)

Q105. 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 using DataGridColumn tags.

Q106. Can I embed HTML in my Flex application?

Flex supports a limited subset of HTML in its TextArea 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://coenraets.com/viewarticle.jsp?articleId=95

Q107. Are there frameworks available for Flex?

Yes there are:

· Cairngorm: http://www.iterationtwo.com/open_source_cairngorm.html

· FlexUnit: http://www.iterationtwo.com/open_source_flexunit.html

· SynergyFLEX: http://www.mossyblog.com/archives/473.cfm (this link is for 1.0.0a)

· ARP: http://www.osflash.org/projects/arp/about

· AsUnit: http://www.asunit.org

Q108. 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 control.

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:

Flex Component Life Cycle :

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 using
new operatorActionScript . 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: Calls createChildren() method to create children of the component.
Step3: Dispatch Initialize event
Step4: Invalidation: 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: Validation: Invalidation of last step results to validation methods like commitProperties(), measure() and updateDisplayLiIst().(we see more about Validation after some lines)
Step6: Dispatch creationComplete event.

Q 109. Difference between PureMVC and cairngorm

PureMVC

Cairngorm

Pros

1) Complete separation of UI controls from the model and controller via the Mediator pattern. This makes it easier to re-use code for different UIs. It also promotes code reuse within the same UI, because you can use one Mediator for multiple visual components. For example, take a look at the code for my Index Cards application, and you'll see that the IndexCardMediator class serves both CardEditPanel.mxml and IndexCardViewer.mxml.

1) The use of Delegates provides a nice way to isolate service-related code.This makes it easy to stub out data when the UI development precedes the availability of services. It also provides a convenient place to switch between live and stand-alone versions of an application

2) Flexibility in the model. The fact that you work with Proxy classes rather than the Model class itself makes it easy for multiple developers to work on the same project without stepping on each other's toes.

2) Takes advantage of native Flex tools for loose coupling, including the event delegation model and data binding.

3) Flexibility in the controller. Having both MacroCommand and Command makes it easy to batch commands for complex workflows, and also makes it easy to reuse chunks of code for different workflows.

3) It was for some time the de facto framework for Flex applications, so lots of developers know it. Therefore, it is easier to find developers who can hit the ground running. This is obviously a business advantage rather than a technical one. There is also a 'gotcha' here, in that not all developers use Cairngorm the same way, so you need to be careful to brief new developers on your implementation of the framework, and make sure that they are comfortable with it.

sample applications all centrally managed and freely available from the puremvc.org website.

4) Backed by Adobe, and official training is available through training partners for a fee.

5) The Multicore version provides support for applications that need to load Modules.

6) Designed for portability, can be (and is) used with multiple languages.

Cons

1) Because of its focus on portability, PureMVC adds its own Notification model for communication between application components rather than leveraging the native Flex tools for this purpose.

1) Cairngorm does not provide a way to notify the view of relevant events in the controller (or updates to the model) apart from binding. Binding alone is not sufficient for all situations.

2) 2) If you go 'by the book' you will end up with far too many events, commands, and delegates. It is possible to consolidate these intelligently, but adherents of 'textbook' Cairngorm will consider this to be sub-optimal.

3) 3) There is no out-of-the-box support for applications that load Modules (or sub-applications).

4) The documentation is scattered, loosely managed, and of inconsistent quality.


1.
What’s AMF format in Flex? And what’s the Advantage over normal HTTP data transfer?

AMF -> Action Message Format (AMF) is a binary format used to serialize Action Script objects.

Advantage à 10 times faster than normal HTTP data transfers.

2. Which one of the following concepts in Flex by default?

Abstract keyword -> Yes/ NO

Method Override -> Yes/NO

Interfaces in Flex -> Yes/NO

Method Overload -> Yes/No

No

Yes

Yes

No

3. How to develop a Data Grid with Check boxes in one column?

By using itemRenderer

4. How to call java Script from Flex?

By using ExternalInterface

5. What are the server side components in Flex?

Flex is purely client side, we don’t have any server side components.

6. Where exactly weak references come into picture in Flex?

While Garbage Collection

7. What are the problems that you faced in BlazeDS?

Atleast they have to tell one problem.

8. What are the problems that you faced in Cairngorm?

Atleast they have to tell one problem.

9. When exactly we will use padding properties in Flex?

Whenever you want to give some spaces inside the components/controls.

10. How many SWC’s can present per application?

Any number of

11) Which property should be set on Images to fit into screen size accordingly (Minimize & Maximize?)

Answer: scale Content

12) How can you call a JavaScript function from Flex?

Answer: ExternalInterface.call (javafunction, agruments);

13) Can I overload constructor (or) functions in Flex?

Answer: No you can not.

14) What type of images can be loaded at run time and compile time?

Compile Time: PNG,GIF,JPEG,SWF,SVG,

Run Time: PNG,GIF,JPEG,SWF

15) Which meta tag can be used to force an Array should contain particular data type?

Answer:[ArrayElementType]

16) What is the base class for all the Flex classes?

Answer: Object

17) Can I use the access modifiers inside the interface?

Answer: You should not

18) If I want to stop event propagation depending on certain conditions. Which method should be called on the event?

Answer: event.preventDefault();or event.stopPropogation();

19) What events will be called during the UI component life cycle?

Answer: PreInitialize(),createChildern(),initialize(),commmitProperites(),measure(),layoutChrome(),updateDisplay(),creationComplete()

20) In Cairngorm, I would like to execute all my commands one after another? Which class I should extended ?

Answer: SequenceCommand

21) Can I pass a function as an argument?

Answer: Yes, Function can be passed as an arguments in Flex like ordinary variables

22) What are the phases in the Flex event Flow?

Answer : 1)Capture Phase 2) Targeting Phase 3) Bubbling Phase

23) Inside the event Handler function, what are the properties used to know from where the event triggered?

Answer: event.target,event.currentTarget.

24) Difference between Array & ArrayCollections in Flex?

Answer: ArrayCollection can be used with databinding where as Array is not.

25) What are three containers that uses the absolute layout by default ?

Answer : Application,Canvase,Panel

26) How can I filter data from ArrayCollection ??

Answer : Using filterFunction

27) How will you load modules in Flex ?

Answer : Using ModuleLoader or ModuleManager.

28) Which java data type you will match with Flex generic Object?

Answer :java.util.Map

29) After executing Remote Object Service or HTTPSrevices How will you retrieve the results from the serivce?

Answer : We have to define the result handler for the service and inside the result event the following properites will have the result, lastResult,result.

30) What is the default value for resultFormat property for HTTPService or WebService?

Answer: Object

31) How will you clone an object in Flex?

Answer: Using ObjectUtil.copy(source)

32) What is the other property you need to set if you want some component to make invisible/Visible?

Answer: IncludeInLayout.

33) What is CreationPolicy for Single View Container and Multiple View Container?

Ans: Creation Policy can “auto,all,none”

For Single View Container:

Auto (default)- instantiates and creates all its children before they are displayed.

All (default)- same like auto.

None: container will not instantiate and create its child components until they are manually created

For Multiple View Container:

Auto (default)- instantiates and created its initially viewed and displayed children. This is faster for start up of application but slower for navigation since other views children are displayed when navigated to its view

All:- instantiates and creates all children in all navigation views of this container. Slower for application startup but faster for navigation during runtime.

None: No children are instantiated and created until they are created manually using a method CreateComponentsFromDescriptors()

34) What is SWFLoader and Module Loader?

Ans: ¨

SWFLoader: 
            source="FlexApp.swf"
            creationComplete="initNestedAppProps();"/>
loadedSM = SystemManager(myLoader.content);
loadedSM.application["lblOne"].text = "I was just updated."; loadedSM.application["varOne"] = "I was just updated.";
 

The ModuleLoader class triggers several events, including setup, ready, loading, unload, progress, error, and urlChanged. You can use these events to track the progress of the loading process, and find out when a module has been unloaded or when the ModuleLoader target URL has changed.

35) How do you include one Flex application into another Flex application?

Ans: Using SWF Loader.

36) BlazeDS is called Open Adapter Architecture. Why?

Ans: Open Adapter architecture is to integrate JMS,EJB, ColdFusion components and other data sources.

37) How do you call a Flex function from JavaScript?

Ans: addCallback(function_name:String, closure:Function):void
 

The function_name parameter is the name by which you call the Flex function from your HTML page's scripts. The closure parameter is the local name of the function that you want to call. This parameter can be a method on the application or an object instance.

ExternalInterface.addCallback()