iNk
iNk

Reputation: 83

Why do I have to create an AS3 package using Flash?

I know what "works"

If I create a new file in explorer named test.as and I create my packaged class, I haven't found a single way to have my flash file find and use it. I've tried using relative and exact paths in the actionscript 3.0 settings. It refuses to see it

However. If I create an as3 class named "test" THROUGH the program, it actually "LOADS" the test.as that I created in explorer. And has no problem finding and using the package.

I need to know why Flash requires that the .as file is made through it's program.

I feel like I'm entirely missing something. Does this mean that if I want to use a class that I find in some tutorial. I need to create new AS3 files and paste them in for each one?

Upvotes: 1

Views: 1338

Answers (1)

ToddBFisher
ToddBFisher

Reputation: 11610

One thing to consider is that package names should always mirror folder structure.

Make sure that if you have a class declared as

package com.mystuff { public class className {...} ...}

that it is saved in "yourSoruceFolder/com/mystuff/className.as" and that when you reference it in your other code you import com.mystuff;

Make sure your class path includes the path to your "yourSoruceFolder" as well, if "yourSoruceFolder" is not your document root.

If you use the default package, aka package { public class myClass ...} without the yourSoruceFolder, then as long as the code is saved in the document root directory then it will work without additional folders, as you have seen in your testing.

Upvotes: 4

Related Questions