Using Flash Professional, how do I import classes from an ActionScript file?

2

In my project I have the ListLoader class, responsible for interpreting a list and uploading files described in it.   My goal is to be able to save this and other classes in a .as extension file and be able to import it into my current project as well as into others.  It is important to mention that this class is not a stage object.

    
asked by anonymous 25.07.2014 / 17:24

2 answers

4

The Flash import system (in the case of ActionScript 3.0) works by looking in two folders and their subfolders (you can add more folders in the project preferences in the libraries section): The folder where% the folder where the compiler is installed. In your case, just create a folder, for example, Main and paste the file ClassesAuxiliares in there. To import use the following syntax:

import ClassesAuxiliares.MinhaClasseAuxiliar;

In a generic way, you will provide the path of the class.

    
25.07.2014 / 17:31
1

The classes imported from ActionScript must be wrapped with the path of the directory where they are saved. This is pre-defined in the class package declaration within your AS code.

Let's say I have a class named Example that is part of the examples package, so the package code inside the class would be:

package examples { //PACOTE DA CLASSE
     public class Example {
          public function Example() {
              //Construtor
          }
     }
}

And the path of the class in the directory would be raizdoseuswf / examples / Example.as .

To use this class, you need to import it into your project / class using the path and its name at the beginning of the code. See below:

import examples.Example;
var novoExemplo:Example = new Example();

This video can help you a lot.

    
25.07.2014 / 23:30