How do we call JavaScript from Flex?

The ExternalInterface API makes it very simple to call methods in the enclosing wrapper. We use the static call() method, which has the following signature:
flash.external.ExternalInterface.call(function_name:
String[, arg1, ...]):Object;
The function_name is the name of the function in the HTML page’s JavaScript. The arguments are the arguments that we pass to the JavaScript function. We can pass one or more arguments in the traditional way of separating them with commas, or we can pass an object that is deserialized by the browser. The arguments are optional.
The following example script block calls the JavaScript f() function in the enclosing wrapper by using the call() method:




import flash.external.*;

public function callWrapper():void {
var f:String = "changeDocumentTitle";
var m:String = ExternalInterface.call(f,"New Title");
trace(m);
}



On our HTML page, we define a function as we would any other JavaScript function. We can return a value, as the following example shows:

This feature requires that the embedded movie file have an id attribute. Without it, no call from our Flex application will succeed.
The call() method accepts zero or more arguments, which can be ActionScript types. Flex serializes the ActionScript types as JavaScript numbers and strings. If we pass an objct, we can access the properties of that deserialized object in the JavaScript, as the following example shows:

public function callWrapper():void {
var o:Object = new Object();
o.lname = "Danger";
o.fname = "Nick";
var f:String = "sendComplexDataTypes";
ExternalInterface.call(f,o);
}

Flex only serializes public, nonstatic variables and read-write properties of ActionScript objects. We can pass numbers and strings as properties on objects, simple objects such as primitive types and arrays, or arrays of simple objects.
The JavaScript code can then access properties of the object, as the following example shows:

We can also embed objects within objects, as the following example shows. Add the following code in our Flex application’s block:

public function callWrapper():void {
var f:String = "sendComplexDataTypes";
var o:Object = new Object();
o.lname = "Danger";
o.fname = "Nick";
o.b = new Array("DdW","E&T","LotR:TS");
var m:String = ExternalInterface.call(f,o);
}

The code triggers the following JavaScript in the wrapper:

Flex and Flash Player have strict security in place to prevent cross-site scripting. By default, we cannot call script on an HTML page if the HTML page is not in the same domain as the Flex application. However, we can expand the sources from which scripts can be called.
We cannot pass objects or arrays that contain circular references. For example, we cannot pass the following object:
var obj = new Object();
obj.prop = obj; // Circular reference.
Circular references cause infinite loops in both ActionScript and JavaScript.

Explain how binding works

Data binding is the process of copying the data from one object to another object. It provides a convenient way to pass data around in an application. Adobe Flex 2 provides three ways to specify data binding: the curly braces ({}) syntax and the tag in MXML and the BindingUtils methods in ActionScript.
Data binding requires a source property, a destination property, and a triggering event that indicates when to copy the data from the source to the destination. To use a property as the source of a data binding expression, the component must be implemented to support data binding, which means that the component dispatches an event when the value of the property changes to trigger the binding.
At compile time, the MXML compiler generates code to create ActionScript Watcher and Binding objects that correspond to the binding tags and expressions found in an MXML document. At run time, Watcher objects are triggered by change events that come from the constituent parts of binding source expressions; the Watcher objects then trigger Binding objects to execute bindings.
When we specify a property as the source of a data binding, Flex monitors not only that property for changes, but also the chain of properties leading up to it. The entire chain of properties, including the destination property, is called a “bindable property chain“. In the following example, firstName.text is a bindable property chain that includes both a firstName object and its text property:
{firstName.text}
It’s not necessary that the binding executes automatically. In the following case the binding wont execute automatically as expected.
1. Binding does not execute automatically when we change an entire item of a dataProvider property.
2. Binding also does not execute automatically for subproperties of properties that have [Bindable] metadata.
3. Binding also does not execute automatically when we are binding data to a property that Flash Player updates automatically, such as the mouseX property.
The executeBindings() method of the UIComponent class executes all the bindings for which a UIComponent object is the destination. All containers and controls, as well as the Repeater component, extend the UIComponent class. The executeChildBindings() method of the Container and Repeater classes executes all of the bindings for which the child UIComponent components of a Container or Repeater class are destinations. All containers extend the Container class. However, we should only use the executeBindings() method when we are sure that bindings do not execute automatically.

