Skip to main content
February 21, 2016
Answered

Can you have multiple packages in one source code file, or do you have to have multiple files?

  • February 21, 2016
  • 1 reply
  • 457 views

Can you have multiple packages in one source code file, or do you have to have multiple files?

This topic has been closed for replies.
Correct answer kglad

ExampleClass must be saved to a directory along with your main fla.

that directory must have a subdirectory named samples which contains SampleCode.

1 reply

kglad
Community Expert
Community Expert
February 21, 2016

you can have multiple classes, but not multiple packages.

the package name specifies class file's location and one file cannot be in multiple locations.

February 22, 2016

OK so I have to use separate files, I’ve been trying to do this but it has not been working.I’ve been following the instructions on the web site below.Basically what I’ve been doing is :package samples { public class SampleCode { public function SampleCode() { } }}Located in one file and in a second file:package { import samples.SampleCode; public class ExampleClass { public function ExampleClass(){ } }}But it just gives me error messages saying that it can’t find the imported class from the second file.http://www.adobe.com/devnet/actionscript/learning/as3-fundamentals/packages.html

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 23, 2016

ExampleClass must be saved to a directory along with your main fla.

that directory must have a subdirectory named samples which contains SampleCode.