ADOBE FLASH LITE 1.x Adobe ActionScript
2010/4/28 Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe Flash Lite 1.x ActionScript This Language Reference is licensed for use under the terms of the Creative Commons Attribution Non-Commercial 3.0 License. This License allows users to copy, distribute, and transmit the user guide for noncommercial purposes only so long as (1) proper attribution to Adobe is given as the owner of the guide; and (2) any reuse or distribution of the guide contains a notice that use of the guide is governed by these terms. The best way to provide notice is to include the following link. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ Adobe, the Adobe logo, ColdFusion, and Flash are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Symbian and all Symbian based marks and logos are trademarks of Symbian Limited. All other trademarks are the property of their respective owners. Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
2010/4/28 iii 1 : Samples................................................................................................... 1......................................................................................................... 1 2 : Flash Lite call()........................................................................................................... 3 chr()............................................................................................................ 4 duplicatemovieclip()............................................................................................. 4 eval ().......................................................................................................... 5 getproperty().................................................................................................... 6 gettimer()...................................................................................................... 6 geturl()........................................................................................................ 7 gotoandplay()................................................................................................... 9 gotoandstop()................................................................................................... 9 ifframeloaded()................................................................................................ 10 int()........................................................................................................... 10 length()........................................................................................................ 11 loadmovie().................................................................................................... 11 loadmovienum()............................................................................................... 12 loadvariables()................................................................................................. 13 loadvariablesnum()............................................................................................. 14 mbchr()........................................................................................................ 15 mblength()..................................................................................................... 15 mbord()....................................................................................................... 16 mbsubstring().................................................................................................. 16 nextframe().................................................................................................... 17 nextscene()..................................................................................................... 17 Number()...................................................................................................... 18 on()........................................................................................................... 18 ord().......................................................................................................... 19 play().......................................................................................................... 20 prevframe().................................................................................................... 20 prevscene().................................................................................................... 21 random()...................................................................................................... 21 removemovieclip()............................................................................................. 22 set()........................................................................................................... 22 setproperty()................................................................................................... 23 stop().......................................................................................................... 24 stopallsounds()................................................................................................. 24
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT iv String()........................................................................................................ 24 substring()..................................................................................................... 25 telltarget()..................................................................................................... 26 togglehighquality()............................................................................................. 26 trace()......................................................................................................... 27 unloadmovie().................................................................................................. 27 unloadmovienum()............................................................................................. 28 3 : Flash Lite / (Forward slash)................................................................................................ 29 _alpha......................................................................................................... 30 _currentframe.................................................................................................. 31 _focusrect...................................................................................................... 31 _framesloaded.................................................................................................. 31 _height........................................................................................................ 32 _highquality.................................................................................................... 32 _level.......................................................................................................... 33 maxscroll...................................................................................................... 33 _name......................................................................................................... 34 _rotation....................................................................................................... 34 scroll.......................................................................................................... 35 _target......................................................................................................... 35 _totalframes.................................................................................................... 35 _visible........................................................................................................ 36 _width......................................................................................................... 36 _x............................................................................................................. 37 _xscale......................................................................................................... 37 _y............................................................................................................. 38 _yscale......................................................................................................... 38 4 : Flash Lite break.......................................................................................................... 40 case........................................................................................................... 41 continue....................................................................................................... 42 do..while....................................................................................................... 43 else............................................................................................................ 44 else if.......................................................................................................... 44 for............................................................................................................ 45 if.............................................................................................................. 46 switch......................................................................................................... 46 while.......................................................................................................... 47
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT v 5 : Flash Lite add (string concatenation)........................................................................................ 50 += (addition assignment)........................................................................................ 51 and............................................................................................................ 52 = (assignment).................................................................................................. 52 /* (block comment).............................................................................................. 53, (comma)...................................................................................................... 53 // (comment)................................................................................................... 54?: (conditional)................................................................................................. 55 (decrement)................................................................................................. 55 / (divide)....................................................................................................... 56 /= (division assignment)......................................................................................... 56. (dot)......................................................................................................... 57 ++ (increment)................................................................................................. 57 && (logical AND)............................................................................................... 58! (logical NOT)................................................................................................. 59 (logical OR)................................................................................................... 60 % (modulo).................................................................................................... 60 %= (modulo assignment)......................................................................................... 61 *= (multiplication assignment).................................................................................... 61 * (multiply)..................................................................................................... 62 + (numeric add)................................................................................................ 63 == (numeric equality)........................................................................................... 63 > (numeric greater than)......................................................................................... 64 >= (numeric greater than or equal to).............................................................................. 64 <> (numeric inequality).......................................................................................... 65 < (numeric less than)............................................................................................ 65 <= (numeric less than or equal to)................................................................................. 66 () (parentheses)................................................................................................. 67 " " (string delimiter)............................................................................................. 67 eq (string equality).............................................................................................. 68 gt (string greater than)........................................................................................... 68 ge (string greater than or equal to)................................................................................ 69 ne (string inequality)............................................................................................ 70 lt (string less than).............................................................................................. 70 le (string less than or equal to).................................................................................... 71 (subtract)..................................................................................................... 72 -= (subtraction assignment)...................................................................................... 72 6 : Flash Lite............................................................................................................ 75 _capcompoundsound........................................................................................... 76
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT vi _capemail...................................................................................................... 76 _caploaddata.................................................................................................. 76 _capmfi....................................................................................................... 77 _capmidi...................................................................................................... 77 _capmms...................................................................................................... 78 _capmp3....................................................................................................... 78 _capsmaf..................................................................................................... 79 _capsms....................................................................................................... 79 _capstreamsound............................................................................................... 80 _cap4waykeyas................................................................................................ 80 $version....................................................................................................... 81 fscommand()................................................................................................... 81 Launch........................................................................................................ 82 fscommand2().................................................................................................. 82 Escape......................................................................................................... 83 FullScreen...................................................................................................... 84 GetBatteryLevel................................................................................................. 84 GetDateDay.................................................................................................... 85 GetDateMonth................................................................................................. 85 GetDateWeekday............................................................................................... 86 GetDateYear................................................................................................... 86 GetDevice..................................................................................................... 87 GetDeviceID................................................................................................... 88 GetFreePlayerMemory........................................................................................... 89 GetLanguage................................................................................................... 89 GetLocaleLongDate............................................................................................. 92 GetLocaleShortDate............................................................................................. 92 GetLocaleTime................................................................................................. 93 GetMaxBatteryLevel............................................................................................. 93 GetMaxSignalLevel.............................................................................................. 94 GetMaxVolumeLevel............................................................................................ 94 GetNetworkConnectStatus....................................................................................... 95 GetNetworkName............................................................................................... 95 GetNetworkRequestStatus........................................................................................ 96 GetNetworkStatus............................................................................................... 97 GetPlatform.................................................................................................... 98 GetPowerSource................................................................................................ 99 GetSignalLevel.................................................................................................. 99 GetTimeHours................................................................................................ 100 GetTimeMinutes............................................................................................... 100 GetTimeSeconds............................................................................................... 101 GetTimeZoneOffset............................................................................................ 101
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT vii GetTotalPlayerMemory......................................................................................... 102 GetVolumeLevel............................................................................................... 102 Quit.......................................................................................................... 103 ResetSoftKeys.................................................................................................. 103 SetInputTextType.............................................................................................. 104 SetQuality..................................................................................................... 104 SetSoftKeys.................................................................................................... 105 StartVibrate................................................................................................... 105 StopVibrate................................................................................................... 106 Unescape..................................................................................................... 106
2010/4/28 1 1 : Adobe Macromedia Flash Lite 1.0 1.1 Flash Lite 1.x ActionScript Flash Lite 1.x ActionScript Adobe Macromedia Flash 4 ActionScript ActionScript Samples ActionScript Flash Lite Flash Lite www.adobe.com/go/learn_flt_samples_and_tutorials_cn ActionScript.zip.zip Samples ActionScript ActionScript ("")
2010/4/28 2 2 : Flash Lite Adobe Macromedia Flash Lite 1.1 ActionScript call() chr() duplicatemovieclip() eval () getproperty() gettimer() geturl() gotoandplay() gotoandstop() ifframeloaded() int() length() loadmovie() loadmovienum() loadvariables() loadvariablesnum() mbchr() mblength() mbord() mbsubstring() nextframe() nextscene() Number() on() ord() play() ASCII SWF SWF URL URL SWF SWF Flash Lite SWF SWF Flash Lite Adobe ColdFusion CGI ASP PHP Perl Flash Lite SWF ColdFusion CGI ASP PHP Perl Flash Lite SWF ASCII 1 ASCII
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 3 prevframe() prevscene() 21 random() removemovieclip() set() setproperty() stop() stopallsounds() String() substring() telltarget() togglehighquality() trace() unloadmovie() unloadmovienum() 1 1 duplicatemovieclip() SWF SWF statement(s) target Flash Lite SWF Flash Lite loadmovie()loadmovienum() duplicatemovieclip() Flash Lite loadmovie()loadmovienum() duplicatemovieclip() call() call(frame) call(movieclipinstance:frame) frame movieclipinstance call() call() call() ActionScript call() ActionScript
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 4 myscript // to execute functions in frame with label "myscript" thisframe = "myscript"; trace ("Calling the script in frame: " add thisframe); // to execute functions in any other frame on the same timeline call("myscript"); chr() chr(number) number ASCII ASCII 65 A myvar myvar = chr(65); trace (myvar);// Output: A duplicatemovieclip() duplicatemovieclip(target, newname, depth) target newname depth
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 5 SWF 1 removemovieclip() duplicatemovieclip() newname originalclip 10 newclip x 100 duplicatemovieclip("originalclip", "newclip", 10); setproperty("newclip", _x, 100); for duplicatemovieclip() clip1 clip2 clip3 for (i = 1; i <= 3; i++) { newname = "clip" add i; duplicatemovieclip("originalclip", newname); removemovieclip() eval () eval(expression) expression expression expression expression undefined eval() eval() "piece" + x piece3eval() y piece3 = "dangerous"; x = 3; y = eval("piece" add x); trace(y);// Output: dangerous.
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 6 name1 = "mike"; name2 = "debbie"; name3 = "logan"; for(i = 1; i <= 3; i++) { trace (eval("name" add i));// Output: mike, debbie, logan getproperty() getproperty(my_mc, property) my_mc property my_mc my_mc (_x) xpos = getproperty("person_mc", _x); trace (xpos); // output: -75 setproperty() gettimer() gettimer() SWF timeelapsed SWF
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 7 timeelapsed = gettimer(); trace (timeelapsed);// Output: milliseconds of time movie has been playing geturl() geturl(url [, window [, "variables"]]) url URL window HTML Flash Lite window _self _blank _parent _top variables GET POST GET URL POST HTTP URL URL URL http://www.myserver.com Flash Lite 1.0 HTTP HTTPS mailto tel Flash Lite 1.1 SMS MMS Flash Lite geturl() geturl() geturl() geturl() ActionScript Flash Lite mobile.example.com myurl = "http://mobile.example.com"; on(keypress "1") { geturl(myurl); GET POST GET URL firstname = "Gus"; lastname = "Richardson"; age = 92; geturl("http://www.example.com", "_blank", "GET");
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 8 ActionScript POST HTTP firstname = "Gus"; lastname = "Richardson"; age = 92; geturl("http://www.example.com", "POST"); address subject body Shift-JIS on (release, keypress "#"){ subject = "email subject"; body = "email body"; geturl("mailto:somebody@anywhere.com", "", "GET"); geturl() on (release, keypress "#"){ geturl("mailto:somebody@anywhere.com?cc=cc@anywhere.com&bcc=bcc@anywhere. com&subject=i am the email subject&body=i am the email body"); URL email+subject email+body email subject email body tel on (release, keypress "#"){ geturl("tel:117"); geturl() SMS mysms = "sms:4156095555?body=sample sms message"; on(keypress "5") { geturl(mysms); geturl() MMS // mms example mymms = "mms:4156095555?body=sample mms message"; on(keypress "6") { geturl(mymms); geturl() // file protocol example filepath = "file://c:/documents/flash/myapp/myvariables.txt"; on(keypress "7") { geturl(filepath);
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 9 gotoandplay() gotoandplay([scene,] frame) scene frame scene gotoandplay() 16 SWF on(keypress "7") { gotoandplay(16); gotoandstop() Flash 1.0 gotoandstop([scene,] frame) scene frame scene gotoandstop() 5 SWF on(keypress "8") { gotoandstop(5);
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 10 ifframeloaded() ifframeloaded([scene,] frame) { statement(s); scene frame statement(s) ifframeloaded SWF _framesloaded SWF _framesloaded ifframeloaded _framesloaded if else ifframeloaded SWF 10 trace() frame number 10 is loaded frame loaded: 10 ifframeloaded(10) { trace ("frame number 10 is loaded"); output = "frame loaded: 10"; _framesloaded int() int(value) value distance mydistance
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 11 distance = 6.04-3.96; //trace ("distance = " add distance add " and rounded to:" add int(distance)); // Output: distance = 2.08 and rounded to: 2 mydistance = "3.8"; //trace ("mydistance = " add int(mydistance)); // Output: 3 length() length(expression) length(variable) expression variable "Hello" length("hello"); 5 email = "someone@example.com"; if (length(email) > 6) { //trace ("email appears to have enough characters to be valid"); loadmovie() loadmovie(url, target [, method]) url SWF URL URL 0 SWF URL http:// file:/// target SWF
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 12 method HTTP GET POST GET URL POST HTTP SWF SWF Flash Lite SWF loadmovienum() loadmovie() SWF SWF SWF SWF SWF unloadmovie() loadmovie() SWF SWF circle.swf mysquare loadmovie("circle.swf", "mysquare"); // Equivalent statement: loadmovie("circle.swf", _level0.mysquare); _level loadmovienum() unloadmovie() unloadmovienum() loadmovienum() loadmovienum(url, level [, method]) url SWF URL URL 0 SWF Flash Lite Flash SWF SWF level Flash Lite SWF method HTTP GET POST GET URL POST HTTP SWF SWF Flash Lite Flash Lite SWF loadmovienum() SWF HTML SWF loadmovie() loadmovienum()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 13 Flash Lite 0 loadmovienum() SWF Flash Lite SWF _leveln SWF N SWF SWF SWF SWF SWF 0 Flash Lite 0 0 SWF SWF unloadmovienum() loadmovienum() SWF SWF 2 loadmovienum("http://www.someserver.com/flash/circle.swf", 2); _level loadmovie() unloadmovienum() loadvariables() loadvariables(url, target [, variables]) url URL SWF Web url SWF target variables HTTP GET POST GET URL POST HTTP ColdFusion CGI Active Server Page (ASP) PHP Perl SWF URL MIME application/x-www-form-urlencoded CGI company=adobe&address=600+townsend&city=san+francisco&zip=94103 loadvariablesnum() loadvariables()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 14 // load variables from text file on local file system (Symbian Series 60) on(release, keypress "1") { filepath = "file://c:/documents/flash/myapp/myvariables.txt"; loadvariables(filepath, _root); // load variables (from server) into a movieclip urlpath = "http://www.someserver.com/myvariables.txt"; loadvariables(urlpath, "myclip_mc"); loadmovienum() loadvariablesnum() unloadmovie() loadvariablesnum() loadvariablesnum(url, level [, variables]) url URL SWF Web url SWF level Flash Lite variables HTTP GET POST GET URL POST HTTP ColdFusion CGI ASP PHP Perl Flash Lite SWF URL MIME application/x-www-form-urlencoded CGI company=adobe&address=600+townsend&city=san+francisco&zip=94103 Flash Lite SWF loadvariablesnum() SWF HTML SWF loadvariables() loadvariablesnum() geturl() loadmovie() loadmovienum() loadvariables()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 15 mbchr() mbchr(number) number ASCII ASCII trace (mbchr(65)); // Output: A trace (mbchr(97)); // Output: a trace (mbchr(36)); // Output: $ mystring = mbchr(51) - mbchr(49); trace ("result = " add mystring);// Output: result = 2 mblength() mbsubstring() mblength() mblength(string) string mystring mystring = mbchr(36) add mbchr(50); trace ("string length = " add mblength(mystring)); // Output: string length = 2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 16 mbchr() mbsubstring() mbord() mbord(character) character mystring mystring = "A"; trace ("ord = " add mbord(mystring));// Output: 65 mystring = "$120"; for (i=1; i<=length(mystring); i++) { char = substring(mystring, i, 1); trace ("char ord = " add mbord(char));// Output: 36, 49, 50, 48 mbchr() mbsubstring() mbsubstring() mbsubstring(value, index, count) value index count
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 17 mystring mystring = mbchr(36) add mbchr(49) add mbchr(50) add mbchr(48); trace (mbsubstring(mystring, 0, 2));// Output: $1 mbchr() nextframe() nextframe() on (release) { nextframe(); prevframe() nextscene() nextscene() 1
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 18 1 on(release) { nextscene(); prevscene() Number() Number(expression) expression expression expression expression expression expression true 1 expression false 0 expression expression 1.57505e- 3 expression undefined -1 mystring mynumber 5 myresult Number() mystring = "55"; mynumber = Number(myString); myresult = mynumber + 5; trace (myresult); // Output: 60 trace (Number(true)); // Output: 1 on()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 19 on(event) { // statement(s) statement(s) event event event ({) event press release rollout rollover keypress "key" 8 mytext maxscroll on (keypress "8") { if (mytext.scroll < mytext.maxscroll) { mytext.scroll++; ord() ord(character) character ASCII ASCII ord() A ASCII trace ("multibyte number = " add ord("a"));// Output: multibyte number = 65
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 20 play() play() if Steve play() Steve SWF alert stop(); if (name == "Steve") { play(); else { alert="you are not Steve!"; prevframe() prevframe() 1 on(release) { prevframe(); nextframe()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 21 prevscene() prevscene() 1 on(release) { prevscene(); nextscene() random() random(value) value 0 value //pick random number between 0 and 5 mynumber = random(5); trace (mynumber); // Output: could be 0,1,2,3,4 //pick random number between 5 and 10 mynumber = random(5) + 5; trace (mynumber); // Output: could be 5,6,7,8,9
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 22 Flash Lite 1.1 // select random name from list mynames1 = "Mike"; mynames2 = "Debbie"; mynames3 = "Logan"; ran = random(3) + 1; ranname = "mynames" add ran; trace (eval(ranname));// Output: will be mike, debbie, or logan removemovieclip() removemovieclip(target) target duplicatemovieclip() duplicatemovieclip() second_mc duplicatemovieclip("person_mc", "second_mc", 1); second_mc:_x = 55; second_mc:_y = 85; removemovieclip("second_mc"); duplicatemovieclip() set() set(variable, expression) variable expression expression
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 23 variable SWF SWF true false SWF orig_x_pos ship x SWF on(release) { set("orig_x_pos", getproperty("ship", _x)); on(release) { orig_x_pos = ship._x; setproperty() setproperty(target, property, value/expression) target property value expression star _alpha 30% on(release) { setproperty("star", _alpha, "30"); getproperty()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 24 stop() stop() SWF stop() on(release) { stop(); stopallsounds() stopallsounds() SWF SWF on(release) { stopallsounds(); String()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 25 String(expression) expression expression expression expression expression true false expression (/) birthyearnum 1976 String() eq 1976 birthyearnum = 1976; birthyearstr = String(birthYearNum); if (birthyearstr eq "1976") { trace ("birthyears match"); substring() substring(string, index, count) string index count 1 String 0 Hello World origstring = "Hello World!"; newstring = substring(origstring, 0, 5); trace (newstring);// Output: Hello
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 26 telltarget() telltarget(target) { statement(s); target statement(s) true statement(s) target telltarget() telltarget() telltarget() telltarget() ball ball 1 stop() 5 telltarget() ball 2 on(keypress "5") { telltarget("ball") { gotoandplay(2); togglehighquality() togglehighquality() Flash Lite SWF Flash Lite SWF
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 27 on(release) { togglehighquality(); trace() trace(expression) expression Flash SWF expression SWF expression trace() JavaScript alert trace() SWF trace() while i = 0; while (i++ < 5){ trace("this is execution " add i); unloadmovie() unloadmovie(target) target Flash Lite loadmovie() loadmovienum() duplicatemovieclip() 3 draggable_mc movie.swf 4
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 28 on (keypress "3") { unloadmovie ("/draggable_mc"); loadmovienum("movie.swf", 4); 3 4 on (keypress "3") { unloadmovienum(4); loadmovie() unloadmovienum() unloadmovienum(level) level (_leveln) Flash Lite loadmovie() loadmovienum() duplicatemovieclip() Flash Lite SWF unloadmovienum() SWF HTML SWF loadmovienum()
2010/4/28 29 3 : Flash Lite Adobe Macromedia Flash Lite 1.x / (Forward slash) _alpha _currentframe _focusrect _framesloaded _height _highquality _level maxscroll _name _rotation scroll _target _totalframes _visible _width _x _xscale _y _yscale alpha SWF SWF _leveln _level SWF loadmovienum() SWF Flash Player _leveln N. SWF scroll Flash Lite x (percentage) y (percentage) / (Forward slash) Flash Lite 1.0
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 30 / /targetpath /:varname Macromedia Flash 5 _root (:) (/) 1 car /:car 2 mc1 car /mc1/:car 3 mc1 mc2 car /mc1/mc2/:car 4 mc2 car mc2/:car _alpha my_mc:_alpha my_mc alpha 0 100 _alpha 0 _alpha 0 my_mc _alpha 30% on(release) { telltarget("my_mc") { _alpha = 30;
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 31 _currentframe my_mc:_currentframe my_mc _currentframe gotoandstop() my_mc 5 telltarget("my_mc") { gotoandstop(_currentframe + 5); gotoandstop() _focusrect _focusrect = Boolean; SWF true false _focusrect = false; _framesloaded my_mc:_framesloaded
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 32 SWF SWF SWF SWF _framesloaded SWF loader _xscale if (_framesloaded >= _totalframes) { gotoandplay ("Scene 1", "start"); else { telltarget("loader") { _xscale = (_framesloaded/_totalframes)*100; _height my_mc:_height on(release) { telltarget("my_mc") { _height = 200; _highquality _highquality SWF 2 1 0
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 33 SWF _highquality = 1; togglehighquality() _level _leveln _leveln _level SWF loadmovienum() SWF Flash Player _leveln N SWF Flash Lite SWF _level0 _level0 SWF SWF SWF _level0 SWF loadmovienum() Flash Lite SWF _level0 SWF SWF SWF SWF 1 SWF 6 loadmovienum("myswf.swf", 1); // at least 1 frame later telltarget(_level1) { gotoandstop(6); loadmovie() maxscroll Flash Lite 1.1 variable_name:maxscroll
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 34 maxscroll scroll 8 mytext maxscroll on(keypress "8") { if (mytext:scroll < mytext:maxscroll) { mytext:scroll++; scroll _name my_mc:_name my_mc bigrose trace(bigrose:_name); _rotation my_mc:_rotation 0 180 0-180 360 my_mc:_rotation = 450 my_mc:_rotation = 90 2 my_mc 15
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 35 on (keypress "2") { my_mc:_rotation += 15; scroll textfieldvariablename:scroll scroll Flash Lite scroll 2 mytext on(keypress "2") { if (mytext:scroll > 1) { mytext:scroll--; maxscroll _target my_mc:_target my_mc _totalframes my_mc:_totalframes
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 36 my_mc myswf.swf 1 25 loadmovienum("myswf.swf", 1); // 25 frames later in the main timeline if (_level1._framesloaded >= _level1._totalframes) { telltarget("_level1/") { gotoandstop("mylabel"); else { // loop... _visible my_mc:_visible my_mc _visible false _visible false 3 my_mc 4 on(keypress "3") { my_mc:_visible = 0; on(keypress "4") { my_mc:_visible = 1; _width my_mc:_width
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 37 5 width on(keypress "5") { my_mc:_width = 10; _x my_mc:_x my_mc x (0,0) 90 90 6 my_mc on(keypress "6") { my_mc:_x = 10; _xscale, _y, _yscale _xscale my_mc:_xscale (percentage) (0,0) _x _y 50% _x 100% 7 my_mc
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 38 on(keypress "7") { my_mc:_xscale = 10; _x, _y, _yscale _y my_mc:_y my_mc y (0,0) 90 90 1 my_mcy y (0,0) 10 on(keypress "1") { my_mc:_y = 10; _x, _xscale, _yscale _yscale my_mc:_yscale (percentage) (0,0) _x _y 50% _y 100% 1 my_mc 10%
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 39 on(keypress "1") { my_mc:_yscale = 10; _x, _xscale, _y
2010/4/28 40 4 : Flash Lite Adobe Macromedia Flash Lite 1.x ActionScript break case continue do..while else else if for if switch while Flash Lite switch case expression switch expression statements true if false if false init condition true statement SWF true Flash Lite curly braces ({) false Flash Lite if switch true true break break for do..while while switch break Flash Lite break ActionScript case switch break
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 41 i = 0; while (true) { if (i >= 100) { i++; case do..while for switch while case case expression: statements expression statements switch case expression switch expression statements switch case mynum 1 case 1 trace() mynum 2 case 2 trace() number case default trace() switch (mynum) { case 1: trace ("case 1 tested true"); case 2: trace ("case 2 tested true"); case 3: trace ("case 3 tested true"); default: trace ("no case tested true") case break 1 A B
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 42 switch (mynum) { case 1: trace ("A"); case 2: trace ("B"); default: trace ("D") switch continue continue while continue Flash do..while continue Flash for continue Flash for while continue Flash Lite i = 0; while (i < 10) { if (i % 3 == 0) { i++; continue; trace(i); i++; do..while continue Flash Lite
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 43 i = 0; do { if (i % 3 == 0) { i++; continue; trace(i); i++; while (i < 10); for continue Flash Lite i 3 0 trace(i) for (i = 0; i < 10; i++) { if (i % 3 == 0) { continue; trace(i); do..while for while do..while do { statement(s) while (condition) statement(s) condition true statement(s) condition true 10 i = 0; do { //trace (i); // output: 0,1,2,3,4,5,6,7,8,9 i++; while (i<10); break continue for while
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 44 else if (condition){ t-statement(s); else { f-statement(s); condition true false t-statement(s) true f-statement(s) false if false else currenthighestdepth = 1; if (currenthighestdepth == 2) { //trace ("currenthighestdepth is 2"); else { //trace ("currenthightestdepth is not 2"); if else if if (condition){ statement(s); else if (condition){ statement(s); condition true false statement(s) if false
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 45 if false else if true Flash else if curly braces ({) else if false Flash elseif else if person_mc.xpos = 100; leftbound = 0; rightbound = 100; if (person_mc.xpos <= leftbound) { //trace ("Clip is to the far left"); else if (person_mc.xpos >= rightbound) { //trace ("Clip is to the far right"); else { //trace ("Your clip is somewhere in between"); if for for (init; condition; next) { statement(s); init condition true false false next (++) (--) statement(s) init condition true statement for for..in _x _y for 1 100 sum = 0; for (i = 1; i <= 100; i++) { sum = sum + i;
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 46 ++ (increment) (decrement)-- do..while while if if (condition) { statement(s); condition true false statement(s) true SWF true Flash Lite curly braces ({) false Flash Lite if name "Erica" play() if(name eq "Erica"){ play(); switch switch (expression){ caseclause: [defaultclause:] expression caseclause switch expression case defaultclause switch expression case defaul ActionScript if switch true
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 47 Switch default true default mynum 1 case 1 trace() mynum 2 case 2 trace() number case default trace() switch (mynum) { case 1: trace ("case 1 tested true"); case 2: trace ("case 2 tested true"); case 3: trace ("case 3 tested true"); default: trace ("no case tested true") case break 1 A B switch (mynum) { case 1: trace ("A"); case 2: trace ("B"); default: trace ("D") case while while(condition) { statement(s); condition while statement(s) true true
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 48 true false while true while 1 4 1 condition 2 condition true true 3 while while 3 statement(s) 4 1 i 10 i = 0; while(i < 10) { trace ("i = " add ++i);// Output: 1,2,3,4,5,6,7,8,9 continue do..while for
2010/4/28 49 5 : Flash Lite Adobe Macromedia Flash Lite 1.x ActionScript add (string concatenation) += (addition assignment) expression1+ expression2 expression1 and logical AND = (assignment) expression2 expression1 /* (block comment) (/*) (*/) ActionScript, (comma) expression1 expression2 expression2 // (comment) (//) ActionScript?: (conditional) Flash Lite expression1 expression1 true expression2 expression3 (decrement) expression 1 (--expression) expression 1 (expression--) expression 1 expression 1 / (divide) expression1 expression2 /= (division assignment) expression1 / expression2 expression1. (dot) ++ (increment) expression 1 (++expression) expression 1 (expression++) expression 1 expression 1 && (logical AND) expression1 false false expression1 true expression2 expression2 true true false! (logical NOT) expression true!expression false x && y false!(x && y) true (logical OR) expression1 expression2 true true false false OR true true % (modulo) expression1 expression2 expression modulo %= (modulo assignment) expression1 % expression2 expression1
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 50 *= (multiplication assignment) expression1 * expression2 expression1 * (multiply) + (numeric add) == (numeric equality) expression1 expression2 true > (numeric greater than) expression1 expression2 true expression1 expression2 false >= (numeric greater than or equal to) expression1 expression2(true) expression1 expression2(false) <> (numeric inequality) expression1 expression2 false < (numeric less than) expression1 expression2 true expression1 expression2 false <= (numeric less than or equal to) expression1 expression2 true false () (parentheses) " " (string delimiter) ActionScript eq (string equality) gt (string greater than) ge (string greater than or equal to) ne (string inequality) lt (string less than) le (string less than or equal to) expression1 expression2 true false expression1 expression2 expression1 expression2 true false expression1 expression2 expression1 expression2 true false expression1 expression2 expression1 expression2 true false expression1 expression2 expression1 expression2 true false expression1 expression2 expression1 expression2 true false (subtract) -= (subtraction assignment) expression1 - expression2 expression1 add (string concatenation) string1 add string2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 51 string1, string2 catalog constr = "cat" add "alog"; trace (constr);// output: catalog + (numeric add) += (addition assignment) expression1 += expression2 expression1, expression2 (arithmetic compound assignment) expression1 + expression2 expression1 x += y; x = x + y; addition (+) addition assignment (+=) addition assignment (+=) x y x = 5; y = 10; x += y; trace(x);// output: 15 + (numeric add)
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 52 and condition1 and condition2 condition1, condition2 true false logical AND and turns score 3 75 You Win the Game! turns = 2; score = 77; winner = (turns <= 3) and (score >= 75); if (winner) { trace("you Win the Game!"); else { trace("try Again!"); // output: You Win the Game! && (logical AND) = (assignment) expression1 = expression2 expression1 expression2 expression2 expression1 assignment (=) weight
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 53 weight = 5; assignment (=) greeting greeting = "Hello, " and personname; /* (block comment) Flash Lite 1.0 /* comment */ /* comment comment */ comment (/*) (*/) ActionScript //(comment delimiter) /* comment delimiter comment delimiter (*/) (/*) (/*) (*/) // (comment), (comma) expression1, expression2 expression1, expression2 expression1 expression2 expression2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 54 comma (,) parentheses () parentheses () comma v = 0; v = 4, 5, 6; trace(v); // output: 4 comma (,) parentheses () comma parentheses () v = 0; v = (4, 5, 6); trace(v); // output: 6 comma (,) parentheses () comma z++ z 1 v = 0; z = 0; v = v + 4, z++, v + 6; trace(v); // output: 4 trace(z); // output: 1 parentheses () comma (,) parentheses () v = 0; z = 0; v = (v + 4, z++, v + 6); trace(v); // output: 6 trace(z); // output: 1 for () (parentheses) // (comment) Flash Lite 1.0 // comment comment comment delimiter (//) ActionScript
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 55 // Record the X position of the ball movie clip. ballx = ball._x; // Record the Y position of the ball movie clip. bally = ball._y; // Record the X position of the bat movie clip. batx = bat._x; // Record the Y position of the bat movie clip. baty = bat._y; /* (block comment)?: (conditional) expression1? expression2 : expression3 expression1 x < 5 expression2 expression3 Flash Lite expression1 expression1 true expression2 expression3 x z expression1 true x = 5; y = 10; z = (x < 6)? x: y; trace (z);// output: 5 (decrement) expression expression
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 56 expression 1 (--expression) expression 1 (expression--) expression 1 expression 1 awidth 2 (awidth - 1 = 2) bwidth awidth = 3; bwidth = --awidth; // The bwidth value is equal to 2. awidth 2 (awidth - 1 = 2) awidth bwidth awidth = 3; bwidth = awidth--; // The bwidth value is equal to 3. / (divide) expression1 / expression2 expression1, expression2 expression1 expression2 22.0 7.0 trace(22.0 / 7.0); 3.1429 /= (division assignment) expression1 /= expression2 expression1, expression2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 57 expression1/expression2 expression1 x /= y x = x / y /= x = 10; y = 2; x /= y; // The expression x now contains the value 5.. (dot) instancename.variable instancename.childinstance.variable instancename childinstance person_mc haircolor person_mc.haircolor /person_mc:haircolor / (Forward slash) ++ (increment)
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 58 ++expression expression++ expression 1 (++expression) expression 1 (expression++) expression 1 expression 1 ++ while i = 0; while (i++ < 5){ trace("this is execution " + i); ++ a = ""; i = 0; while (i < 10) { a = a add (++i) add ","; trace(a);// output: 1,2,3,4,5,6,7,8,9,10, 1,2,3,4,5,6,7,8,9,10, ++ a = ""; i = 0; while (i < 10) { a = a add (i++) add ","; trace(a);// output: 0,1,2,3,4,5,6,7,8,9, 0,1,2,3,4,5,6,7,8,9, && (logical AND) expression1 && expression2 expression1, expression2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 59 expression1 false false expression1 true expression2 expression2 true true false && turns score 3 75 You Win the Game! turns = 2; score = 77; winner = (turns <= 3) && (score >= 75); if (winner) { trace("you Win the Game!"); else { trace("try Again!"); x xpos = 50; if (xpos >= 20 && xpos <= 80) { trace ("the xpos is in between 20 and 80");! (logical NOT)!expression expression true!expression false x && y false!(x && y) true!!true false!false true happy false if!happy true trace()
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 60 happy = false; if (!happy) { trace("don't worry, be happy"); (logical OR) expression1 expression2 expression1, expression2 expression1 expression2 true true false false logical OR true true logical OR Flash Lite true true 1 if true true theminimum = 10; themaximum = 250; start = false; if (theminimum > 25 themaximum > 200 start){ trace("the logical OR test passed"); % (modulo) expression1 % expression2 expression1, expression2 expression1 expression2 expression modulo
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 61 Flash Lite 1.0 1.1 Flash SWF % expression1 - int(expression1/expression2) * expression2 modulo Flash Player modulo (%) trace (12 % 5);// output: 2 trace (4.3 % 2.1);// output: 0.0999... %= (modulo assignment) expression1 %= expression2 expression1, expression2 expression1% expression2 expression1 x %= y x = x % y 4 x x = 14; y = 5; trace(x %= y);// output: 4 % (modulo) *= (multiplication assignment) expression1 *= expression2 expression1, expression2
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 62 expression1 * expression2 expression1 x *= y x = x * y 1 50 x x = 5; y = 10; trace (x *= y);// output: 50 2 (=) x y i = 5; x = 4-6; y = i + 2; trace(x *= y);// output: -14 * (multiply) expression1 * expression2 expression1, expression2 1 2 3 2 * 3 6 2 2.0 3.1416 2.0 * 3.1416 6.2832
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 63 + (numeric add) expression1 + expression2 expression1, expression2 + 2 3 5 trace (2 + 3); 2.5 3.25 5.75 trace (2.5 + 3.25); add (string concatenation) == (numeric equality) expression1 == expression2 expression1, expression2 <> expression1 expression2 true <> equal true false
2010/4/28 FLASH LITE 1.X ACTIONSCRIPT Flash Lite 64 trees = 7; bushes = "7"; shrubs = "seven"; trace (trees == "7");// output: 1(true) trace (trees == bushes);// output: 1(true) trace (trees == shrubs);// output: 0(false) eq (string equality) > (numeric greater than) expression1 > expression2 expression1, expression2 expression1 expression2 true expression1 expression2 false true false trace(3.14 > 2);// output: 1(true) trace(1 > 2);// output: 0(false) gt (string greater than) >= (numeric greater than or equal to) expression1 >= expression2 expression1, expression2