2 Replies Latest reply on Dec 8, 2008 7:03 PM by ntsiii

    Dynamic variable

    salut
      The values in <mx:Label text="{videoRepeater.currentItem.VideoName}"/> are correctly displayed, but I got an error message when the same dynamic variable is in

      <mx:Text id="videoName" link="onLinkClick(event,'rtmp://localhost/vod/' + {videoRepeater.currentItem.VideoName} + '.flv')" selectable="true" condenseWhite="true">
      <mx:htmlText>

      The error message is: Id
      1084: Syntax error: expecting identifier before rightbrace. Video5/src Video5.mxml line 39

      Id
      1084: Syntax error: expecting colon before dot. Video5/src Video5.mxml line 39

      I appreciate your help.

      private function onLinkClick(event:TextEvent, rtmplink:String):void{
      vid.source=rtmplink;
      vid.autoPlay="true";
      }


      ]]>
      </mx:Script>

      <mx:VBox x="10" top="600">
      <mx:Repeater id="videoRepeater">
      <mx:Label text="{videoRepeater.currentItem.VideoName}"/>

      <mx:Text id="videoName" link="onLinkClick(event,'rtmp://localhost/vod/' + {videoRepeater.currentItem.VideoName} + '.flv')" selectable="true" condenseWhite="true">
      <mx:htmlText>
      <![CDATA[
      <a href='event: http://www.adobe.com/'><u><font color='Blue'>Go to this video! </font></u></a>
      ]]>
      </mx:htmlText>
      </mx:Text>

      </mx:Repeater>

      <mx:VideoDisplay id="vid" autoPlay="false" source="rtmp://localhost/vod/legend.flv" x="300" y="700"/>
      <mx:VBox x="400" y="600">
      <mx:Button label="Play" click="vid.play();"/>
      <mx:Button label="Pause" click="vid.pause();"/>
      <mx:Button label="Stop" click="vid.stop();"/>
      </mx:VBox>

      </mx:VBox>
        • 1. Re: Dynamic variable
          salut Level 1
          The answer is to use event.currentTarget, as shown below:

          <mx:Text id="videoName" link="onLinkClick(event,event.currentTarget.getRepeaterItem().VideoName)" selectable="true" condenseWhite="true">
          • 2. Re: Dynamic variable
            ntsiii Level 3
            For all but the simplese uses, i advise creating a custom component, passing in a reference to the entire current Item, and repeating that component. I is much easier to cod and does away with getRepreater item, since you can expose the item in a public property accessible in the handler.

            Tracy