Is it possible to make httpService Requests synchronous?

RPC communications, including RemoteObject, are asynchronous. In other words, we don’t exactly call a remote method, but rather send a message to the server, requesting a call of the specific Java method. Not only is the client’s request(s) executed asynchronously, but even sending to the server is done asynchronously. And if we need to do multiple RemoteObject invocations in our script, Flex will batch them together and send in the end of the script execution. The results of remote invocations are returned via events. RemoteObject provides the result event for success or fault for failures. We should write the corresponding handler functions. Flex will call these methods, supplying an Event object as a parameter. It’s our responsibility to get the information from the event and act accordingly. Friendly advice: we will save ourself hours of time if we supply a fault handler.

What is dynamic keyword used for? or What is the difference between sealed class and dynamic classes?

Dynamic Keyword is used to make a class dynamic. A dynamic class defines an object that can be altered at run time by adding or changing properties and methods. We create dynamic classes by using the dynamic attribute when we declare a class. For example, the following code creates a dynamic class named Protean:
dynamic class Protean {
private var privateGreeting:String = "hi";
public var publicGreeting:String = "hello";
function Protean () {
trace("Protean instance created");
}
}
If we subsequently instantiate an instance of the Protean class, we can add properties or methods to it outside the class definition. For example, the following code creates an instance of the Protean class and adds a property named aString and a property named aNumber to the instance:
var myProtean:Protean = new Protean();
myProtean.aString = "testing";
myProtean.aNumber = 3;
trace (myProtean.aString, myProtean.aNumber); // output: testing 3
Properties that we add to an instance of a dynamic class are run-time entities, so any type checking is done at run time. We cannot add a type annotation to a property that we add in this manner.
We can also add a method to the myProtean instance by defining a function and attaching the function to a property of the myProtean instance. The following code moves the trace statement into a method named traceProtean():
var myProtean:Protean = new Protean();
myProtean.aString = "testing";
myProtean.aNumber = 3;
myProtean.traceProtean = function () {
trace (this.aString, this.aNumber);
}
myProtean.traceProtean(); // output: testing 3
Methods created in this way, however, do not have access to any private properties or methods of the Protean class. Moreover, even references to public properties or methods of the Protean class must be qualified with either the this keyword or the class name. The following example shows the traceProtean() method attempting to access the private and public variables of the Protean class.
myProtean.traceProtean = function () {
trace(myProtean.privateGreeting); // output: undefined
trace(myProtean.publicGreeting); // output: hello
}
myProtean.traceProtean();

dynamically added or redefined functions can’t access private members of the dynamic
class
Sealed Class
A class that is not dynamic, such as the String class, is a sealed class. We cannot add properties or methods to a sealed class at run time.

What is the difference between Flex and AIR application?

The “Flex Framework” is a collection of AS3 classes and components used in developing RIAs. “Flex Builder” is an IDE used to develop “Flex Applications.” If we use something other than Flex Builder to develop in Flex, we need to download the Flex SDK to compile. The end result of a compiled Flex Application is an SWF file (Same as Flash). With the compiled SWF file, a user only needs to have Flash Player installed to run the application. Most Flex apps are developed, deployed to a server and then a web browser is used to serve the application to the user for use.
AIR is an alternative delivery system for Flex Applications, replacing the web server and browser so to speak. It’s primary purpose is for deploying RIAs to a user’s desktop, independent of an internet connection. AIR, also allows for the use of HTML, AJAX etc. So an AIR Application could be a collection of all these things, compiled together. To run an AIR Application, we need AIR Runtime installed on our computer.

What is AMF?

AMF is a binary format based loosely on the Simple Object Access Protocol (SOAP). It is used primarily to exchange data between an Adobe Flash application and a database, using a Remote Procedure Call. Each AMF message contains a body which holds the error or response, which will be expressed as an ActionScript Object. AMF was introduced with Flash Player 6, and this version is referred to as AMF 0. It was unchanged until the release of Flash Player 9 and ActionScript 3.0, when new data types and language features prompted an update, called AMF 3.

Give similarities btw Java and Flex

Both are object Oriented, Encapsulation, Inheritance, Abstraction and Polymorphism are implemented 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