Reputation: 331
I usually work with many AS files in the same folder and it is easy to address those files to each other. But I now have a sub folder inside the name folder which stores most of my files; and there is another as file inside that sub folder. How can I change variables of the AS file(inside the sub folder) from the AS files from the main folder and vice verses. Thank you a lot ^^
Upvotes: 0
Views: 139
Reputation: 15580
You probably need to use the import
keyword if I've understood your question correctly. ActionScript files that reside in the same folder are automatically visible to each other, but files in different folders need to be imported. For example:
- name // folder
- sub // folder
- c.as // file
- a.as // file
- b.as // file
In this structure, a
can access b
(and vice versa) because they are in the same folder, or package. Neither a
nor b
can access c
, becuase it is in a different package (name.sub), and likewise c
cannot access a
or b
.
To make a
able to access c
, you must import the file first, like this:
//file a.as
import name.sub.c;
Notice that
a
resides.as
is omittedThe same would be done to allow c
to access a
:
//file c.as
import name.a;
And as a bonus, if you want to import all the files in a package you can use a wildcard selector:
//file c.as
import name.*; //imports a and b
Edit: As Taurayi notes in the comments, correct naming convention is to use lowercase names for folder/package names and to capitalize file/class names, e.g. com.myproject.components.MyComponentClass
Upvotes: 3