PYTHON  
 
  Oracle Forms & PL/SQ  
 
  ROR  
 
  Java  
 
  php  
 
  ask us  
 
  home  
 

 

Web Technologies






ActionScript and Flash
 

ActionScript3 and Flex Builder 3



1. Introduction


ActionScript language allows creating animations, interactive and dynamic web applications. Like Javascript, ActionScript is a scripting language following ECMAScript specifications. Its related platform is Flash Player. It was first developed by Macromedia which became Adobe Since 2005. The version Actionscript 1.0 (AS 1.0) works with Flash MX; Actionscript 2.0 (AS 2.0) works with Flash MX2004; and Actionscript 3 works with Flex. Actionscript needs Adobe Flash Player to show the file.swf generated when we compile (or run) Actionscript.(Flash Player and Flash Reader are totally free). In this tutorial, we will use Actionscript 3 working with Flex builder 3.


2. Installing Adobe Flex Builder 3:

Go to: www.adobe.com
   
, and download the 
60-day trial : Flex Builder 3 Professional. 
Get FB3_win.exe. 
Double_click on it and follow the instructions.

This installtion gives two programming ways:
1. In the Flex platform, build a project, set and run mxml applications. In the directory: C:\Program Files\Adobe\Flex Builder 3, make FlexBuilder.exe as a shortcut in the desktop, in order to be called easily. Open Flex and start the project.
2. The other way is to write an Actionscript program, save at as file.as, and compile it using "mxmlc.exe". This compiler is located in the directory: C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\bin Add C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\bin in the path (start, setting,control pannel, system, advanced, environment variable) Make a working director, say : C:\FLASH In this working directoy, write a code, save it as file.as and compile as: C:\FLASH> mxmlc file.as If the code is correct, that is the compilation is done, we get: C:\FLASH\file.swf (xxxx bytes). That is the file.wsf is generated and stored in the sane working directoory. This file.wsf can be seen in the Builder environement(just by double clicking on it), or opened in the browser.
In fact, the real compiler is the Java compiler that comes with Builder 3 software, and located in the directory: C:\Program Files\Adobe\Flex Builder 3\jre\bin. Actionscript programming is an OOP(Oriented Object Programming). Its style is one of the Java. Sometimes, it seems that we are programming applets (compiled by "javac" and viewed by "appletviwer" or by a browser where the bycode file.class is embedded in an html page as <applet code=file.class></applet>). With Actionscript, we compile with mxmlc, and we get the file.wsf viwed in a browser or the Flex platform.

3. Examples


Example 1:

package { import flash.display.Sprite; import flash.text.TextField; public class Regards extends Sprite { public function Regards() { var display_txt:TextField = new TextField(); display_txt.text = "Regards .."; addChild(display_txt); } } }
The execution gives: C:\FLASH>mxmlc Regards.as Loading configuration file C:\Program Files\Adobe\ Flex Builder 3\sdks\3.1.0\frameworks\flex-config.xml C:\FLASH\Regards.swf (616 bytes) The output is shown below, In the Mozilla Firefox browser and in Flash Player 9 platform:  

Example 2: Drawing cirles

package {//package of classes import flash.display.Sprite; import flash.display.Shape; import flash.display.Graphics; public class Circles extends Sprite { //Constructor: public function Circles() { colored_circle(graphics, 0x4169E1); //New circle called child: circ var circ:Shape = new Shape(); colored_circle(circ.graphics, 0xFFE4E1); //Its position relatively to the first one: circ.x = 150; circ.y = 20; addChild(circ); } //Define a fuction with two arguments of type Graphics and int: private function colored_circle(target:Graphics, color:int):void { target.lineStyle(1, 0x0000cd); //(border-width, color-width), here: blue //Fill in the circle with the chosen color 0x0000cd target.beginFill(color); //Draw the related circle (x-position, y-position, radius): target.drawCircle(200, 200, 100); } } }
Let's compile this program: C:\FLASH>mxmlc Circles.as Loading configuration file C:\Program Files\Adobe\ Flex Builder 3\sdks\3.1.0\frameworks\flex-config.xml C:\FLASH\Circles.swf (751 bytes) The output is shown below in Flash Player 9 platform:
We can insert the following code: <object <object data ="Binaries.swf" type="application/x-shockwave-flash" width="200" height="100"> <param name="Binaries" value="Binaries.swf"> </object> So the generated Circles.swf will appear within the same current page:


 
  
Google
Web
ScientificSentence
 



chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2011. All rights reserved.