Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flash import class from another directory

Originally my classes(.as) and project (.fla) were stored in the same directory. But I would like to refactor them. I've created a subdirectory "classes", and moved my classes into this subdirectory but I've got error.

All my classes are stored in one package.

How can I "include" or "import" my classes from a subdirectory of my project?

like image 366
takayoshi Avatar asked Nov 17 '25 05:11

takayoshi


2 Answers

The problem is probably the .as files in the new folders. AS3 namespaces map to your filesystem. This means a class named Bar in the folder foo needs to be in the foo namespace.

Bar.as

package {

foo/Bar.as

package foo {

widget.as

package {
    import foo.Bar;

Which will look like this on your filesystem:

| Bar.as
- foo
   | Bar.as
| widget.as
like image 117
DingoEatingFuzz Avatar answered Nov 18 '25 19:11

DingoEatingFuzz


Two solutions:

  1. Add your subdirectory to your library path (click on Edit next to ActionScript settings in the property panel and then on the first tab just add your directory)
  2. In your class file just change the package to nameofthesubdirectory
like image 41
Kodiak Avatar answered Nov 18 '25 20:11

Kodiak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!