Wednesday, December 31, 2008

Flex Interview Questions & Answers

1. Is it possible to make httpService Requests synchronous?
Yes, By using Custom Class and Remote Objects..
http://blog.lab49.com/archives/category/flex
2. I need to load an image from flickr into my application. Do I need a crossdomain.xml file on flickr?

Of course it's Adobe's problem. The player work "as designed", but it's a poor design.

The idea behind crossdomain.xml files is to prove that the site hosting the SWF file also controls the domain the data is being loaded from. Unless you think that you should need to own Flickr to be able to host a SWF that can access Flickr images, I can't see how you could possibly think this is a good 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.
3. What is the difference between httpService and Data Service?
The Flex presentation layer communicates with the business layer by using Flex
data services, which are objects you insert in a Flex file. Specifically, you can
use Flex data services to interact with the following:

* Web services
* HTTP services
* Remote objects

A Flex data service is an object you insert in an MXML file to communicate with
the business layer of a multi-tier application. You use data services to send and
receive data from web services, HTTP URLs, and remote objects such as
server-based Java objects.

An HTTP service is nothing more than an HTTP request to a URL. The primary
purpose of HTTP services is to retrieve XML data from an external source.

4.How do you generate random numbers within a given limit with actionscript?
public function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}
5.Have you built any components with actionscript? If so explain how you did it?
Yes, By extending any UI Compopnents
6.How do you implement push on a flex applications?
Pushing datas into array
7. I am going to add images into a tag. How will it resize itself?
Scalecontent = true
For the tag in which you are going to add images you don't have to specify any width or height property. This will help the container to resize itself.

8.What is a resource Manager?
With Flex 3, localization support will become much more Flexible! Here’s how:
• You can put your resources into resource modules -- similar to style modules -- rather than into the application itself. You can preload the module for an appropriate locale when the application starts, and you can load modules for additional locales later.
• You can compile resources for multiple locales into a single application or module.
• You access all resources through a new ResourceManager, which can manage resources for multiple locales. You can change at runtime which locales get searched for resources.
• Binding expressions that reference resources via the new ResourceManager will automatically update if the locale changes. Components are notified when the locale changes so that they can update themselves appropriately.
• You can also use images, sounds, etc. as resources rather than just strings.
• You can programatically create your own resources at runtime and use them just like ones that were compiled from .properties files. So you can create resources at runtime from downloaded XML files, database results, etc.
http://sujitreddyg.wordpress.com/2008/01/22/localizing-flex-applications/
9.What are the similarities between java and flex
• Java is a virtual machine that can be used to create platform-independent software. Software created in Java can run on any hardware that supports the Java Virtual Machine.
• In web development, Java can be used as either a client-side or server-side programming language.
• When Java is used on the client side, we're generally talking about Applets, which can run on a browser with Java support.
• When Java is used on the server side, we're probably thinking JSP or [???] to create framework-based web applications or to create web services.
How does it compare to Flex?
• Java Applets, with their ability to run inside a browser window, are similar to Flex applications. Flex apps, however, are much easier to deploy through the lightweight easy-to-install Flash Player.
• Server-side Java can be used to create web services for consumption by a Flex application
10. What is the dynamic keyword used for?
dynamic

11.What are the methods called when a UI component is intialized?
createChildren(),commitProperties(),measure(),layoutChrome(),updateDisplayList()
http://flexcomps.wordpress.com/2008/05/09/flex-component-life-cycle/
12. 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.
13. Can you write to the file system from flex?
No
14. What is a drag manager?
The DragManager class manages drag and drop operations, which let you move data from one place to another in a Flex application. For example, you can select an object, such as an item in a List control or a Flex control, such as an Image control, and then drag it over another component to add it to that component.
All methods and properties of the DragManager are static, so you do not need to create an instance of 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.

15. How do you call javascript from Flex?
The ExternalInterface class is the External API, an application programming interface that enables straightforward communication between ActionScript and the Flash Player container– for example, an HTML page with JavaScript. Adobe recommends using ExternalInterface for all JavaScript-ActionScript communication.
You can call an ActionScript function in Flash Player, using JavaScript in the HTML page. The ActionScript function can return a value, and JavaScript receives it immediately as the return value of the call.
This functionality replaces 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.

16. How do you use a 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 Syntax Hide MXML Syntax
The class has the following properties:


17. What are three ways to skin a component in flex?
Tag,class,typed
18. How do you use css styles in flex?

