1 Reply Latest reply on Jun 26, 2009 11:54 AM by Flex harUI

    Using an Embeded symbol and getDefinitionByName

    CannotCompute Level 1

      Below I am creating a toolbar using some buttons I created in the Flash IDE. Now I am adding them to a panel depending on which tools they wanted loaded in. That information is stored in an xml file.  The Error I get now is that the class bPrint is not defined. Basically I need help with the sytax.


      Some other side questions I had was about using ButtonAsset. I can use SpriteAsset and MovieClipAsset with no problems but if I try using ButtonAsset on buttons that I am pulling in from flash I get errors. Can someone provide me with an example of how to use the ButtonAsset object?


      Lastly, what is the best way to handle the events on my buttons that I created in flash?  I was just going to add an event listener called clickHandler and using a case statement on the target.name value, I would handle the event accordingly. Sound good?


      Thanks in advance to all who contribute.


      <?xml version="1.0" encoding="utf-8"?>

      <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"


      height="114" width="800"

      paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5">




      import mx.controls.Alert;

      import flash.utils.getDefinitionByName;

      import mx.controls.Image;

      import mx.core.ButtonAsset;

      import mx.controls.Button;

      import mx.core.SpriteAsset;



      [Bindable] public var PropList:XMLList;

      [Embed("Images/tool_24.png")] private const PanelTitleIcon:Class;



      [Embed("SWFs/buttons.swf", symbol="bPrint")] private var bPrint:Class;






      public function init():void


      this.title = PropList.@t;

      this.setStyle('backgroundColor', String(PropList.@bgc));

      this.setStyle('boarderColor', String(PropList.@bc));


      this.setStyle('fontFamily', PropList.@f);

      this.setStyle('fontSize', Number(PropList.@fs));

      this.setStyle('color', String(PropList.@fc));


      if(PropList.@si == "t") this.titleIcon = PanelTitleIcon;


      var i:uint;

      var toollist:XMLList;

      var tool:Array = new Array();


      toollist = PropList.tools;




      tool[i] = new Image();

      tool[i].source = getDefinitionByName(String(toollist.t[i].@n)) as Class;