Search code examples
actionscript-3componentsshareswcrsl

how to share a component in as3


I have a custom component(eg. MyButton) used in several swfs. I'd like to share the component in runtime, thus once our designer change the button's visual effect, we need not publish all flas that uses this button.

In as2, I can put this button in an asset fla(eg. lib.swf) and check the "export for runtime share" in symbol property. Then copy the button to a fla(eg. main.swf) and check the "import for runtime share", this works fine. However in as3, after doing above, if I put a button instance on stage and modify its inspectable property, i'll get a compile error "1046:Type was not found or was not a compile-time constant".

I searched the web and found this http://www.kirupa.com/forum/showthread.php?317257-Runtime-Shared-Library-woes. Then I tried the swc approach, but it seems swc will be compiled into swf, it doesn't share at all.

  1. the shared component must be put on the stage, because all fla will be modified by our designer while he knows nothing about programing.
  2. we can not use flex, all operation must be done in Flash CS5.

Solution

  • I've found the solution.

    1. Give the Sprite that holds the imported components a binding class
    2. Edit the class file, declare the components yourself regardless of whether checked the "auto declare instance on stage"