Hi,

I'm trying to use code behind technique and have a compiler problem. I 'm
trying to set an icon in a Button control, but the compiler not allow me to
do this. The following are the classes use to show you the problem


The following is the parent class:

ButtonPanelClass.as
===============

package components {

   import mx.containers.HBox;
   import mx.controls.Button;
   import assets.EmbeddedAssets;

   public class ButtonPanelClass extends HBox {

       public var new_btn:Button;
   }
}

Next is the mxml that extends the parent class:

ButtonPanel.mxml
=============

<?xml version="1.0" encoding="utf-8"?>
<comps:ButtonPanelClass
   xmlns:comps="components.*"
   xmlns:mx="http://www.adobe.com/2006/mxml";
   >

   <mx:Button id="new_btn" label="New" icon="{EmbeddedAssets.new_icono}"/>

   <mx:Script>
       <![CDATA[
           import assets.EmbeddedAssets;
       ]]>
   </mx:Script>

</comps:ButtonPanelClass>

Now the assets class I'm trying to use with an icon:

EmbeddedAssets.as
===============

package assets {

   public class EmbeddedAssets {

       [Embed(source="/assets/icons/16/new_icon.png")]
       public static const new_icono:Class;
  }
}


Now you have to use the following tag in your mx:Application and set the
namespace of course (xmlns:comps="components.*")


<comps:ButtonPanel/>


This is the result:

Severity and Description    Path    Resource    Location    Creation Time
Id
No se encontró el tipo o no es una constante en tiempo de compilación:
ButtonPanel. [Generated code (use -keep to save): Path:
components\ButtonPanel-generated.as, Line: 142, Column: 14]        FlexTest
  Unknown    1170796854984    14900

I assume this is a bug in the compiler. Anyone nows a workaround to get my
class compile or I should try to implement my component without use the code
behind technique?

Thanks in advance for any insight on this issue.


--
::| Carlos Rovira
::| http://www.carlosrovira.com
::| http://www.madeinflex.com

Reply via email to