Top 50 Adobe Flex Actionscript Interview Questions You Must Prepare 14.Nov.2024

Q1. What Is The Model-view-controller (mvc) Pattern?

The Model-View-Controller (MVC) is a compound pattern, or multiple patterns working together to create complexapplications.

  • Model Contains the application data and logic to manage the state of the application
  • View Presents the user interface and the state of the application onscreen
  • Controller Handles user input to change the state of the application

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

Q3. Explain What Happens If An .swf Is Loaded Into A Already Occupied Level?

  • An error is thrown.
  • The new swf is rejected and the old one stays.
  • The old swf is unloaded and the new swf is loaded.
  • They share the same level

Q4. What Is Different Between Urlloader Class And Loader Class?

The URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. A URLLoader object downloads all of the data from a URL before making it available to ActionScript. It sends out notifications about the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, as well as through dispatched events.

The Loader class is used to load SWF files or image (JPG, PNG, or GIF) files. Use the load() method to initiate loading. The loaded display object is added as a child of the Loader object.

Q5. What Is The Difference In Movieclip And Sprite?

Sprite does not have timeline in it But Movie Clips can have. Sprite is the parent class of MovieClip though not all of the MovieClip properties are available in the parent class.

Q6. What Is Display Object?

Display object is an object which represents some type of visual content in Flash Player. Only display objects can be included in the display list, and all display object classes are subclasses of the DisplayObject class. After a display object is created, it won't appear on-screen until it is added into a display object container.

Q7. What Is A Drag Manager In Adobe Flex Actionscript?

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.

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

<mx:Application ...>
<mx:Zoom id="shrink" duration="100" zoomHeightTo=".9" zoomWidthTo=".9" />
<mx:Zoom id="revert" duration="50" zoomHeightTo="1" zoomWidthTo="1" />
<mx:Panel title="Bouncy Button" paddingTop="10" paddingBottom="10"
paddingLeft="10" paddingRight="10" autoLayout="false" left="41" top="24" right="42">
<mx:Button id="bouncyButton" label="Click me!" 
mouseDownEffect="{shrink}" mouseUpEffect="{revert}"/>
</mx:Panel>
</mx:Application>

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

Q10. What Are Sealed Classes In Flex?

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.

Q11. What Keyword Allows You To Refer To Private Variables Of A Class In Flex?

Private keyword , this keyword (? ) in flex

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

Q13. Explain How Many Levels Does Flash Mx Support?

  • 20
  • 80
  • 100
  • 1000

Q14. What Is Display Container?

Display object container is special type of display object which can contain child display objects in addition to (generally) having its own visual representation. When a display object container is removed from the display list, all its children are removed as well.

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

Q16. Can I Embed Html In My Flex Application?

Flex supports a limited subset of HTML in its TextArea and some other text-related classes.

Q17. What Is Cairnghorm In Flex? How Do We Use It?have You Worked With Cairnghorn In Flex?

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.

Q18. How Do I Run Flex As A Service?

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

Q19. Is Double-clicking Supported On Various Components?

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

var someTimestamp:Number;
public function doubleClickHandler( evt:Object ):Void {
var now = getTimer();
// we got a double-click
if( ( now - someTimestamp ) < 500 ) {
// do something here ...
}
someTimestamp = now;
}

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

Q21. What Are Runtime Shared Libraries In Flex?

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

Q22. 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;
}
}

Q23. What Is The Difference Between Sealed Class And Dynamic Classes In Flex?

Classes are sealed by default, i.e. properties cannot be added dynamically at runtime.

  • Dynamic classes can add additional dynamic properties at runtime; sealed classes cannot.
  • Sealed classes conserve memory because no internal hash table is needed to store dynamic properties, and the compiler can provide better error feedback.

Q24. How Do We Identify A Component Created In A Repeater Using Flex?

If currentIndex value is greater than startIndex value me 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.

Q25. What Does Calling Preventdefault() On An Event Do? How Is This Enforced?

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.

Q26. What Are The Correct Statements Concerning Text Field?

  • Embedded font outlines are shared by text fields using the same font.
  • Font Outlines for static for static text field are embedded in the SWF file by default.
  • Font outline for input text field are embedded in SWF file by default.
  • Individual font outlines are embedded in to the SWF file for each text field in the FLA file.
  • Font outlines for dynamic text fields are embedded in SWF file by default.

Q27. What Is Polymorphism In Term Of Oop (flash Actionscript)?

Inheritance also allows you to take advantage of polymorphism in your code. Polymorphism is the ability to use a single method name for a method that behaves differently when applied to different data types.

Q28. What Design Patterns Have You Used? In Actionscript And Java?

  • Creational Pattern
    • Factory Method Pattern.
    • Singleton Pattern.
  • Structural Patterns
    • Decorator Pattern.
    • Adapter Pattern.
    • Coposite Pattern.
  • Behavioral Patterns
    • Command Pattern.
    • Observer Pattern.
    • Template Metod Pattern.
    • State Pattern.
    • Strategy Pattern.
  • Multiple Patterns
    • MVC Pattern.
    • Symetric Proxy Pattern.

