views:

111

answers:

3

I understand the syntax of AS3 just fine, but all the types and the strange hierarchy and all the inheritance is a bit confusing, and I am having trouble just getting something to show up. I see all these commands like addChild(etc); but they aren't tell me how I use it to do anything. And what is the main flash window called? How can I set its properties with AS3?

A: 

The main flash window can be linked to a custom class of your choice that inherits from MovieClip. You'll see at the bottom of the Flash UI a property called document class. If you set this to a class of your own choice you can start using it as the main window.

For example say you have a class called MainWindow (for simplicity) that you link to your .fla through the document class property. If you then drag a movieclip named car onto the stage and give it an instance name of "theCar" you could access it through the MainWindow class file by simply typing:

theCar.alpha = .5;

Or if you wish to dynamically add items you would have to link the movieclips themselves to classes that you can then create instances of. For example if you link the care movieclip to a class called Car_mc you could instantiate it in the main window class like this:

var car:MovieClip = new Car_mc();
addChild(car);

This would instantiate the movieclip and add it to the stage as a child of your main class.

To link a movieclip to a class you simply right click the symbol in the library and choose "linkage" and then check "export for actionscript" then you can fill in a class name and a baseclass for that symbol and instantiate it as I described above.

Robban
A: 

addChild(x) = this.addChild(x), "this" is omitted. "this" is how your main windows or on flash language "stage" called. Stage is an object, usually of Sprite type. Can be MovieClip which is more advanced and probably not that useful for "stage"

addChild is pretty simple, you drag to library any control you want use (like importing), let's say you drag Input, then you create an external action script file .as from which you can access this control by creating new control object and setting it's properties. Important is to make your external class to inherit from Sprite object ( which is simpler form than MovieClip object).

Most of ppl who get into Flash usually fail to get events because these are quite unique to AS and maybe Javascript. If you get those you are on the right road.

eugeneK
+2  A: 

again, as with http://stackoverflow.com/questions/1569385/how-do-i-setup-a-game-room-in-pure-actionscript read some manuals, tutorials etc

http://www.senocular.com/flash/tutorials/as3withflashcs3/ <-- this is a good free beginners guide that gives an overview on all your questions.

Allan