Adobe Flex Actionscript

  Home  Adobe  Adobe Flex Actionscript


“Adobe Flex and Actionscript Interview Questions Answers Tutorial and Guide to build your knowledge for better career. Adobe Flex is a highly productive application also called actionscript, its free and open source framework for building and maintaining expressive web applications that deploy consistently on all the web browsers, desktops, and operating systems. Adobe Flex actionscript Interview Questions and Answers will guide you about all the aspects of Adobe Flex Actionscript.”



84 Adobe Flex Actionscript Questions And Answers

21⟩ How do I make synchronous data calls in actionscript?

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

 261 views

22⟩ 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)

 242 views

25⟩ 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.rendc.org/images/ggl.gif' width='139' height='139'> This image is under Dynamic text field of flash "

 226 views

26⟩ 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 this?

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";

 242 views

28⟩ 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.0. 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)

 220 views

29⟩ 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.

 236 views

30⟩ 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.

 240 views

31⟩ 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.

 249 views

34⟩ 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;

}

 240 views

39⟩ 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.

 244 views