19. What is the difference between sealed class and dynamic classes?
Sealed Classes cannot add properties and methods dynamically.
Dynamically cannot add proprties or methods.
20. What is MVC and how do you relate it to flex apps?
MVC is an Model View Controller Architecture used to differentiate the Model(business Classes), View (Mxml components) and Contoller(command classes).
21. What is state? what is the difference between states and ViewStack?
View Stack is to handle different MXML file eg TAB control..
And states is the transition within single MXML file
ViewStack should be used were there is complete change in the controls used and States should be used when you just want to add or remove a few components based on certain conditions.
Login/Registration/Forgot password is the best example for using States as each page will either add or remove to the already existing one.
22. How does item renderer work? How do I add item renderer at runtime?
Item renderer works with Listbased Contols such as list,combo,datagrid,menu,menubar,tree etc.. It Populate the list based on the dataprovider to the particular component.
xxx.itemrenderer = new classfactory(rendrerer component name);
23. What are the various ways of creating and using item renderers?
• Using the default item renderer
• Using a drop-in item renderer
• Creating an inline item renderer
• Creating a reusable inline item renderer
• Using a component as an item renderer
http://www.adobe.com/devnet/flex/quickstart/using_item_renderers/

24. What keyword allows you to refer to private variables of a class?
this
25. How polymorphism works on actionscript?
http://www.adobe.com/devnet/actionscript/articles/oop_as3_05.html
26. Whats the difference between itemRenderer & itemEditor?
ItemRenderer can be used to edit the cells and make modifications..,
Itenrenderer only readonly no modification possible.
27. How do you overload functions in actionscript?
Ex:An constructor can contain ‘n’ number of arguments
28. What is dynamic keyword used for?
We can add properties to the class which has the keyword dynamic.
29. What are sealed classes ?
We cant add properties to the class which are sealed.
30. What are runtime shared libraries?
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.
http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs
31. What is caringorm ? how do you use it?Have you worked with Cairnghorm?
Cairngorm is the lightweight micro-architecture for Rich Internet Applications built in Flex or AIR.Add the Cairgorm.swc file to ur librarypath.
http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm;jsessionid=B01E4B7E105462969ED5A7FA1FFD4543
32. What design patterns have you used? in Actionscript and java?
PureMVC,Cairngorm

33. What's the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?
The ChangeWatcher class defines utility methods that you can use with bindable Flex properties. These methods let you define an event handler that is executed whenever a bindable property is updated.
public function initWatcher():void {
// Define a watcher for the text binding.
ChangeWatcher.watch(textarea, "text", watcherListener);
}
// Event listener when binding occurs.
public function watcherListener(event:Event):void {
myTA1.text="binding occurred";
}

The BindingUtils class defines utility methods for performing data binding from ActionScript. You can use the methods defined in this class to configure data bindings.

private function init():void {
BindingUtils.bindProperty(textInputDst, "text", textInputSrc, "text");
}
34. How do you add event listeners in mxml components. Now AS3 components?
Inside the tag you can add event listeners by specifying the components id/name or using this keyword.
35. What does calling preventDefault() on an event do? How is this enforced?
preventDefault () method
public function preventDefault():void
Cancels an event's default behavior if that behavior can be canceled.
Many events have associated behaviors that are carried out by default. For example, if a user types a character into a text field, the default behavior is that the character is displayed in the text field. Because the TextEvent.TEXT_INPUT event's default behavior can be canceled, you can use the preventDefault() method to prevent the character from appearing.
An example of a behavior that is not cancelable is the default behavior associated with the Event.REMOVED event, which is generated whenever Flash Player is about to remove a display object from the display list. The default behavior (removing the element) cannot be canceled, so the preventDefault() method has no effect on this default behavior.
You can use 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 quick brown fox jumped over the lazy dog.



36. How do you identify a component created in a repeater?
No way. But you can get the data of the selected repeated component, or the number of child its holds. By accessing its parent container.
37. 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:










38. What is meant by data binding?
Data binding is the process of tying the data in one object to another object. It provides a convenient way to pass data around in an application.
39. What are the different ways to specify data binding in flex?
• Using the curly braces ({}) syntax
• Using ActionScript expressions in curly braces
• Using the tag in MXML
• Using bindings in ActionScript
http://www.adobe.com/devnet/flex/quickstart/using_data_binding/
40. Write code to create a button with the title "Press". Add code to intercept the button click event. When clicked, the title of the button should change to "Button Pressed". Either use MXML or ActionScript.





