1) Is their any keyword named as singleton in flex ?
A:) No
2) Can we declare constructor as protected in flex ?
a;) No AS 3.0 will not support protected constructors
3) Can we declare constructor as private in flex ?
a;) No AS 3.0 will not support private constructors
4)What is the diffrence between Protected and default access specifiers ?
a:) DEFAULT : Default access means package level access,that means a default member can be accessed
only inside the same package in which memebrs is declared
PROTECTED: protected memebers are same as default memebers as far as the access in the same
package concerned ,the diffrence is that ,the protected are also accessable
to the subclasses of the class in which members is declared which are outside
the package in which parent class is present (only through inheritence)
5)Does action script support overloading ?
a:) you can't overload a function, because you can't have more than one property
of the current variable object with the same name.
The behaviour may be is because Action Script follows the ECMA script Standard,
a function is nedeed one property of the object,so, like you can't have two properties
with the same name ,you can't have two functions with the same name.
But the functions may have default parameter like this :
[eg:]- public function doSomething(a:String='',b:someObject=null,c:Number=0 ):void
now, doSomething can be called in four diffrent ways,
doSomething()
doSomething('astring')
doSomething('astring',anObject)
doSomething('astring',anObject,123)
public function overloaded(mandatory1:Type,mandatory2:Type, ....rest):void
now, This function require the first two arguments and then pass the rest is an array,
which you can then handle as needed.This is probably the more flexible approach.
6) Explain event bubbling in flex ?
a:) Event bubling is the process of event objects being passed from objects
that will generate the event through the countership hierarchy.
6) What is the difference between target and currentTarget ??
a:) target : this proeprty contains the target node.
[eg:] if a user clicks an OK Button
the traget node is the display list node
contaning the button.
currentTraget : The object that is actively processing the event object with an eventListener.
[eg:] if user click an OK Button,the currentTarget could be the node
containing that button (or) one of it's ancestors that has registerd
an event listener of that event.
7) List some of the main features of FlexUnit 4 ?
a:) Easier to create test suite and test case classes.
Easier to create test runners and integrate runners from other frameworks.
Better usage with continous integration.
Better handling of asynchrouns tests.
Better handling of exceptions.
Framework in meta-data driven.
Allows user interface testing.
Ability to create test sequences
8) How many ways of data-binding is avilable in flex 4?
a:) five main techniques
1) using braces with MXML tag
2) using fx:binding tag
3) using the BindingUtils class
4) implicit and explicit data binding
5) Custom metadata databinding
9) What’s the difference between Java and AS3 getters and setters?
Ans : Getters and Setters are different in java and flex. In Flex ActionScript the getters and setters are the part of ECMA Script and in java they work through naming convention.
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.
You can expand on this a bit more to describe why this is useful. The
implications are that, unlike in Java, all variables in a class are
generally public. Java standard practices are to create only public
getters and setters while keeping the variables private. The reason
for only allowing methods to be publicly accessible is so that
1) they can be overridden and
2) their implementation can change without altering class interface.
AS3 addresses both of these concerns because, as described above, a
public property can be replaced with a getter and setter without
changing the interface. And an inherited public property can actually
be overridden by a subclass.
For example, this is valid:
public class A
{
public var foo:Object;
}
public class B extends A
{
override public function get foo():Object{return ‘bar’};
override public function set foo(value:Object):void{};
}
10) What is state? what is the difference between states and ViewStack?
Ans:ViewStack is to switch between different container for a single view but States change is to change view of single container itself. In ViewStack different views are switched by setting visibility true to only one container at a time, thus content containers are untouched.
11)What keyword allows you to refer to private variables of a class?
ans: Private variables cannot be referred outside the class. “this” keyword can be used to refer private variable within a class.
12)How polymorphism works on actionscript?
Ans: Polymorphism describes multiple possible states for a single property. Another way of expressing this in OOPs is, different classes implementing the same method names. Polymorphism is achieved in actionscript with keyword Override.
[In question 12 you state “Polymorphism is achieved in actionscript with keyword Override.” That’s not really true (at least from my understanding) since polymorphism is usually achieved through several classes implementing the same interface. The implementing class’ method of the interface does not need the keyword override – that’s only for when you extend from another concrete class (you could use polymorphism in this way also if your base class is severing as the “type” instead of an interface.)]
[Interface is the best example of “Polymorphism”.
Let’s say you have declared one method ” some x ” in the interface class (here ,you are declaring the method but your not implementing yet) .
And actual implementation will be done in different classes .
so one method will handle different functionality , in different classes , this is called “Polymorphism”.]
13)What keyword allows you to implement abstraction better?
Ans:There is no keyword in as3 to implement abstraction directly, but there are workaround available for this. One of the best followed way is runtime enforcement of abstract classes.
14)What is a resource Manager??
A :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.
15)What are the similarities between java and flex?
A : 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).
16)What’s the difference between ChangeWatcher.watch, and BindingUtils.bindProperty?
Ans:Changewatcher.watch is used to watch the changes to a property and when that happens execute some function. BindingUtils.bind is used to bind a property of an object to another property of another object. In-fact the ChangeWatcher.watch() uses BindingUtils.bind to do the trick.
Eg : ChangeWatcher.watch(myObject, “myProperty”, myPropertyChanged);
Here, whenever the myProperty of the object myObject is changed, the function (handler) myPropertyChanged is executed.
BindingUtils.bindProperty(textBox, “text”, myObject, “myProperty”);
Usually this is given in the creationComplete event. Here in this example, whenever myProperty of the object myObject is changed, the text property of the text box textBox is changed.
ChangeWatcher.watch returns a ChangeWatcher object, which can be saved to unwatch at later point of time.
17)Why would you want to keep a reference to a ChangeWatcher and call unwatch()?
Ans:The watch function returns an instance of ChangeWatcher which we can then use to do other things. The most important of this is to stop the ChangeWatcher. To stop watching we use a function named unwatch.
var cw:ChangeWatcher = ChangeWatcher.watch(myObject, “myProperty”,myPropertyChanged);
//when you want to stop watching
cw.unwatch();
18)How does Flex event system works?
Ans:Events let a developer know when something happens within a Flex application. They can be generated by user devices, such as the mouse and keyboard, or other external input, such as the return of a web service call. Events are also triggered when changes happen in the appearance or life cycle of a component, such as the creation or destruction of a component or when the component is resized. We can “handle” these events in our code by adding an event handler. Event handlers are the functions or methods that we write to respond to specific events. They are also sometimes referred to as event listeners.
The event model in Flex comprises the Event object and its subclasses, and the event dispatching model. We can instruct any container or control to listen for events dispatched by another container or control. When Flash Player dispatches an Event object, that Event object makes a roundtrip journey from the root of the display list to the target node, checking each node for registered listeners. The target node is the node in the display list where the event occurred. For example, if a user clicks a Button control named Child1, Flash Player dispatches an Event object with Child1 defined as the target node.The event flow is conceptually divided into three parts:
the capturing phase,
the targeting phase, and
the bubbling phase
During each of these phases, the nodes have a chance to react to the event. For example, assume the user clicks a Button control that is inside a VBox container. During the capturing phase, Flex checks the Application object and the VBox for listeners to handle the event. Flex then triggers the Button’s listeners in the target phase. In the bubbling phase, the VBox and then the Application are again given a chance to handle the event but now in the reverse order from the order in which they were checked in the capturing phase.
During any phase, we can stop the traversal of the display list by calling one of the following methods on the Event object:
stopPropagation()
stopImmediatePropagation()
We can call either the event’s stopPropagation()method or the stopImmediatePropagation() method to prevent an Event object from continuing on its way through the event flow. The two methods are nearly identical and differ only in whether the current node’s remaining event listeners are allowed to execute. The stopPropagation() method prevents the Event object from moving on to the next node, but only after any other event listeners on the current node are allowed to execute.
The stopImmediatePropagation() method also prevents the Event objects from moving on to the next node, but it does not allow any other event listeners on the current node to execute.
19)What is event Bubbling?
Answer: It's a processes of event objects being passed from objects , it follow containership hireerchy .
20)What does calling preventDefault() on an event do? How is this enforced?
Answer: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.
21)What are some ways to specify styles on components?
Ans:*declaring styles through CSS for each component
*declaring style classes in CSS and giving the class name in styleName property of component
* tag in MXML
*using setStyle() method for AS3
22)What is the problem with calling setStyle() ?
Answer:When we are instantiating an object and setting the styles for the first time, we should try to apply style sheets rather than use the setStyle() method because it is computationally expensive. This method should only be used when we are changing an object’s styles during run time.
23)What are the methods called when a UI component is intialized?
answers: addChild : is called on parent container .
*sets the parent property of the component.
*Computes style Settings.
Preinitialize: The application has been instantiated but has not yet created any child components.
CreateChildren:Flex calls the createChildren() method in response to the call to the addChild() method to add the component to its parent.
invalidateProperties(): marks a component so that its commitProperties() method gets called during a later screen update.
invalidateSize (): Marks a component so that its measure() method gets called during a later screen update.
invalidateDisplayList (): Marks a component so that its updateDisplayList() method gets called during a later screen update.
Initialize: The application has created child components but has not yet laid out those components.
CommitProperties:Flex calls the commitProperties() method when you use the addChild() method to add a component to a container, or when you call the invalidateProperties() method of the component. Calls to the commitProperties() method occur before calls to the measure() method. This lets you set property values that might be used by the measure() method.
Calls the component’s measure() method.
Measure : calculates the default size, and optionally the default minimum size, of the component. This is an advanced method that you might override when creating a subclass of UIComponent.
The default implementation of measure() sets measuredWidth, measuredHeight, measuredMinWidth, and measuredMinHeight to 0.
LayoutChrome:Calls the component’s (Adobe help mention this method is in UIComponent where as it is in container class) container’s layoutChrome() method.
The Container class, and some subclasses of the Container class, use the layoutChrome() method to define the border area around the container.
Calls the component’s updateDisplayList() method.
UpdateDisplayList(): method sizes and positions the children of your component based on all previous property and style settings, and draws any skins or graphic elements that the component uses. The parent container for the component determines the size of the component itself.
UpdateComplete ispatched when an object has had its commitProperties(), measure(), and updateDisplayList() methods called (if needed). This is the last opportunity to alter the component before it is displayed. All properties have been committed and the component has been measured and layed out.
creationComplete: The application has been completely instantiated and has laid out all components.
24) What is preloder property ?
ans: preloder property is used in tag ,which Specifies the path of a SWC component class or ActionScript component class that defines a custom progress bar. ..A SWC component must be in the same directory as the MXML file or in the WEB-INF/flex/user_classes directory of your Flex web application.[;;;http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html#213832 ]
25)what is viewSourceURL ?
Answer: You can use the viewSourceURL property of the Application container to specify a URL to the application's source code. If you set this property, Flex adds a View Source menu item to the application's context menu, which you open by right-clicking anywhere in your application. Select the View Source menu item to open the URL specified by the viewSourceURL property in a new browser window.
You must set the viewSourceURL property by using MXML, not ActionScript, You typically deploy your source code not as an MXML file, but as a text or HTML file. In this example, the source code is in the file AppSourceURL.txt. If you use an HTML file to represent your source code, you can add formatting and coloring to make it easier to read.
26) How many Parameters are avilable in removeEventListener ?
ans : removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.
type:String — The type of event.
listener:Function — The listener object to remove.
useCapture:Boolean (default = false) — Specifies whether the listener was registered for the capture phase or the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to removeEventListener() are required to remove both, one call with useCapture() set to true, and another call with useCapture() set to false.
27) What is the use of willTrigger of EventDispatcher Class ?
Answer : willTrigger(type:String):Boolean
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
28) How many Parameters are avilable for the constructor Event and use of those properties ?
Ans:
Event(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
Creates an Event object to pass as a parameter to event listeners.
@ type : String [read-only] The type of event.
@ bubbles : Boolean [read-only] Indicates whether an event is a bubbling event.
@ cancelable : Boolean [read-only] Indicates whether the behavior associated with the event can be prevented.
@ currentTarget : Object [read-only] The object that is actively processing the Event object with an event listener.
@ target : Object [read-only] The event target.
@ eventPhase : uint [read-only] The current phase in the event flow.
29) What are the methods called when UICOmponent is initalized ?
answer :
commitProperties()
createChildren()
layoutChrome()
measure()
updateDisplayList()
30) When does [Transient] meta data tag is used while dealing with Remote Object ?
answer : To restrict a specific property from being sent to the server from an ActionScript class, use the [Transient] metadata tag above the declaration of that property in the ActionScript class.
31) what is the use of ByteArray Class?
answer: ) The ByteArray class is part of the flash.utils package.
The ByteArray class includes several methods that make it easier to read from and write to a data stream. Some of these methods include readBytes() and writeBytes(), readInt() and writeInt(), readFloat() and writeFloat(), readObject() and writeObject(), and readUTFBytes() and writeUTFBytes(). These methods enable you to read data from the data stream into variables of specific data types and write from specific data types directly to the binary data stream.
The position property :
The position property stores the current position of the pointer that indexes the ByteArray during reading or writing. The initial value of the position property is 0 (zero) as shown in the following code:
var bytes:ByteArray = new ByteArray();
trace("bytes.position is initially: " + bytes.position); // 0
When you read from or write to a ByteArray, the method that you use updates the position property to point to the location immediately following the last byte that was read or written. For example, the following code writes a string to a ByteArray and afterward the position property points to the byte immediately following the string in the ByteArray.
var bytes:ByteArray = new ByteArray();
trace("bytes.position is initially: " + bytes.position); // 0
bytes.writeUTFBytes("Hello World!");
trace("bytes.position is now: " + bytes.position); // 12
Likewise, a read operation increments the position property by the number of bytes read.
var bytes:ByteArray = new ByteArray();
trace("bytes.position is initially: " + bytes.position); // 0
bytes.writeUTFBytes("Hello World!");
trace("bytes.position is now: " + bytes.position); // 12
bytes.position = 0;
trace("The first 6 bytes are: " + (bytes.readUTFBytes(6))); //Hello
trace("And the next 6 bytes are: " + (bytes.readUTFBytes(6))); // World!
32) How to create PopUPManger ? what are the properties used in PopUpManager.createPopUp()?
Answer : var loginccobj:LoginCC = PopUpManager.createPopUP(this,LoginCC,false) as LoginCC;
this -A refrence to a window to popup over
class-A reference to the class of object you want to create. This is typically a custom MXML component that implements a Spark or MX TitleWindow container.
modal-(Optional) A Boolean value that indicates whether the window is modal, and takes all keyboard and mouse input until it is closed (true), or whether interaction is allowed with other controls while the window is displayed (false). The default value is false.
33) how to call skin class from css file ?
answer : ClassReference
ie..
s|Panel
{
skin-class:ClassReference("skins.PanelSkin");
}
34) Explain Understanding the Flex Application startup event order ?
Answer:
Last week I tried to add 2 eventlisteners to the stage to listen for key up and key down events. These eventhandlers should be initiated immediately when the application is loaded. I added these eventlisteners to a function and called the function with the creationComplete() method in the application declaration. This setup gave me an error because the stage was not yet available and returned as a null object. I started digging into the event startup order of Flex and found that the stage was only available when called with the updateComplete() and applicationComplete() methods.
The creation order is different for containers and components because a container can be the parent of other components or containers. The following scheme shows the mayor events that are dispatched during the creation of a container:
So the order in which the events are dispatched by the application are preinitialize(), initialize(), creationComplete(), updateComplete() and applicationComplete().
The events in more detail:
- preinitialize() is dispatched when the component has been attached to its parent container, but before the component has been initialized, or any of its children have been created. In most cases, this event is dispatched too early for an application to use to configure a component.
- initialize() is dispatched when a component has finished its construction and its initialization properties have been set. At this point, all of the component’s immediate children have been created (they have at least dispatched their preinitialize() event), but they have not been laid out. Exactly when initialize events are dispatched depends on the container’s creation policy, as described later in this section.
- creationComplete() is dispatched when the component, and all of its child components, and all of their children, and so on have been created, laid out, and are visible.
- updateComplete() is dispatched every time the container or component characteristics are changed.
- applicationComplete() dispatches events after the Application has been initialized, processed by the LayoutManager and added to the display list. This is the last event dispatched during an application startup. It is later than the application’s creationComplete() event, which gets dispatched before the preloader has been removed and the application has been attached to the display list.
So you are trying to add eventListeners to the stage right from the start of your application execution, this will only work with updateComplete() and applicationComplete(). More information about the startup order of a Flex application can be found here.
Another solution for this is using the callLater() function.The callLater() function (or doLater() in previous versions of Flex and ActionScript), allows you to delay code execution until the user interface is updated.
35) What is the use of Generics in Java ?
Answer : The Java Collections FrameWork uses genrics to allow programers to specify the exact type of Objects that
a perticular collection will store in a program .
Generics also provides compile time-type saftey that allows programmers to catch invalid types at compile time.
Only reference types can be used with generic methods n classes.
36) What is mean by wrapper Class ?
Answer : It wraps the primitive to an object so that primitives can
be used in the activities which are reserved only for the objects.
Converting primitives to and from String objects.
Java provides the Wrapper class for each of the primitives.
some of the premetives : * Boolean
* Character
* Byte
* Short
* Integer
* Long
* Float
* Double
37) what is databinding ?
answer :
A Data Binding sets a property to watch another property for changes in value
This powerfull Flex framwork is a event based system in which objects can subsribe to updates of property
values on other objects by using data binding.
Databinding provides a conventient way to pass data between diffrent layers with in an apllication, by linking a source property to a destiantion property , changes to proprties on destiantion object occur after an event is dispacthed by the source object, notifying all destiantion objects of an update. with the property on a source object marked as bindable [Bindable],the other objects can subscribe to updates by assigining a destiantion property.
you must define the
[Bindable] metadata tag in one of three ways:
Before a class definition:
package com.oreilly.f4cb
{
import flash.events.EventDispatcher;
[Bindable]
public class DataObject extends EventDispatcher{}
}
Adding a [Bindable] tag prior to a class definition establishes a binding expression for
all readable and writable public attributes held on that class. Classes using binding
must implement the IEventDispatcher interface because data binding is an event-based
notification system for copying source properties to destination properties.
b)
Before a public, protected, or private variable:
[Bindable] private var _lastName:String;
[Bindable] protected var _age:Number;
[Bindable] public var firstName:String;
c)Before the definition of a public, protected, or private attribute using implicit getter/setter
methods:
private var _lastName:String;
...
[Bindable]
public function get lastName():String
{
return _lastName;
}
public function set lastName( str:String ):void
{
_lastName = str;
}
38) What is the difference between Array and ArrayCollection ?
answer :
Let me draw quick comparison between Array and ArrayCollection:
The elements of the ArrayCollection can be used in bindings that will be continued to be monitored. This is not the case with the normal Array class, once the element from an array is used in a binding, it is no longer monitored.ArrayCollection provides a rich set of tools for data manipulation
So what does all that mean?
According to the Adobe flex liveDocs The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces. Operations on a ArrayCollection instance modify the data source; for example, if you use the removeItemAt() method on an ArrayCollection, you remove the item from the underlying Array.
Let me take an example to clear this concept. Say we receive some data through some webservice. Now if we parse the result set into Array, we have only a few tools to manipulate data namely, push() (for adding an element to the end), pop() (for removing the last element), length (the number of indices), etc.
However, the ArrayCollection class provides a suite of immensely convenient "extra" methods that can act on the Array namely the addItemAt(), removeItemAt(). So using these methods, we can directly access any index value of an array.
Apart from that, we can continuously watch the array for any changes at run time. Say, some user operation deletes a value from my ArrayCollection or Add a new item in my ArratyCollection which I am using as an dataProvider for a data grid. In that case, I can see the node getting disappear or visible at the same time.
This can’t be possible in the case of an Array.
Array is the toplevel Class and global functions.
Inheritance---->Array--> Object.
The Array class lets you access and manipulate arrays. Array indices are zero-based, which means that the first element in the array is [0], the second element is [1], and so on.
You can store a wide variety of data types in an array element, including numbers, strings, objects, and even other arrays. You can create a multidimensional array by creating an indexed array and assigning to each of its elements a different indexed array. Such an array is considered multidimensional because it can be used to represent data in a table.
Object is also a Top level Class and it's functions are global.
ArrayCollection (mx.collections.* package)-->Inheritance ArrayCollection ListCollectionView Proxy Object
Implements IExternalizable
ArrayCollection is a Wrapper Class for Array which implements ICollectionView and IList Interfaces to provide methods n properties
for manipulating arrays.It monitors and updates Databinding to all values in an instance unlike Array and Object (this two won't monitor indvidual values in their instance) hence ArrayCollection class is recomended to use as dataprovider for Components.
.....................................................................................................................................
39) What is creation policy ? [http://livedocs.adobe.com/flex/3/html/help.html?content=styles_08.html]
Answer : Containers with multiple views, such as the ViewStack and Accordion, do not immediately create all of their descendants, but only those descendants that are visible in the initial view. Flex defers the instantiation of descendants that are not initially visible until the user navigates to a view that contains them. The following containers have multiple views and, so, are defined as navigator containers:
ViewStack
TabNavigator
Accordion
When you instantiate a navigator container, Flex creates all of the top-level children. For example, creating an Accordion container triggers the creation of each of its views, but not the controls within those views. The creationPolicy property determines the creation of the child controls inside each view.
Value Description
all :
Creates all controls in all views of the navigator container. This setting causes a delay in application startup time, but results in quicker response time for user navigation.
auto :
Creates all controls only in the initial view of the navigator container. This setting causes a faster startup time for the application, but results in slower response time for user navigation.
This setting is the default for multiple-view containers.
none :
Instructs Flex to not instantiate any component within the navigator container or any of the navigator container's panels until you manually instantiate the controls.
To manually instantiate controls, you use the createComponentsFromDescriptors() method. For more information, see Creating deferred components.
queued :
This property has no effect on deferred creation. For more information on using the queued value of the creationPolicy property, see Using ordered creation.
.....................................................................................................................................
40) What is the difference between result and lastResult ?
Answer : After the request executes, returnd data is placed in the objects lastResult property
here, lastResult is represented as an ArrayCollection instance of objects.
Based on your previous experience, you know that the returned data is represented as an ArrayCollection instance of generic objects.
You also learned that it is often more useful to handle the data with a result event rather than directly binding to the lastResult property.
Doing so allows you to manipulate the data before you use it or assign it to a class property, where it can be used more flexibly in the application.
Remember that the event object is of type ResultEvent.
Note:You use the lastResult property in data bindings directly to the returned results, and you use the result property in an event handler when you pass the event object to the event handler function.
41) What is Flex ?
Answer : It is a markup programming language. With this language, you can create visually stunning User Interfaces for your web application. These user interfaces will run in the flash player of the browser. The programs you write with Flex are in XML and ActionScript.
Flex is an event driven technology, this means that it relay on system calls are user interaction to drive application behaviour
42)What is MXML?
Answer: It is xml-based user interface markup language first introduced by Macromedia.
MXML tags r actually AS classes.
ie..in reality tag is an instance of Application Classes
43)So whats so special about Flex 4?
Answer : Behaviour , layout,styles, and skins are decopled in flex 4 .
All components in Flex 4 are sum of two things – 1) The behaviour, logic and the data holders of the component coded in an ActionScript class + 2) the graphics,layout,animation,states and constituent parts(in case of a complex component) in MXML. The Adobe guys have named these sort of components as Spark components.
The compiler has been improved and now works faster.
The Effects like Swipe down,etc are improved, now they are smoother than before.
The layout system has been modified, now the layouts are assigned to the component’s MXML tags as attributes.
Earlier we used to have layout specific components, like Vbox,Hbox,etc.
Compile time optimization of images – so static graphics like images which get used only one or two times are separated out, which helps in making SWF files lighter.
Well, no. in Flex 3 – Every component had behaviour, logic,graphics,layout,animation,states all coded in an ActionScript class and there were MXML tags attached to them. And a few of the properties mentioned here were exposed as attributes of the MXML tags. So a developer could manipulate the values for these attributes. If he wanted more, he would have to wade through the entire ActionScript class.
.....................................................................................................................................
44) What are mx_internal namespaces in flex and create a coustom namespace ?
Answer:
Adobe uses the mx_internal namespace to mark things that may change in future versions of the framework .. So you have to use it at your own risk, because your inherited class or component may not work with future releases of Flex.
mx_internal is a namespace used by the Flex framework to partition out functions and properties that may change in future releases of the Flex SDK.
Traditionally in OOO languages access specifiers are used to control visibility of declarations (public, private, protected). Now with XML based languages like MXML making debut, a new mechanism for controlling visibility of declarations has evolved… using namespaces. Namespaces are essentially custom access specifiers, which can have names of your choosing. Namespaces are outfitted with a Universal Resource Identifier (URI) to avoid collisions, and are also used to represent XML namespaces when working with E4X.
What I’m interested in discussing here is an internal namespace that FLEX framework uses for its internal data, called mx_internal. A lot of variables in Flex are mx_internal variables and are available to the developers if they use the mx_internal namespace. Before we go into the details of how to use them… lets look at how to identify these variables. There are 2 ways to do this…
One is the straight forward way of looking into the source. Since Flex is Open Source and comes bundled with the source code.. one can easlily locate these variables in the source. For example, under the class defenition of VideoDisplay.as, you can see the an mx_internal variable called videoPlayer (of type VideoPlayer, which in turn extends from flash.media.Video)
mx_internal var videoPlayer:VideoPlayer = null;
This way of identifying mx_internal variables is not always effective, so a better way is to use FlexBuilder to identify them. This is what you need to do…
Switch to Flex Debugging View
Use the following code
public function debug():void{ } ]]>
Make sure that you can view the mx_internal variables in the debugging mode. You can do this by checking the options in the debug Layout as below
Now put a break point in the debug() function and run the app in the debug mode. Click on the button to come to the debug view and add a watch for the VideoDisplay object. You’ll see the following in the debug view, when you search for videoDisplay under the watched vid variable…
The variables are color coded as below
Red Rectangle – private
Green Circle – public
Yellow Rhombus – mx_internal
Char codes “C” & “S” – constants and static vars
Now you have identified the mx_internal variables that you need to use. Now lets see how to use them. This is a 3 step process…
Import the namespace that is going to be used. Note that this needs to be done after all other imports
import mx.core.mx_internal;
Tell Actionscript that is a namespace
use namespace mx_internal;
Prefix the property name with its namespace
vd.mx_internal::videoPlayer.clear();
Thus you can now access and use the mx_internal variable and all its properties, methods, styles etc. I’ll tell you about some scenarios where this is most useful in the coming posts. Hope this makes your job easier
.....................................................................................................................................
45 ) How to avoide shadow of panel in both mx and spark ?
Answer : with ;
Note: headerHeight property is only avilable for mx:panel not s:panel, but for s:panel it van be achived by skinning.
46) Does HTTPService source property ?
Answer : No, HTTPSerive dn't have source property,It has url property
But RemoteObject have source property along with endPoint property but no url proeprty in RemoteObject.
TIP1: higlight bulk code in flash builder and press TAB key to move it disance together.
47)Say about spark cotainers ?
Answer : spark includes following containers
1)Group (very low-overhead(high -effeciency) container which is also a non-skinable container
and it displays all visuall childern together, place BorderContainer instance around
GroupContainer)
2)DataGroup
*which above are non-skinable containers n below 5 are skinable containers.*
3)SkinableContainers
4)SkinableDataContainers
5)Application
6)Panel
7)BorderContainer (This container provides an approach to change the border n background of container
without creating a skin.
It defines set of css styles that conrol the apperance of border n background fill
of the container,n it's a child of SkinableContainer )
NOTE: Each Containers has layOut Property , and each layOut Property has a value that is an instance of another Class
eg:
48) Does scrollers play automatic in spark components?
Answer:
No,Spark components are not automatically scrollable .
Use Scroller component to display horizontal/vertical scroll bars
Wrap the scroller around group container.
Constrain the scroller component size,not the view port size.
SkinableContainers define their scrollbars in their skins.
eg:
49) Override base class method in Action script ?
Answer: it should have :
All Same name, modifier,parameter list,parameter data types, return type, and must explicitly marked with override keyword
50) what does super() does in AS?
answer :
As use super()to invoke functionality of base class
52) What is RIA ?
answer :
Rich Internet Applications are Web-based applications that function as traditional desktop applications however Web browsers (or clients) are required for access but unlike traditional applications, software installation is not required, however depending on the application you usually will need to have ActiveX, Java, Flash, or similar technologies installed on the client machine.
A rich internet application tries to lower the amount of round trips to a server. They use a runtime engine that is downloaded to the user's machine. The engine enables the application to handle all the interaction with the user. It only talks to an application server when necessary.
RIAs also provide a richer set of features for the user interface such as animation or the ability to drag and drop.
53) What is the difference between DataGroup and SkinnableDataContainer ?
Answer : The Spark DataGroup and Spark SkinnableDataContainer containers take as children any components that implement the IVisualElement interface and are subclasses of DisplayObject. However, these containers are primarily used to take data items as children. Data items can be simple data items such String and Number objects, and more complicated data items such as Object and XMLNode objects.
An item renderer defines the visual representation of the data item in the container. The item renderer converts the data item into a format that can be displayed by the container. You must pass an item renderer to a DataGroup or SkinnableDataContainer container.
The main differences between the DataGroup and SkinnableDataContainer containers are:
SkinnableDataContainer can be skinned. The DataGroup container is designed for simplicity and minimal overhead, and cannot be skinned.
DataGroup can be a child of the Scroller control to support scroll bars. Create a skin for the SkinnableDataContainer to add scroll bars.
54) What is difference between Group and SkinnableContainer ?
Answer: The Spark Group containers take any components as a child which implement the IVisualElement interface. When you want to manage visual children component (both visual components and graphical components) you can use Group container. The Group container is designed for simplicity and it cannot be skinned. The BasicLayout is the default layout class of the Group container. You can use Horizontal and Vertical layout with Group container also. The tag of Group container is .
SkinnableContainer is similler to Group but it provides skinning feciltiy.
55) What is the difference between Group and DataGroup containers?
Answer: The Spark Group containers take any components as a child which implement the IVisualElement interface. When you want to manage visual children component (both visual components and graphical components) you can use Group container. The Group container is designed for simplicity and it cannot be skinned. The BasicLayout is the default layout class of the Group container. You can use Horizontal and Vertical layout with Group container also. The tag of Group container is .
SkinnableContainer is similler to Group but it provides skinning feciltiy.
DataGroup container is a Spark container in Flex 4 hold components that implements IVisualElement interface and subclasses of DisplayObject. User uses these containers when take data item as children. These container uses item renderer that provide visual representation of the data item in the container. Item renderer converts data item in the format type which is required by the container. These components also use data provider to provide data for these components. The data provider is the by default property for this component. The tag is . In this example you can see mix data items like String and Objects.
Difference :
56) how is this BorderContainer is useful ?
57) What is DataPush ?
Answer:
58) What are constraints ?
59) What is linkButton ?
60)What is controlBar Content in Panel ?
61)Why embeded property is used while dealing with images ?
Answer:
For example, you use the [Embed] metadata tag in ActionScript to embed a GIF image, as the following code shows:
[Embed(source="logo.gif")]
[Bindable]
public var imgCls:Class;
In this example, you define a class named imgCls that represents the embedded image. When embedding JPEG, GIF, and PNG files, Flex defines imgCls as a reference to a subclass of the mx.core.BitmapAsset class, which is a subclass of the flash.display.Bitmap class.
62) List some Framwork initiated events and user intiated events ?
Answer: FrameWork Initiated Events:
initialize
creationComplete
show (component goes from invisible to visble)
User initiated events :(This fires when user interact )
click
change
mouseOver
63)How many ways we can impliment handlers ?
Answer: two ways to implement event handlers:
1) using inline ActionScript
2)Using Action Script function in a scipt block
64) Name some events types of Event Class ?
Answer: events are of mostly in three packages :
spark.events.*;
mx.events.*;
flash.events.*;
type:string = name of event ..ie..eg: click
target:Object = name of the target
currentTarget:Object = name of the current traget
eventPhase:uint = name of the event phase.
target.id = instance name of the target
.....................................................................................................................................
65)What are Effects in flex ?
Answer:
An effect is a visible or audible change to the target component that occurs over a period of time, measured in milliseconds. For example, you can use behaviors to cause a dialog box to bounce slightly when it receives focus, or to slowly fade in when it becomes visible.
Adobe® Flex® supplies a number of standard effects that you can use in your application. However, you also can define custom effects for your specific application needs.
Flex implements effects by using an architecture in which each effect is represented by two classes: a factory class and an instance class. Therefore, to implement a custom effect, you create two classes: the factory class and the instance class.
ie.. mx.effects.Effect,
mx.effects.EffectInstance
You create a factory class by creating a subclass of the mx.effects.Effect class, or by creating a subclass of one of the subclasses of the mx.effects.Effect class. You create an instance class by creating a subclass of the mx.effects.EffectInstance class, or a subclass of one of the subclasses of the mx.effects.EffectInstance class.
Effect-->MaskEffect -->effect classes
-->TweenEffect -->effect classes
-->CompositeEffect -->effect classes
EffectInstance-->MaskEffectInstance -->effectinstance classes
-->TweenEffectInstance -->effectinstance classes
-->CompositeEffectInstance -->effectinstance classes
The following table lists the methods and properties that you define in a factory class:
Factory method/property
Description
constructor
(Required) The class constructor. You typically call the super() method to invoke the superclass constructor to initialize the inherited items from the superclasses.
Your constructor must take at least one optional argument, of type Object. This argument specifies the target component of the effect.
Effect.initInstance()
(Required) Copies properties of the factory class to the instance class. Flex calls this protected method from the Effect.createInstance() method; you do not have to call it yourself.
In your override, you must call the super.initInstance() method.
Effect.getAffectedProperties()
(Required) Returns an Array of Strings, where each String is the name of a property of the target object that is changed by this effect. If the effect does not modify any properties, it should return an empty Array.
Effect.instanceClass
(Required) Contains an object of type Class that specifies the name of the instance class for this effect class.
All subclasses of the Effect class must set this property, typically in the constructor.
Effect.effectEndHandler()
(Optional) Called when an effect instance finishes playing. If you override this method, ensure that you call the super() method.
Effect.effectStartHandler()
(Optional) Called when the effect instance starts playing. If you override this method, ensure that you call the super() method.
Additional methods and properties
(Optional) Define any additional methods and properties that the user requires to configure the effect.
The following table lists the methods and properties that you define in an instance class:
Instance method/property
Description
constructor
(Required) The class constructor. You typically call the super() method to invoke the superclass constructor to initialize the inherited items from the superclasses.
EffectInstance.play()
(Required) Invokes the effect. You must call super.play() from your override.
EffectInstance.end()
(Optional) Interrupts an effect that is currently playing, and jumps immediately to the end of the effect.
EffectInstance.initEffect()
(Optional) Called if the effect was triggered by the EffectManager. You rarely have to implement this method. For more information, see Overriding the initEffect() method.
TweenEffectInstance.onTweenUpdate()
(Required) Use when you create a subclass from TweenEffectInstance. A callback method called at regular intervals to implement a tween effect. For more information, see Example: Creating a tween effect.
TweenEffectInstance.onTweenEnd()
(Optional) Use when you create a subclass from TweenEffectInstance. A callback method called when the tween effect ends. You must call super.onTweenEnd() from your override. For more information, see Example: Creating a tween effect.
Additional methods and properties
(Optional) Define any additional methods and properties. These typically correspond to the public properties and methods from the factory class, and any additional properties and methods that you require to implement the effect.
some of the classes of Effect :
AddAction, AddChildAction, AddItemAction, Animate, CallAction, CompositeEffect, MaskEffect, RemoveAction, RemoveChildAction, RemoveItemAction, SetAction, SetPropertyAction, SetStyleAction, SoundEffect, TweenEffect, UnconstrainItemAction
some of the classes of TweenEffect:
Subclasses AnimateProperty, Blur, Dissolve, Fade, Glow, Move, Pause, Resize, Rotate, SeriesEffect, Zoom
.....................................................................................................................................
66) What are Filters in flex ?
Answers: You can use Adobe Flash filters to apply style-like effects to Flex components, such as Labels and Text. You can apply filters to any visual Flex component that is derived from UIComponent. Filters are not styles because you cannot apply them with a style sheet or the setStyle() method. The result of a filter, though, is often thought of as a style.
Filters are in the flash.filters.* package, and include the DropShadowFilter, GlowFilter, and BlurFilter classes. To apply a filter to a component with MXML, you add the filter class to the component's filters Array. The filters Array is a property inherited from the DisplayObject class. It contains any number of filters you want to apply to the component.
The following example applies a drop shadow to a Label control by using expanded MXML syntax and inline syntax:
text="DropShadowFilter (inline)"
fontSize="20"
filters="{[new DropShadowFilter(10, 45)]}"
/>
.....................................................................................................................................
67) What are Transitions in Flex ?
Answer:
View states let you vary the content and appearance of an application, typically in response to a user action. To use view states, you define the base view state of an application, and one or more additional view states.
When you change view states, Adobe® Flex® performs all the visual changes to the application at the same time. That means when you resize, move, or in some other way alter the appearance of the application, the application appears to jump from one view state to the next.
Instead, you might want to define a smooth visual change from one view state to the next, in which the change occurs over a period of time. A transition is one or more effects grouped together to play when a view state change occurs.
For example, your application defines a form that in its base view state shows only a few fields, but in an expanded view state shows additional fields. Rather than jumping from the base version of the form to the expanded version, you define a Flex transition that uses the Resize effect to expand the form, and then uses the Fade effect to slowly make the new form elements appear on the screen.
When a user changes back to the base version of the form, your transition uses a Fade effect to make the fields of the expanded form disappear, and then uses the Resize effect to slowly shrink the form back to its original size.
By using a transition, you can apply one or more effects to the form, to the fields added to the form, and to fields removed from the form. You can apply the same effects to each form field, or apply different effects. You can also define one set of effects to play when you change state to the expanded form, and a different set of effects to play when changing from the expanded state back to the base state.
.....................................................................................................................................
68) What is Bitmap and BitmapData Classes ?
Answer: The main ActionScript 3.0 classes for working with bitmap images are the Bitmap class, which is used to display bitmap images on the screen, and the BitmapData class, which is used to access and manipulate the raw image data of a bitmap.
Understanding the Bitmap class
As a subclass of the DisplayObject class, the Bitmap class is the main ActionScript 3.0 class used for displaying bitmap images. These images may have been loaded into Flash via the flash.display.Loader class or created dynamically using the Bitmap() constructor. When loading an image from an external source, a Bitmap object can only use GIF, JPEG, or PNG format images. Once instantiated, the Bitmap instance can be considered a wrapper for a BitmapData object that needs to be rendered to the Stage. Because a Bitmap instance is a display object, all the characteristics and functionality of display objects can be used to manipulate a Bitmap instance as well. For more information about working with display objects, see Display programming.
Pixel snapping and smoothing
In addition to the functionality common to all display objects, the Bitmap class provides some additional features that are specific to bitmap images.
Similar to the snap-to-pixel feature found in the Flash authoring tool, the pixelSnapping property of the Bitmap class determines whether or not a Bitmap object snaps to its nearest pixel. This property accepts one of three constants defined in the PixelSnapping class: ALWAYS, AUTO, and NEVER.
The syntax for applying pixel snapping is as follows:
myBitmap.pixelSnapping = PixelSnapping.ALWAYS;
Often, when bitmap images are scaled, they become blurred and distorted. To help reduce this distortion, use the smoothing property of the BitmapData class. This Boolean property, when set to true, smooths, or anti-aliases, the pixels within the image when it is scaled. This gives the image a clearer and more natural appearance.
Understanding the BitmapData class
The BitmapData class, which is in the flash.display package, can be likened to a photographic snapshot of the pixels contained within a loaded or dynamically created bitmap image. This snapshot is represented by an array of pixel data within the object. The BitmapData class also contains a series of built-in methods that are useful for creation and manipulation of pixel data.
To instantiate a BitmapData object, use the following code:
var myBitmap:BitmapData = new BitmapData(width:Number, height:Number, transparent:Boolean, fillColor:uinit);
The width and height parameters specify the size of the bitmap; the maximum value of both is 2880 pixels. The transparent parameter specifies whether the bitmap data includes an alpha channel (true) or not (false). The fillColor parameter is a 32-bit color value that specifies the background color, as well as the transparency value (if it has been set to true). The following example creates a BitmapData object with an orange background that is 50 percent transparent:
var myBitmap:BitmapData = new BitmapData(150, 150, true, 0x80FF3300);
To render a newly created BitmapData object to the screen, assign it to or wrap it in a Bitmap instance. To do this, you can either pass the BitmapData object as a parameter of the Bitmap object's constructor, or you can assign it to the bitmapData property of an existing Bitmap instance. You must also add the Bitmap instance to the display list by calling the addChild() or addChildAt() methods of the display object container that will contain the Bitmap instance. For more information on working with the display list, see Adding display objects to the display list.
The following example creates a BitmapData object with a red fill, and displays it in a Bitmap instance:
var myBitmapDataObject:BitmapData = new BitmapData(150, 150, false, 0xFF0000);
var myImage:Bitmap = new Bitmap(myBitmapDataObject);
addChild(myImage);
.....................................................................................................................................
69) Why Adding eventListeners via AS3 even when mxml event calls are avilable ?
answer :
Coz , 1)Some ActionScipt Classes don't have mxml equivlent ,ie..classes exist that you can only instantiate in ActionScript not MXML.
2)You can only remove listeners added via ActionScript using removeEventListeners method.
3)Some devlopers prefer Scripting
70) Difference between ArrayList and ArrayCollection ?
Answer :
ArrayList is new to flex 4.
Both,ArrayList and ArrayCollection classes can be used for databinding
ArrayList has less overhead than ArrayCollection
If you need to sort or filter the array, use ArrayCollection class.
ArrayList-->
Package mx.collections
Class public class ArrayList
Inheritance ArrayList EventDispatcher Object
Implements IList, IExternalizable, IPropertyChangeNotifier
Subclasses Conflicts
ArrayCollection-->
Package mx.collections
Class public class ArrayCollection
Inheritance ArrayCollection ListCollectionView Proxy Object
Implements IExternalizable
Subclasses ApproverCollection, DocumentCollection, ModeratorCollection, Node, ReminderCollection, ReviewerCollection, StageCollection
71) Mention some advatages using Network monitor and debbuger ?
Answer :
NetworkMonitering helps in :
providing information on : network traffic between flex and server.
Elapsed time.
Packet Size.
Packet type and content.
Data information avilable in three views, tree, raw, binery views.
.....................................................................................................................................
72) how you deal with Flex and REST (including GET, POST, PUT and DELETE) ?
Answer:
I usually use flash.net.URLLoader, URLRequest, URLVariables, flash.net.URLRequestMethod
a)Package flash.net
Class public class URLLoader
Inheritance URLLoader EventDispatcher Object
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 code in the applications. 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.
When loading very large video files, such as FLV's, out-of-memory errors may occur.
When you use this class in Flash Player and in AIR application content in security sandboxes other than then application security sandbox, consider the following security model:
A SWF file in the local-with-filesystem sandbox may not load data from, or provide data to, a resource that is in the network sandbox.
By default, the calling SWF file and the URL you load must be in exactly the same domain. For example, a SWF file at www.adobe.com can load data only from sources that are also at www.adobe.com. To load data from a different domain, place a URL policy file on the server hosting the data.
URLLoaderExample.as
The following example loads and displays the data found in a local text file. It also traces event handling information.
Note: To run this example, put a file named urlLoaderExample.txt in the same directory as your SWF file. That file should only contain the following line of text: answer=42&question=unknown
The example code does the following:
The constructor function creates a URLLoader instance named loader and a URLRequest instance named request, which contains the location and name of the file to be loaded.
The loader object is passed to the configureListeners() method, which adds listeners for each of the supported URLLoader events.
The request object is then passed to loader.load(), which loads the text file.
When the URLLoader has finished loading the text file the Event.COMPLETE event fires, triggering the completeHandler() method. The completeHandler() method creates a URLVariables object from the text loaded from the file. The URLVariables object converts URL-encoded name/value pairs into ActionScript properties to make it easier to manipulate the loaded data.
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class URLLoaderExample extends Sprite {
public function URLLoaderExample() {
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("urlLoaderExample.txt");
try {
loader.load(request);
} catch (error:Error) {
trace("Unable to load requested document.");
}
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
var vars:URLVariables = new URLVariables(loader.data);
trace("The answer is " + vars.answer);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}
b) Package flash.net
Class public final class URLRequest
Inheritance URLRequest Object
The URLRequest class captures all of the information in a single HTTP request. URLRequest objects are passed to the load() methods of the Loader, URLStream, and URLLoader classes, and to other loading operations, to initiate URL downloads. They are also passed to the upload() and download() methods of the FileReference class.
A SWF file in the local-with-filesystem sandbox may not load data from, or provide data to, a resource that is in the network sandbox.
By default, the calling SWF file and the URL you load must be in the same domain. For example, a SWF file at www.adobe.com can load data only from sources that are also at www.adobe.com. To load data from a different domain, place a URL policy file on the server hosting the data.
However, in Adobe AIR, content in the application security sandbox (content installed with the AIR application) is not restricted by these security limitations. For content running in Adobe AIR, files in the application security sandbox can access URLs using any of the following URL schemes:
http and https
file
app-storage
app
Content running in Adobe AIR that is not in the application security sandbox observes the same restrictions as content running in the browser (in Flash Player), and loading is governed by the content's domain and any permissions granted in URL policy files.
URLRequestExample.as
The following example creates a new Loader object and passes it a URLRequest object that contains the path to an XML file. If the loading operation is successful, a complete event is dispatched and the data in the XML file traces to the output. Additional event handlers capture other events, including error events.
To run this example, place a file named XMLFile.xml in the same directory as your SWF file.
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class URLRequestExample extends Sprite {
public function URLRequestExample() {
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("XMLFile.xml");
try {
loader.load(request);
} catch (error:Error) {
trace("Unable to load requested document.");
}
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}
c)Package flash.net
Class public dynamic class URLVariables
Inheritance URLVariables Object
The URLVariables class allows you to transfer variables between an application and a server. Use URLVariables objects with methods of the URLLoader class, with the data property of the URLRequest class, and with flash.net package functions.
URLVariablesExample.as
The following example opens the remote application hosted at http://www.[yourDomain].com/application.jsp in a new browser window and passes data about a user session, captured in a URLVariables object, to the application.
Highlights of the example follow:
The constructor function creates a URLRequest instance named request, taking the URL of the remote application as a parameter.
A URLVariables object is created and two of its properties are assigned values.
The URLVariables object is assigned to the data property of the URLRequest object.
The example calls navigateToURL, which opens a new browser window to the remote application's URL.
Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by Flash Player in the URLVariables object.
package {
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLVariables;
public class URLVariablesExample extends Sprite {
public function URLVariablesExample() {
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";
request.data = variables;
navigateToURL(request);
}
}
}
d)Package flash.net
Class public final class URLRequestMethod
Inheritance URLRequestMethod Object
The URLRequestMethod class provides values that specify whether the URLRequest object should use the POST method or the GET method when sending data to a server.
URLRequestMethodExample.as
The following example loads and displays the data found in a local text file. It also traces event handling information.
Note:To run this example, put a file named example.txt in the same directory as your SWF file. That file should be a simple text file containing a few words or lines of text.
The example code does the following:
The constructor function creates a URLLoader instance named loader.
The loader object is passed to the configureListeners() method, which adds listeners for each of the supported URLLoader events.
A URLRequest instance named request is created, which specifies name of the file to be loaded.
The method property of the request is set to URLRequestMethod.POST.
The request object is then passed to loader.load(), which loads the text file.
When the URLLoader has finished loading the text file the Event.COMPLETE event fires, triggering the completeHandler() method. The completeHandler() method simply traces the data property, the contents of the text file.
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class URLRequestMethodExample extends Sprite {
public function URLRequestMethodExample() {
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("example.txt");
request.method = URLRequestMethod.POST;
loader.load(request);
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(Event.OPEN, openHandler);
dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: " + loader.data);
}
private function openHandler(event:Event):void {
trace("openHandler: " + event);
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace("httpStatusHandler: " + event);
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}
.....................................................................................................................................
73) What is the difference between HTTP and HTTPS ?
Answer: HTTP HTTPS
URL begins with “http://” URL begins with “https://”
It uses port 80for communication It uses port 443 for communication
Unsecured Secured
Operates at Application Layer Operates at Transport Layer
No encryption Encryption is present
No certificates required Certificates required
Hypertext Transfer Protocol (HTTP) is a protocol used in networking. When you type any web address in your web browser, your browser acts as a client, and the computer having the requested information acts as a server. When client requests for any information from the server, it uses HTTP protocol to do so. The server responds back to the client after the request completes. The response comes in the form of web page which you see just after typing the web address and press “Enter”.
Hypertext Transfer Protocol Secure (HTTPS) is a combination of two different protocols. It is more secure way to access the web. It is combination of Hypertext Transfer Protocol (HTTPS) and SSL/TLS protocol. It is more secure way to sending request to server from a client, also the communication is purely encrypted which means no one can know what you are looking for. This kind of communication is used for accessing those websites where security is required. Banking websites, payment gateway, emails (Gmail offers HTTPS by default in Chrome browser), and corporate sector websites are some great examples where HTTPS protocols are used.
For HTTPS connection, public key trusted and signed certificate is required for the server. These certificate comes either free or it costs few dollars depends on the signing authority. There is one other method for distributing certificates. Site admin creates certificates and loads in the browser of users. Now when user requests information to the web server, his identity can be verified easily.
To enable both HTTP and HTTPS access to you Flex app, you need to do the following:
1. Open remoting-config.xml (can be located at /WEB-INF/flex)
2. Look for
3. Add reference to the secure channel
4. Define "my-secure-amf" in "services-config.xml" if not aleady defined.
....................................................................................................................................
74) What is seralization ?
Answer:
Serialization is the process of converting an object into a
stream of bytes. Deserialization is the opposite process of
creating an object from a stream of bytes.
Serialization/Deserialization is mostly used to transport
objects (e.g. during remoting), or to persist objects (e.g.
to a file or database).Serialization can be defined as the
process of storing the state of an object to a storage
medium. During this process, the public and private fields
of the object and the name of the class, including the
assembly containing the class, are converted to a stream of
bytes, which is then written to a data stream. When the
object is subsequently deserialized, an exact clone of the
original object is created.
? Binary serialization preserves type fidelity, which is
useful for preserving the state of an object between
different invocations of an application. For example, you
can share an object between different applications by
serializing it to the clipboard. You can serialize an object
to a stream, disk, memory, over the network, and so forth.
Remoting uses serialization to pass objects "by value" from
one computer or application domain to another.
? XML serialization serializes only public properties and
fields and does not preserve type fidelity. This is useful
when you want to provide or consume data without restricting
the application that uses the data. Because XML is an open
standard, it is an attractive choice for sharing data across
the Web. SOAP is an open standard, which makes it an
attractive choice.
There are two separate mechanisms provided by the .NET class
library - XmlSerializer and SoapFormatter/BinaryFormatter.
Microsoft uses XmlSerializer for Web Services, and uses
SoapFormatter/BinaryFormatter for remoting. Both are
available for use in your own code.
....................................................................................................................................
75) Why we use polling enabled as true ?
Answer: This channel definition creates a polling channel with a polling interval of 1 second. Therefore, the client sends a poll message to the server every second to request new messages. Use a polling channel because it is the easiest way for the client to receive updates.
.....................................................................................................................................
76)What is crossdomain.xml in flex ?
answer:
The Flash Player follows a sandbox security. In certain cases you'll need to provide a crossdomain.xml file for your Flex Applications to work.
A cross-domain policy file is an XML document that grants a web client—such as Adobe Flash Player, Adobe Reader, etc.—permission to handle data across multiple domains. When a client hosts content from a particular source domain and that content makes requests directed towards a domain other than its own, the remote domain would need to host a cross-domain policy file that grants access to the source domain, allowing the client to continue with the transaction. Policy files grant read access to data, permit a client to include custom headers in cross-domain requests, and are also used with sockets to grant permissions for socket-based connections.
"...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..."
This brief tutorial will teach you how to create a crossdomain.xml file so that you can access files and information from outside domains and load files and data within your Flash / Flex apps. It is as simple as 4 easy steps.
1) Create an xml file named crossdomain.xml. (XML can be created with Dreamweaver or just simply MS Notepad. Just make sure that you give it the '.xml ' extension on the end.)
2)Copy and paste one of the code examples below into the XML file:
3)Save the file.
4) FTP / upload the file to the root directory of your website. (you should be able to see the file in a browser by typing the url www.yourwebsite.com/crossdomain.xml).
XML Code 1:
This is a typical crossdomain.xml file. Notice that I included my domain as well as my domain without the 'www' in front.
XML Code 2:
The follwing Code will allow all domains. This effectively eliminates any security that Flash would have otherwise had. I suggest that you don't use this example unless you enjoy security holes.
XML Code 3:
The block of code below will explicitly disallow any and all access from any outside domain. As well, any domain that is not spelled exactly how the host domain is spelled will be blocked. This is the tighest cross domain security that you can employee.
XML Code 4:
The code below illustrates different uses of the '*' wildcard symbol. This is the crossdomain.xml file from Amazon.com The wildcard allows for any variation before '.amazon.com'. Amazon does this because of the public services and APIs that it allows others to connect to.
Creating a cross domain policy file is just that easy.
And Happy Flashing.
P.S. I highly suggest that you read one or all of the following articles on cross domain policy files and the Flash Player security sandbox,
.....................................................................................................................................
77) What is the use of SWFLoader ?
Answer:
.....................................................................................................................................78) How to create coustom preloader ?
Answer:
.....................................................................................................................................
79) Does multithreading is supported by Flex and AS3?
Answer:
Flex/Flash alone don't support multithreading - Adobe keeps argumenting that multithreading is not necessary for most of potential flex applications and would just increase complexity for the average flex developer too much.
Looking for solutions myself I have only found snippets where the task to be done simultanously gets logically cut into smaller pieces, then you run them piece by piece, letting UI get time slices in between. It might work for some but is no solution to your problem.
Now to Java - using the native process api could make it work. Java process would take over some part of the processing and you would control its working writing to and reading from input/output streams which gets connected between java process and flex app. Another possibility could be inter-process socket communication (did it myself before native process api was there - works!)
Explantion :
Every once in a while, someone decides they would like to see threading or background processing in Actionscript. While the underlying Flash Player and Operating System use threads, the execution model for Actionscript does not.
For those who don’t know, ‘threading’ is essentially the ability to have the code do something in the background while the UI is doing something else. Because Actionscript is single-threaded, if you spend lots of time doing heavy computation, the UI cannot be updated while you’re doing that computation so your application appears stuck or effects don’t run smoothly.
Similarly, there is no yielding or blocking in Actionscript either. If the next line of code is supposed to run, you cannot prevent the next line of code from running. That means that when you call Alert.show(), the next line of code following that runs right away. In many other runtimes, the Alert window has to be closed before the next line of code continues.
Threading may be a feature of Actionscript some day, but until then, you have to live with the fact that there is no such thing right now.
.....................................................................................................................................80)What is ProgressBar in flex ?
Answer: The ProgressBar control provides a visual representation of the progress of a task over time. There are two types of ProgressBar controls: determinate and indeterminate.
A determinate ProgressBar control is a linear representation of the progress of a task over time. You use a determinate ProgressBar when the scope of the task is known. It displays when the user has to wait for an extended amount of time.
An indeterminate ProgressBar control represents time-based processes for which the scope is not yet known. As soon as you can determine the scope, you should use a determinate ProgressBar control.
Use the ProgressBar control when the user is required to wait for completion of a process over an extended period of time. You can attach the ProgressBar control to any kind of loading content. A label can display the extent of loaded contents when enabled.
ProgressBar control modes:
You use the mode property to specify the operating mode of the ProgressBar control. The ProgressBar control supports the following modes of operation:
event Use the source property to specify a loading process that emits progress and complete events. For example, the SWFLoader and Image controls emit these events as part of loading a file. You typically use a determinate ProgressBar in this mode. The ProgressBar control only updates if the value of the source property extends the EventDispatcher class. This is the default mode.
You also use this mode if you want to measure progress on multiple loads; for example, if you reload an image, or use the SWFLoader and Image controls to load multiple images.
polled Use the source property to specify a loading process that exposes the bytesLoaded and bytesTotal properties. For example, the SWFLoader and Image controls expose these properties. You typically use a determinate ProgressBar in this mode.
manual Set the maximum, minimum, and indeterminate properties along with calls to the setProgress() method. You typically use an indeterminate ProgressBar in this mode.
eg:
public function initImage():void {
image1.load('../assets/DSC00034.JPG');
}
]]>
width="600" height="600">
width="300"
source="image1"
mode="polled"
label="Loading Image %1 out of %2 bytes, %3%%"
labelWidth="400"
/>
label="Show"
click="initImage();"
/>
height="500" width="600"
autoLoad="false"
visible="true"
/>
Few Properties :
setProgress(value:Number, total:Number):void
Sets the state of the bar to reflect the amount of progress made when using manual mode.
labelPlacement : String -->Placement of the label.
maximum & minimum : Number-->Largest progress value for the ProgressBar and smallest respectivly
Conversion : Number-->Number used to convert incoming current bytes loaded value and the total bytes loaded values.
direction : String-->Direction in which the fill of the ProgressBar expands toward completion.
Indeterminate : Boolean-->Whether the ProgressBar control has a determinate or indeterminate appearance.
percentComplete : Number-->[read-only] Percentage of process that is completed.The range is 0 to 100.
another example :
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
minimum="0" maximum="100"
value="0"
change="pBar.setProgress(sldr.value, sldr.maximum);" />
barSkin="skins.CustomProgressBarSkin"
labelPlacement="center"
mode="manual" />
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" >
override protected function initializationComplete():void {
useChromeColor = true;
super.initializationComplete();
}
]]>
.....................................................................................................................................
81) Write code of creating singlton calss ?
Answer:
public class Singleton {
private static final Singleton instance;
private Singleton(){}
public static Singleton getInstance() {
if (instance == null)
instance = new Singleton();
return instance;
}
}
.....................................................................................................................................
82) What is the root node of event propagation ?
answer: flash.display.Stage -->mx.mangers.SystemManger-->mx.core.Application-->container-->controller
.....................................................................................................................................
83)