Information AboutActionscript |
|
HISTORY in Macromedia Flash MX Professional 2004 in Mac OS X 10.2 . The code creates a customizable animation similar to the one seen during the boot process of Mac OS X.]] ActionScript first appeared in its current syntax with the release of Flash 5, which was the first thoroughly programmable version of Flash. This ActionScript release was named ActionScript 1.0. Flash 6 (MX) then further broadened the utility of the programming environment by adding a number of built-in functions and allowing better programmatic control of Movie elements. Flash 7 (MX 2004) introduced ActionScript 2.0, which added Strong Typing and Class-based Programming features such as explicit Class declarations, Inheritance , Interfaces , and Strict Data Typing. ActionScript 1.0 and 2.0 share the same compiled form within Flash SWF s (Shock'''w'''ave '''F'''lash files). Timeline
THE LANGUAGE Syntax In ActionScript 2.0 there can be classes, and also, a library item (a movie clip) can be associated with a class. Classes are always written in external text files, and these files must have the .as extension. Classes are extensions to the ActionScript language which the programmer can write himself, though there are many built-in classes such as the '''MovieClip''' class, which can be used to draw vectors onto the screen dynamically. Class files can be used to make your programming easier, and the class files can be transferred between many projects if needed. Features of the Flash ActionScript implementation that JavaScript programmers may find interesting:
ActionScript code is frequently written directly in the Flash authoring environment, which offers reference, code hints and syntax highlighting. Often, the source code is saved along with the rest of the movie in a .fla file. It is also common for ActionScript code to be imported from external text files via #include statements. In this case, the external files may be compiled with the built-in compiler in the Flash IDE or with Motion Twin ActionScript2 Compiler (MTASC). See External Links . Criticism
EXAMPLES ActionScript 2.0 Examples The following prints Hello World . Note this will only work when run inside the Flash IDE , as the trace function is only supported inside it. trace("Hello world!"); The following code outputs the current mouse position when the mouse moves, by using the onMouseMove event. Again this will only work in the Flash IDE. onMouseMove = function () { trace("X: "+_root._xmouse); trace("Y: "+_root._ymouse); }; This more advanced example creates an array containing numbers and strings, and assigns a number to a variable called num and a string to a variable called str using prototype functions and function recursion. Then, using the MovieClip API, a text field is drawn on screen, into which the variable values are written.var my_Array:Array = new Array("Hello", "ActionScript", 3, 7, 11, "Flash"); Array.prototype.pickNumber = function():Number { var rand:Number = random(this.length); return (typeof (this == "number") ? this[rand : this.pickNumber(); }; Array.prototype.pickString = function():String { var rand:Number = random(this.length); return (typeof (this == "string") ? this[rand : this.pickString(); }; var num:Number = my_Array.pickNumber(); var str:String = my_Array.pickString(); _root.createTextField("txt", 1, 10, 10, 530, 390); txt.text = "Array = "+my_Array+" Random Number = "+num+" Random String = "+str; ActionScript 3.0 Examples This advanced Hello World program currently needs to be compiled using the Flex 2.0 Public Beta IDE. package { import flash.display.TextField; import flash.display.MovieClip; import flash.filters.DropShadowFilter; public class HelloWorld extends MovieClip { public function HelloWorld() { var shad:DropShadowFilter = new DropShadowFilter(2, 45, 0x000000, 25, 3, 3, 2, 2); var txt:TextField = new TextField(); txt.textColor = 0xFFFFFF; txt.filters = {Link without Title} ; txt.width = 120;
txt.selectable = false; txt.text = "Hello World! {Link without Title} "; addChild(txt); } } } EXTERNAL LINKS Technical
Tutorials
Resources
|
|
|