Wednesday, 26 August 2015

Week 4 Workshop A - AC3 Hello World!

Get absent to the workshop, done the practice at home.


Very excited to learn a new OOP language!

The first exercise is a simple introduction to the software. Get familiar with the basic layout of the software and make some simple coding.

Listing key knowledge:

- Stage file as "file.fla" . This is what the users/players would see as the main interface.
- Class file as "file.as'.   This is the external code for the stage, usually the "main.as" (AKA document class) is the one that directly (exclusively) links to the stage file. In other word, the code on "main.as" is what would be shown on the stage.
   #The Class name must be exactly same as the file name#

- package: All classes in AS3 begin with the keyword package. The package keyword tells Flash that everything in between the curly brace just after it and the final curly brace is part of a single group.

- import statement: it is used to import different classes from different packages. Generally they will come from the core Flash Player set of classes.

 import flash.display.MovieClip;   
 import flash.events.*;  

- To set the "main.as" as the sub-class of the MovieClip class:

 public class main extends MovieClip {  
 }  

- "Complier Errors" is handful for debugging.

- Variables:

 var greeting: String;   
 greeting = 'Hello World!';  
OR
 var greeting: String = 'Hello World!";  

- Keyboard input
1.
 import flash.events.*;  

2.(inside the public function)
 stage.addEventListener(KeyboardEvent.KEY_DOWN, otherfunction);  
 public function otherfunction(e:KeyboardEvent):void {  
 }  
#void means the function did not actually create any value


No comments:

Post a Comment