Copy link to clipboard
Copied
How do I include 2 or more external action script files in my FLA document.The first one is easy and taken care by setting the class property of the FLA document to the class file name. But if I have several external class files? I have tried the 'include' directive but the compiler complains - any suggestions?
Thanks
Joseph Karov
Copy link to clipboard
Copied
If they are class files then you need to use the import directive.
Copy link to clipboard
Copied
Thanks!
Copy link to clipboard
Copied
Have one of the Classes you want to use extend the other.
Copy link to clipboard
Copied
Thanks! How do I do that? Can I bundle 2 or more 'classes' in one package? I even thought to past the second class code on a frame . Surely there must be a correct way to include 2 or more class files in FLA document?
Copy link to clipboard
Copied
To import the other Class, just start typing its name in an expression, and hold down the control key while hitting the space bar. Both the Flash IDE and Flash Builder will bring up a code completion dropdown. When you select the Class, the import statement will be generated.
For example, if you are in Foo and you type:
protected var bar:Bar;
Then when you have typed in the "Ba" part of the word Bar after the colon, if you use the Ctrl-Space keyboard shortcut, it should show you your Bar Class, possibly among other Classes starting with "Ba." Select "Bar" with either your mouse or your cursor, and Flash will finish the word for you and generate the import statement. Note that you can now create and use instances of Bar, but Bar won't be "merged" into Foo, which it sounds like is what you want. To do that, you'll need to do what I suggested, which is to have one Class extend another Class.
To have one Class extend the other, change the line that says "public class Foo" to "public class Foo extends Bar". Note that the two Classes must have compatible functionality and have the same base Class. I'm assuming they do, or else trying to "include" the code wouldn't work either.
Another possible solution, depending on exactly what you're trying to acheive, is to apply the second Class to a symbol in the library and use that by placing it on the stage or accessing it through code. However, you haven't given us very much to go on, so it's really difficult to help you.
Copy link to clipboard
Copied
Many thanks, i'll will try to work through it
Copy link to clipboard
Copied
compilier "include" only that classes that was used somewhere in the code. So as MVP's said above - you need import second class in first.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now