4 Replies Latest reply on Apr 5, 2010 10:07 AM by FinFlex

    Flex4: LinkElement not clickable in ItemRenderer ?

    ZeDav

      When I create an inline ItemRenderer, the LinkElement is clickable. However, when I create it from code, it's not clickable. I must be missing something, I've searched the web and docs for hours and I still can figure it out.

       

      Can anyone check my code below and tell me what I am doing wrong ? Thanks in advance

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                             xmlns:s="library://ns.adobe.com/flex/spark" 
                             xmlns:mx="library://ns.adobe.com/flex/mx"
                             creationComplete="initApp();">
          <fx:Declarations>
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import mx.collections.ArrayList;
                  
                  private function initApp():void{
                      mylist.dataProvider = new ArrayList([{"href":"http://www.adobe.com","text":"Adobe"},
                                                           {"href":"http://www.google.com","text":"Google"}]);
                  }
              ]]>
          </fx:Script>
          <s:List id="mylist">
              <s:itemRenderer>
              <fx:Component>
              <s:ItemRenderer>
                  <fx:Script>
                  <![CDATA[
                      import flashx.textLayout.elements.LinkElement;
                      import flashx.textLayout.elements.ParagraphElement;
                      import flashx.textLayout.elements.SpanElement;
                      import flashx.textLayout.elements.TextFlow;
                                  
                      override public function set data(value:Object):void {
                           var p:ParagraphElement = new ParagraphElement();
                           var t:SpanElement = new SpanElement();
                           t.text = " ";
                           p.addChild(t);
                           t = new SpanElement();
                           t.text = value.text;
                           var l:LinkElement = new LinkElement();
                           l.href = value.href;
                           l.addChild(t);
                           p.addChild(l);
                           htext.textFlow = new TextFlow();
                           htext.textFlow.addChild(p);
                      }
                  ]]>
                  </fx:Script>
                  <s:HGroup>
                       <s:Label text="Link:"/>
                       <s:TextArea id="htext" width="100%" height="40" editable="false"/>
                  </s:HGroup>
              </s:ItemRenderer>
              </fx:Component>
              </s:itemRenderer>
          </s:List>
      </s:WindowedApplication>