开发者

AS3 Import FLA file

I have two as3 projects. Project A has 2 files (fla with 1 frame and some components and as with some behavior and a default construc开发者_JAVA技巧tor). I want to use project A in my project B through as3 code. But when I do something like A a = new A(x, y, z); I receive lots of errors that in my A.as I am using undefined properties (those defined in my A.fla file).

So, right now I am using a loader to dynamically load A.swf into my project B. It is probably not an efficient way to do this. What's the correct way to import project A in project B?

Thanks.


loading the swf is not a bad way to do it..

****EDIT I forgot the most obvious answer: If you are using CS4, you should go to your publish settings and check "Export as SWC" In flaB, link the external library ( Actionscript settings) to contain the SWC flaA just generated. Now, you can say within flaB addChild(new flaAClass());

This gives you compile-time access to any library symbol in FLA A. This means you can't use the document class, so make sure you create a library symbol for what you want to bring in to FLA B and export it for actionscript. Then set the symbol's class label to something unique. Replace "flaAClass" in the example above with your name for the symbol.

But you shouldn't be defining any properties in your FLA itself. A good standard to work under is as so: 1) Go to your Publish settings and UNcheck "Automatically declare stage instances".

2) Set up your Document class/movieclip/whatever so that there's a reference to the stuff on the stage in the Class (This is why you must do step 1 -- otherwise it will complain you declare it twice)

Example: You have movieclip "mcA" on the stage.. your class might look like this:

package {

public class mainA extends MovieClip {
public var mcA:MovieClip;
      public function mainA(...args):void
      {
         trace(mcA); //If mcA is on the stage and this is the document class, this will 
         //return [object MovieClip]
      }
}

}

3) Attach as a document class or base class to something in your movieclip and you can reference it this way.


The above will work for a custom dynamic class, but won't contain anything that you brought with the FLA. If you want to take things out of fla A and put them into fla B.. you should load the SWF first, and then pull a class out of its library (but that may be unnecessary complexity you don't need).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