Sei sulla pagina 1di 17

Actionscript 3.

0 for Flash Development

Advantages of Flash
Interactive content

Fairly simple to create

Universal ease of use & compatibility

Flash Penetration

Flash Client Runtime Environments


Flash Player ( for Web browsers) Adobe AIR (Adobe Integrated Runtime for desktop applications ) Flash Lite ( for mobile phones)

Flash Player Runtime

OOP in ActionScript 3
Objects are its fundamental building blocks. ActionScript program as a group of objects that carry out tasks, respond to events, and communicate with one another. Characteristics that any object can include
Properties Methods Events, Event Handlers, Event Listeners

Functions
public function myFunc(arg1:Number) : Boolean
{ }

NoteAS3 does not support function overloading!

Components in FLASH and AS3


allow you to easily and quickly build robust applications with a consistent appearance and behaviour User Interface Components Video Components FLV playback 2.5 Customized components list of Flash Component (partial)

Scroll Pane UILoader

Slider UIScrollBar

Event Handling in AS3


there are three important elements: The event source: Which object is the one the event is going to happen to? The event: What is the thing that is going to happen, the thing that you want to respond to? The response: What step(s) you want to be performed when the event happens?

Event Flow in AS3

Animation packages
fl.motion flash.geom flash.display

External API - (1)


Calling external code from ActionScript
var param1:uint = 3; var param2:uint = 7; var result:uint = ExternalInterface.call("addNumbers", param1, param2); <script language="JavaScript"> // adds two numbers, and sends the result back to ActionScript function addNumbers(num1, num2) { return (num1 + num2); } </script>

External API - (2)


Calling ActionScript code from the container
Registering ActionScript function function callMe(name:String):String { return "busy signal"; } ExternalInterface.addCallback("myFunction", callMe); <script language="JavaScript"> // callResult gets the value "busy signal" var callResult = flashObject.myFunction("my name"); </script>... <object id="flashObject"...> ... <embed name="flashObject".../> </object>

Document Viewer
Any format is converted to PDF, which is then converted to SWF by pdf2swf utility. pdf2swf -T9 -t -p<page-range> <pdf-doc> -o <swf> Viewer itself a flash application can load SWF format (using Loader API ) where each page of document is considered as one frame of movie clip. Navigate to different pages <MovieClip_object>.gotoAndStop(<frame index>) prevFrame(), nextFrame() Zooming Scaling the bitmap graphics

Document Viewer Limitations


Slow loading of documents (swf movie clip)
Single SWF is used for whole document Solution
Using per page SWF or, Converting pdf into multiple N-frame SWFs

Scrolling isn t smooth Zooming Searching , highlighting, and annotations not implemented

Resources
Flash Developer Center
http://www.adobe.com/devnet/flash/

Actionscript 3.0 Language Reference


http://help.adobe.com/en_US/FlashPlatform/reference/actionscr ipt/3/index.html

PDF2SWF
http://www.swftools.org/download

Graphics in Flash
Flash supports Vector and Raster (Bitmap) graphics
Bitmaps are made to be displayed at fixed sizes Vector graphics are size independent
- Ideal for animations.

Potrebbero piacerti anche