3 Replies Latest reply on Nov 8, 2007 6:39 AM by Gregory Lafrance

    Actionscript Tab Icon

    JayStang Level 1
      I'm trying to put an icon on each tab of a tab navigator. Works just fine if i have everything in mxml, but if i am programmatically creating the tab objects, the icon will not appear.

      Working Example:
      <mx:TabNavigator id="pageTab" width="100%" height="100%" verticalGap="0">
      <tab:page_Info id="pageInfo" icon="{iconInfo}" />
      </mx:TabNavigator>

      Non Working Exmaple:
      var pageInfo:page_Info = new page_Info();
      pageInfo.setStyle("icon", iconInfo);
      pageTab.addChild(pageInfo);


      Anyone know what i am doing wrong here?

      Thanks,
      ~Jamie
        • 1. Re: Actionscript Tab Icon
          Gregory Lafrance Level 6
          ------------------------------- PageInfo.mxml -------------------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">
          <mx:TextArea text="This is an MXML component TextArea."/>
          </mx:VBox>
          ---------------------------------- Test.mxml -----------------------------------------
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()"
          xmlns:tab="components.*">
          <mx:Script>
          <![CDATA[
          import components.PageInfo;

          [Embed("assets/images/redSquare10px.JPG")]
          public var os:Class;

          private var pageInfoAS:PageInfo = new PageInfo();
          private function init():void{
          pageInfoAS.icon=Class(os);
          pageTab.addChild(pageInfoAS);
          }
          ]]>
          </mx:Script>

          <mx:TabNavigator id="pageTab" width="100%" height="100%" verticalGap="0">
          <tab:PageInfo id="pageInfo2" icon="@Embed(source='assets/images/blueSquare10px.JPG')" />
          </mx:TabNavigator>

          </mx:Application>


          • 2. Re: Actionscript Tab Icon
            JayStang Level 1
            Ah thanks Greg, makes sense. Just strange icon is referenced as a style everywhere else and just a normal attribute here. Oh well this worked great!
            • 3. Re: Actionscript Tab Icon
              Gregory Lafrance Level 6
              I had to jump through hoops for this to work. I need exactly this:

              Embed("assets/images/redSquare10px.JPG")]
              public var os:Class;

              and this

              pageInfoAS.icon=Class(os);