Actionscript 3
Total Page:16
File Type:pdf, Size:1020Kb
ActionScript 3 #actionscrip t-3 1 1: ActionScript 3 2 2 2 Actionscript 3 "ActionScript 3.0" . 2 Examples 2 2 3 3 Apache Flex 4 mxmlc Flex Flash 5 "Hello World" 5 2: " 1009 : null ." 7 7 7 Examples 7 . 7 7 7 7 7 7 8 3: 9 Examples 9 " " 9 9 10 10 11 4: 13 13 Examples 13 + 13 : 13 : ( ) 13 : 13 : 18 5: 19 Examples 19 19 19 19 19 19 20 . 20 6: 21 Examples 21 12 Ante meridiem (AM) Post meridiem (PM) 21 21 21 21 21 7: 22 22 Examples 22 . 22 8: 24 Examples 24 0 1 24 24 () 24 24 25 ( ) 25 " " 25 26 26 26 9: 28 Examples 28 28 28 10: 30 Examples 30 30 NetStatusEvent 30 11: 32 Examples 32 32 32 33 12: 34 34 Examples 34 () 34 : 34 13: 36 36 Examples 36 36 36 37 14: 38 Examples 38 38 38 HTTP (GET, POST, PUT ) 38 null, "" ? 38 39 15: 40 Examples 40 40 40 for 40 40 41 41 16: 43 Examples 43 43 43 X 43 43 44 17: 45 45 Examples 45 45 18: 46 46 Examples 46 / SWF 46 FileStream (AIR ) 47 19: 48 Examples 48 48 48 48 49 49 51 20: 53 53 Examples 53 53 53 54 54 55 21: 56 Examples 56 IDataInput ByteArray . 56 22: 57 Examples 57 57 58 58 23: 61 Examples 61 MovieClip 61 24: 62 62 62 Examples 62 62 Z- / 62 63 64 Adobe Animate / Flash Professional 64 64 64 64 25: 66 66 Examples 66 66 69 72 You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: actionscript-3 It is an unofficial and free ActionScript 3 ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official ActionScript 3. The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners. Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected] https://riptutorial.com/ko/home 1 1: ActionScript 3 ActionScript 3 Adobe Flash Player Adobe AIR . (Windows / Mac) (iOS / Android) ECMAScript . Adobe : http://www.adobe.com/devnet/actionscript/learning.html : https://en.wikipedia.org/wiki/ActionScript : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package-detail.html Actionscript 3 "ActionScript 3.0" . Flash Player 2006-06- 9.x 22 Flash Player Vector.<T> , flash.filters.ShaderFilter Adobe Pixel Bender 2008-10- 10.0 CPU . 15 Flash Player 2010-06- flash.events.TouchEvent . 10.1 10 Flash Player 2011-02- flash.media.StageVideo AS3 . 10.2 08 Flash Player 2011-10- NetStream H.264 . SecureSocket Flash SSL / TLS . 11 04 Flash Player 2012-08- flash.system.Worker . 11.4 10 Flash Player 2013-05- Adobe Pixel Bender (JIT ) PB . 11.8 09 Examples ActionScript 3 Adobe AIR SDK Apache Flex SDK Adobe Animate CC ( Flash Professional ) . Adobe Animate CC AS3 . AS3 . AIR SDK Flex SDK IDE . Adobe Animate CC AS3 IDE . IDE . • Flash Builder (Adobe - Eclipse ) https://riptutorial.com/ko/home 2 • IntelliJ IDEA (Jetbrains ) • FlashDevelop • FDT ( ) "Hello, World" . import flash.display.Sprite; public class Main extends Sprite { public function Main() { super(); trace("Hello, World"); } } FlashDevelop 2005 IDE. AS3 . FlashDevelop , 1. 2. FlashDevelop . App Man SDK . https://riptutorial.com/ko/home 3 AppMan '' ' ' . '' AIR SDK + ACS 2.0 ( '') Flash Player (SA) ( ) . 3. SDK hello world . 4. AIR AS3 Projector / . 5. ( ' ') src Main.as . 6. Main.as Hello World . 7. F5 Ctrl+Enter Ctrl+Enter . ( ). FlashDevelop Hello World . FlashDevelop AS3 ! Apache Flex http://flex.apache.org/doc-getstarted.html https://riptutorial.com/ko/home 4 1. SDK 2. SDK . • Mac /Applications/Adobe Flash Builder 4.7/sdks/4.14.0/ • PC C:\Program Files(x86)\Adobe Flash Builder 4.7\sdks\4.14.0 4.14.0 . SDK IDE : • Flash Builder • IntelliJ IDEA • FlashDevelop • FDT mxmlc Flex Flash Flex ( mxmlc ) Flex SDK . AS3 . DisplayObject . mxmlc -source-path="." -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as" Flash (Flex ) Flash (Adobe Animate IDE ). mxmlc -source-path="." -library-path+="/Applications/Adobe Animate CC 2015.2/Adobe Animate CC 2015.2.app/Contents/Common/Configuration/ActionScript 3.0/libs" -static-link-runtime-shared- libraries=true -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as" Windows : mxmlc -source-path="." -library-path+="C:\Program Files\Adobe\Adobe Animate CC 2015.2\Common\Configuration\ActionScript 3.0\libs" -static-link-runtime-shared-libraries=true -default-size [width in pixels] [height in pixels] -default-frame-rate [fps] -o "outputPath.swf" "mainClass.as" "Hello World" package { import flash.text.TextField; import flash.display.Sprite; public class TextHello extends Sprite { public function TextHello() { var tf:TextField = new TextField(); tf.text = "Hello World!" tf.x = 50; tf.y = 40; addChild(tf); https://riptutorial.com/ko/home 5 } } } TextField . ActionScript 3 : https://riptutorial.com/ko/actionscript-3/topic/1065/actionscript-3- https://riptutorial.com/ko/home 6 2: " 1009 : null ." 1009 null . " 1009 : null " null . Examples . stage Flash . 1009 . public class Main extends MovieClip { public function Main() { stage.addEventListener(Event.ENTER_FRAME,update); // here . stage null. : stage.addEventListener(Event.ENTER_FRAME,update); // here . Main GUI . SWF SWF . SWF Main . Event.ADDED_TO_STAGE AS . function listener(e:Event):void { var m:MovieClip=e.target as MovieClip; m.x++; } MovieClip ( : Sprite ) 1009 . var a:Object; trace(a); // null trace(a.b); // Error 1009 null new . 1009 . x=anObject.aProperty.anotherProperty.getSomething().data; null null . s=this.getChildByName("garbage"); if (s.parent==this) {...} getChildByName() null . null null . s null . 1009 . https://riptutorial.com/ko/home 7 addEventListener(Event.ENTER_FRAME,moveChild); function moveChild(e:Event):void { childMC.x++; if (childMC.x>1000) { gotoAndStop(2); } } Main childMC childMC gotoAndStop() 2 childMC 1009 childMC . gotoAndStop() , gotoAndPlay() SWF ( gotoAndStop() GUI . childMC null 1009 . removeEventListener . : Timer setInterval() setTimeout() . gotoAndStop() . , gotoAndStop() . for each (bullet in bullets) { if (player.hitTestObject(bullet)) gotoAndStop("gameOver"); } 1009 gotoAndStop() player MC now-null hitTestObject() . if (bullet.hitTestObject(player)) # 2007 "parameter hitTestObject null ." . gotoAndStop() return . : stage.addEventListener(Event.ENTER_FRAME,func1); stage.addEventListener(Event.ENTER_FRAME,func2); function func1(e:Event):void { if (condition()) { gotoAndStop(2); } } condition() true gotoAndStop() 1009 . " 1009 : null ." : https://riptutorial.com/ko/actionscript-3/topic/2098/--1009---null---------- https://riptutorial.com/ko/home 8 3: Examples " " As3 . public static "" . , 2D flash.geom.Point . • public function Point(x:Number = 0, y:Number = 0) : var point:Point = new Point(2, -.5); • public static function polar(len:Number, angle:Number):Point : var point:Point = Point.polar(12, .7 * Math.PI); new . private get / set public . _ public class Person { private var _name:String = ""; public function get name():String{ return _name; //or return some other value depending on the inner logic of the class } public function set name(value:String):void{ //here you may check if the new value is valid //or maybe dispatch some update events or whatever else _name = value; } get / set private . get set . public function get selectedValue():String { https://riptutorial.com/ko/home 9 //just the data from the element return _selected ? _selected.data : null; } public function set selectedValue(value:String):void { //find the element with that data for (var i:int = 0; i < _elems.length; i++) { if (_elems[i].data == value) { _selected = _elems[i];//set it processRadio();//redraw return; } } } . package package . package . ( . ) . package class . : package { // The top level package. } package world { // A package named world. } package world.monsters { // A package named monsters within a package named world. } . src . src TopLevelClass.as world ClassInWorldPackage.as AnotherClassInWorldPackage.as monsters Zombie.as extend override override override . public class Example { public function test():void { trace('It works!'); } } public class AnotherExample extends Example { public override function test():void { trace('It still works!'); } } : https://riptutorial.com/ko/home 10 var example:Example = new Example(); var another:AnotherExample = new AnotherExample(); example.test(); // Output: It works! another.test(); // Output: It still works! super . , AnotherExample.test() AnotherExample.test() . public override function test():void { super.test(); trace('Extra content.'); } : another.test(); // Output: It works! // Extra content. override super() . public class AnotherClass extends Example { public function AnotherClass() { super(); // Call the constructor in the inherited class. } } get set . getter setter . getter : get function , , : public function get myValue():Type{ //anything here return _desiredValue; } : getter (no parens () ). trace(myValue); setter : function function set . public function set myValue(value:Type):void{ //anything here https://riptutorial.com/ko/home 11 _desiredProperty=value; } : setter ( = ). myValue=desiredValue; getter setter : : getter setter . getter setter . 1. 2. (getter setter () , : getters setter