views:

27

answers:

2

Sorry for the dumb question, but I've spent already hours trying to figure this out (I am not a flash developer).

I have downloaded some external actionscript library in a form of a bunch of folders with .as files that have the following folder structure:

  • com/helper_lib1/*.as
  • com/helper_lib2/*.as
  • com/primary_lib/LibClass.as <- primary lib I want to use

lib.as has the following code:

package com.primary_lib{
    import com.helper_lib1.*;
    import com.helper_lib2.*;
    public class LibClass extends MovieClip{
        .....

Now I have some fla project where I want to use this com/primary_lib/lib.as, something like:

import com.primary_lib.LibClass;
var test:LibClass = new LibClass();
...

How to include this library into my project and where should I put all those files? I already tried putting them into every possible folder but I always get definition com.primary_lib:LibClass could not be found error. Can someone please walk me through this process on a basic level as I don't know much about flash (I'm using CS4).

Thanks.

+1  A: 

It looks like the problem is the filename. Actionscript classes must have their filename and location match the class name and package so your com.primary_lib:LibClass should be at com/primary_lib/LibClass.as Hope that does the trick.

Dave
Sorry, I just manually edited lib filenames for example sake. It matches lib name. Where should I put those files though?
serg
+1  A: 

Your Flash project should be able find the external libraries. Flash usually starts searching for them in the same folder that the FLA is saved in, then it looks in the common classes folders in your user settings folder...

Sometimes external code might be located in a folder that's not part of the package, e.g: src or classes in this case you have to manually add a path pointing to that location. For more info on this please check this acticle.

I hope this helps!

Makram Saleh
Thanks. If I copy this whole folder structure into FLA location I get another error that says that lib's method I am trying to call is not a function, and trace inside library class constructor is never called. But I finally made it work by moving main lib.as file directly into fla folder and changing its package declaration to reflect this.
serg