1 Reply Latest reply on Dec 3, 2009 9:27 AM by anaping wan

    how cant I add a sprite to a IUIComponent

    jciglesias@uci.cu

      I'm doing some shapes with the class sprite and now I wan to add  that shape as a child of a component panel, but give me an error

      it's say that cant convert a sprite a to a IUIComponent,,

       

       

      how cant  I do that

        • 1. Re: how cant I add a sprite to a IUIComponent
          anaping wan

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/halo"  >

          <fx:Script>
            <![CDATA[
             import com.wananping.MySparkSkin;
            
             import mx.core.UIComponent;
              private function init():void
              {
                 var sp:Sprite=new Sprite();
              sp.graphics.beginFill(0xcc0000);
              sp.graphics.drawRect(0,0,100,100);
              sp.graphics.endFill();
             
              var ui:UIComponent=new UIComponent();
              ui.addChild(sp);
              vb.addElement(ui);
             
              }
            
            ]]>
          </fx:Script>
          <s:Group id="vb" width="400" height="300"  creationComplete="init()"/>
          <!--
          <s:Button label="提交"  textAlign="center" height="30" skinClass="com.wananping.MySparkSkin" />
          -->
          </s:Application>

           

          My english is not good. I hope you can see.