41. What is the FaultEvent class ?
Fault event class indicates an error has occurred.. You can use the Fault Event with HTTP Service , Remote Object. When there is connection failure or some error the Fault Event handles and displays it..
42. What is the difference between Array and ArrayCollection classes?
ArrayCollections can hold different instances of varying data types. You can add and remove items from ArrayCollections, causing repositioning along the array. ArrayCollections can hold far more data than regular Arrays
43. What is Flex?
Its is an Framework or tool Used for developing RIA.
44. What kind of applications you can create from Flex?
Web Application
45. What is the output of Flex applications?
Swf  shock wave file/object.
46. What development environment you need to create Flex applications?
Adobe Flex Builder / flashplayer 9
47. Can you manipulate images using Flex programs?
yes
48. Does Flex support creating workflow based applications?
yes
49. What kind of data grids you can create through Flex applications?
Datagrid,Advanced Datagrid,OLAP Datagrid
50. How do you connect to a database via a Flex program?
Using any server side Languages such as ASP,DotNet,JSP,PHP etc..

51. Can you develop web based applications in Flex?
Yes
52. Is Flex OS specific or operating system independent?
No its OS Independent.
53. Can we run Flex applications in MAC?
Yes
54. Do we need any plugins to run Flex applications?
Flash Player 9 should be installed in the browser.
55. What's the difference between Java and AS3 getters and setters?
In Java, getter and setter methods have to be explicitly called.While in AS3, they're called automatically and externally indistinguishable from public properties.
For instance trace(myClass.foo) might be referencing a public property or it might be referencing the method "public get foo():Object". It makes no difference to an external class.
56. Data Grid adding and changing columns with item renderers at runtime.
Right click to view the source.
http://www.dgrigg.com/post.cfm/08/01/2007/Datagrid-runtime-item-renderers
Step 1.
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.
Here is my basic image item renderer. Nothing to exciting, but it is very reusable. I can drop this into any datagrid to render an image column and it will work.






Step 2.
Modify the renderer so that it can be added at runtime. To do this the renderer needs to implement the IFactory interface. This will allow the renderer to be added at any point during runtime. Without implementing this interface it won't work, period. Below is the code to implement the interface.

public function newInstance():*
{
return new ImageRenderer();
}

Step 3.
The code to change a column at runtime from a basic column to an item renderer column. Get the columns from the datagrid, modify the column you are interested in and then reassign the columns to the datagrid. Notice that when you set the column's itemRenderer value you must create a new instance of the desired item renderer.
private function switchStatusColumn(event:MouseEvent):void {
var cols:Array = users_dg.columns;
var col:DataGridColumn = cols[1] as DataGridColumn;
col.itemRenderer = new CheckBoxRenderer();
users_dg.columns = cols;
}
Step 4.
The code to add a new column with an item renderer at runtime. This is almost identical to modifying an existing column. The only difference is that we push the new column into the columns array.
private function addImageColumn(event:MouseEvent):void {
var cols:Array = users_dg.columns;
var col:DataGridColumn = new DataGridColumn();
col.itemRenderer = new ImageRenderer();
col.dataField = 'emoticon';
col.headerText = 'Image';
cols.push(col);
users_dg.columns = cols;
}
57. whats the difference between mx.rpc.http.HTTPService and
mx.rpc.http.mxml.HTTPService ?
whats the difference and when each has to be used..


mx.rpc.http.mxml.HTTPService inherits from mx.rpc.http.HTTPService. So
basically mx.rpc.http.mxml.HTTPService has everything that mx.rpc.http.HTTPService has. But apart from that, it can also handle concurrency. This means if concurrency is set to multiple, you can send multiple asychronous requests using the same object. But the flipside of this is that while handling the results, you have to be careful about which request is the data pertaining to...
58. How BindingUtils.bindProperty works?
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");

Some More Questions
How to delete an element/node from the xml?
Explain the lifecycle of a Cairngorm action.
What is the problem with calling setStyle()?
Explain the difference between creating an effect and setting the target as opposed to adding an effectListener
Explain how binding works in mxml components.
Why would you want to keep a reference to a ChangeWatcher and call unwatch()?
What kind of source code integration tools are available with Flex?
What third party development tools are available to program in Flex?
How do you implement push with flex data services?
What keyword allows you to implement abstraction better?

No comments: