开发者

Understanding classes in ActionScript

开发者 https://www.devze.com 2023-04-07 09:07 出处:网络
I have not used Flash in some time, let alone gotten round to using Classes in flash. I need to do some work on a client\'s site and I 开发者_如何学编程am trying to follow the previous developer\'s co

I have not used Flash in some time, let alone gotten round to using Classes in flash. I need to do some work on a client's site and I 开发者_如何学编程am trying to follow the previous developer's code which he/she did using classes in AS2.

Am I correct in understanding that these lines of code...

import mx.transitions.*;
import com.app.*;
import com.movie.*;

class com.movie.Main extends MovieClip {
   private var _contentData:Object;
   private var _contentManager:ContentManager;
   public var _language:String;
  1. imports the other classes
  2. extends the abilities of the movie clip called Main and then fires off everything below it.

What I am trying to grasp is what fires off the initial code and it looks like this might be it?

EDIT: It seems that the initial Main.as is fired off just after the preloader on the timeline:

import com.movie.Main;


In your Main class there should be a line such as:

public function Main():void

That's the constructor of the class and where most of the initialization code should be.

If the Main class is the fla's document class, the class will be created automatically.


It is a Document Class, of which an instance is created automatically and added to the stage. Not everything is fired off, just the constructor (same name as the class) will run, whatever that is doing from then on.

The document class can be chosen when compiling. Take a look here. The document class can probably also be chosen in the project configuration in an IDEs.


if you are using flash IDE,

include com.movie to the list of source file locations & set Document class to Main.

Understanding classes in ActionScript

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号