Search code examples
actionscript-3flashflashdevelop

How can i associate a library symbol with an existing class


I am using Flash Develop for compilation ( Not Flash IDE )

Here is a sample code :

   [Embed(source = 'assets.swf', symbol = 'app.view.CustomButton')
    var customButton_Class:Class ; 

    var customButton_Instance ;


    customButton_Instance = new customButton_Class();

The problem is that this "customButton_Instance" doesnot know anything about app.view.CustomButton ?? ( Actually this means there is no sense in setting the class as app.view.CustomButton in the assets.fla library )

The workaround i am following is :

 var customButton:CustomButton = new CustomButton();
customButton.setView( customButton_Instance ) 

But i wanted somehow, the customButton_Instance should automatically associate itself with the customButton class. Any ideas pls ?


Solution

  • When using Embed you lose the symbol's associated class. That's how it works.

    Instead, if you're using Flash Pro, choose to Publish a SWC that you can then add to your FlashDevelop project (in FlashDevelop: right-click > Add to Library), and then all the symbols will be visible in code completion like any class and you can just write new app.view.CustomButton() or create a custom class extending it.