Q29. How Can You Show A Jpg Image In Dynamic Text Field?

Using HTML Tags in HTML enabled text field you can load image in that. Make a Dynamic Text Field on Stage and give it instance name "txt", On frame paste the following code and test your flash.

Code: txt.htmlText ="<img src='http://www.globalguideline.com/images/ggl.gif' width='139' height='139'> This image is under Dynamic text field of flash "

Q30. Can I Dynamically Instantiate A Web Service 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.

Q31. What Is Interface Or Benefit Of Interface In Term Of Oop?

  • Allows you to specify a set of methods that classes are required to implement
  • Classes can implement multiple interfaces,interfaces can extend each-other
  • Interfaces can be seen as contracts to be developed against, great for frameworks

Q32. How Does Item Renderer Work? How Do We Add Item Renderer At Runtime In Flex?

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.

Q33. Explain How Binding Works In Mxml Components In Flex?

Binding in MXML:

Lets look at the following code…
<mx:TextInput id=”ti1?/>
<mx:Label id=”label1? text=”{ti1.text}”/>

Here you are binding the text property of the TextInput to the label. So whatever you type in the textInput automatically reflects in the label. That’s the power of Binding…

The best practice for defining components that return information back to the main application is to design the component to dispatch an event that contains the return data. In that way, the main application can define an event listener to handle the event and take the appropriate action. You also use events in data binding. 

The following example uses the Bindable metadata tag to make useShortNames a bindable property.The implicit setter for the useShortNames property dispatches the change event that is used internally by the Flex framework to make data binding work.

Q34. Difference Between States And Viewstack In Flex?

  • View Stack is to handle different MXML file eg TAB control and states is the trition 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

Q35. I Have I Input Text Field On Stage And I Have A Button Also, Further I Am Writing Some Text In That Input Text Field. I Want To Save My Written Data On My Local System (on My Computer), How Can I Do T

To achieve this you have to use flash CS4 with Flash Player 10 or above. Using the new method of filereference class you can save you typed text on your computer as a text file.

First create a object of filereference… then use the save method and pass your data to it.
var fR:FileReference =new FileReference()
fR.save("your Written text should be come here.","flexflashforum.txt")
Paste the following code on frame and run a sample application...

Code: 

var TxtF:TextField = new TextField();
var BtnMc:TextField = new TextField();
var MyFile:FileReference = new FileReference();
TxtF.border = true;
TxtF.type = TextFieldType.INPUT;
BtnMc.background = true;
BtnMc.backgroundColor = 0xCCCCCC;
BtnMc.x = 150;
BtnMc.height = 20;
BtnMc.text = " Click here to save";

Q36. How Do I Pass Parameters To A Pop-up Window In Actionscript?

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.

Q37. When I Have Only A Single Record, Why Does Not 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)

Q38. Tell Some New Capabilities / Features Of Flash As 3.0?

URLLoader class to load text or binary data (The ActionScript 2.0 MovieClipLoader and LoadVars classes are not used in ActionScript 3.@The Loader and URLLoader classes replace them.)

Sound.computeSpectrum() (Takes a snapshot of the current sound wave and places it into the specified ByteArray object. It returns a ByteArray containing 512 normalized values (-1 to 1) that can be used to visually display the waveform of sound. 256 values for the left channel and 256 values for the right channel. These values can be use to create Sound Spectrum Analyzer displays in Audio Players like Winamp and Windows Media Playres.)

BitmapData.getPixels() (Generates a byte array from a rectangular region of pixel data. Writes an unsigned integer (a 32-bit unmultiplied pixel value) for each pixel into the byte array. No need to loop through every pixel in a bitmap, one at a time with getPixel to send a bitmap to the server.)

MovieClip.currentLabel (This returns the label of the current frame as a String. The current label in which the playhead is located in the timeline of the MovieClip instance. If the current frame has no label, currentLabel is set to the name of the previous frame that includes a label. If the current frame and previous frames do not include a label, currentLabel returns null.)

stage.frameRate ( At runtime frame rate of stage can be change)

Q39. 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();

Q40. What Is State? What Is The Difference Between States And Viewstack In Flex?

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.

Q41. What Is Dynamic Keyword Used For In Actionscript?

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

Q42. Sometimes, If I Do Not Move The Mouse, "click" And "mousedown" Do Not 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.

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

Q44. What Is A Resource Manager In Flex Actionscript?

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.

Q45. What Is Mvc And How Do You Relate It To Flex Apps?

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

Q46. 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)');

Q47. Differences Between Defining Bindings In Mxml And Actionscript?

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.

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

Q49. What Is Interface In Term Of Oop (flash Actionscript)?

An interface is a collection of method declarations that allows unrelated objects to communicate with one another. The structure of an interface definition is similar to that of a class definition, except that an interface can contain only methods with no method bodies. Interfaces cannot include variables or constants but can include getters and setters. To define an interface, use the interface keyword. Use the implements keyword in a class declaration to implement one or more interfaces.

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