Hi

My problem is that I have a Flex library file (swc) that contains a
class that holds several methods that I want several Flex-projects to
register with the ExternalInterface API so that they can be reached
from Javascript or ActiveX.

I want the Flex project to just include the swc file.

I figure that I need to use mixin and to register the library class
with the APPLICATION_COMPLETE.

I want to be able to add this swc file as a library, and without
making any calls to this class, making the addCallback methods be
registered automatically.

How do I do that?

Thanks

Peter


[Mixin]
public class ExternalLib
{
  public function ExternalLib(root:DisplayObject)
  {
    root.addEventListener(FlexEvent.APPLICATION_COMPLETE,
applicationCompleteHandler);
  }

  public static function init(root:DisplayObject):void
  {
    if(!externalLib)
    {
        _root = root;
        externalLib= new ExternalLib(root);
    }
  }
                
  private function applicationCompleteHandler(event:FlexEvent):void
  {
    _root.removeEventListener(FlexEvent.APPLICATION_COMPLETE,
applicationCompleteHandler);
        
    externalLib= this;
    
    if(ExternalInterface.available)
    {
      ExternalInterface.addCallback("addevent", catchEvent);
      ExternalInterface.addCallback("checkProperty", catchProperty);
    }
    else
      trace("Error: Not available");
                        
  }

}

Reply via email to