Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

including AS3 external class file

New Here ,
Jun 22, 2013 Jun 22, 2013

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

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2013 Jun 23, 2013

If they are class files then you need to use the import directive.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2013 Jun 24, 2013

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 23, 2013 Jun 23, 2013

Have one of the Classes you want to use extend the other.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2013 Jun 24, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 24, 2013 Jun 24, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2013 Jun 24, 2013
LATEST

Many thanks, i'll will try to work through it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 23, 2013 Jun 23, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines