Flex and ActionScript

Flex and ActionScript
What is Flex?
• Adobe Flex is a rich Internet application
framework built on top of the Flash platform
• Applications are built using MXML and
ActionScript
• Applications are compiled into SWF (Flash) files
• Whether written in MXML or ActionScript, all
Flex components are classes.
• At compile time, MXML is precompiled to
ActionScript classes, which are then compiled
into the swf file format.
ActionScript
•
•
•
•
•
•
•
Object-Oriented Programming Language
Encapsulation
Abstraction
Inheritance
Polymorphism
Reusability
Similar to JavaScript
Properties
• Each class has pre-defined set of properties
• Example: Camera properties include bandwidth,
height, width
mycam=new Camera();//creates new object
mycam.height=20;//setting value of property
• You can define and change the properties of
each object (instance) of a Class through
ActionScript
Methods
• An action that is performed by an object
• Example: Camera class has getCamera
method
• Calling a method
mycam=new camera();//create an object
mycam.getCamera(); //calling method
Events
• Events are actions that occur in response to user’s
interaction
• The technique for specifying certain actions that should
be performed in response to particular events is known
as event handling
• Example
function eventResponse(event:MouseEvent):void
{
// Actions performed in response to the event go here
}
myButton.addEventListener(MouseEvent.CLICK,
eventResponse);
Functions
• Defining a function
function functionName(){
Statement1;
Statement2;
}
• Invoking a function
functionName();
Flash Media Server and
ActionScript
•
•
•
•
Client-side ActionScript compiled to swf
Web Server plays swf
Server-side ActionScript code is invoked
Sever loads application
Client-side and server-side objects
Connection Flow
Calling client-side function from
server-side code
Calling server-side function from
client-side code
Client-side calls on the left invoke
server-side calls on the right
Server-side calls on the left invoke
client-side calls on the right