Here is one example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
     layout="horizontal"  horizontalAlign="left" verticalAlign="top">
     <mx:Script>
         <![CDATA[
             import mx.events.ItemClickEvent;

             [Bindable] private var theLinks:XML =
             <sample>
                 <entry>
                     <text>Click Me 1</text>
                     <link>http://www.followthis1.com</link>
                 </entry>
                 <entry>
                     <text>Click Me 2</text>
                     <link>http://www.followthis2.com</link>
                 </entry>
                 <entry>
                     <text>Click Me 3</text>
                     <link>http://www.followthis3.com</link>
                 </entry>
             </sample>

             private function
handleLinkClickedEvent(event:MouseEvent):void
             {
                 var theLink:XML = XML(event.target.data[0]);
                 navigateToURL(new URLRequest(theLink), '_self');
             }
         ]]>
     </mx:Script>
     <mx:Repeater id="myRepeater" dataProvider="{theLinks.entry}">
         <mx:LinkButton label="{myRepeater.currentItem.text}"
             data="{myRepeater.currentItem.link}"
             click="handleLinkClickedEvent(event)"/>
     </mx:Repeater>
</mx:Application>


--- In flexcoders@yahoogroups.com, "iloveyouwisconsin" <[EMAIL PROTECTED]>
wrote:
>
> Newbie alert...now for my stupid question. I'm sure this is pretty
> simple but I am completely new to Flex:
>
> How do I dynamically display an array of external hyperlinks? I have
> the following xml code:
>
> <sample>
> <entry>
>   <text>Click Me 1</text>
>   <link>http://www.followthis1.com</link>
> </entry>
> <entry>
>   <text>Click Me 2</text>
>   <link>http://www.followthis3.com</link>
> </entry>
> <entry>
>   <text>Click Me 3</text>
>   <link>http://www.followthis3.com</link>
> </entry>
> </sample>
>
> How do I make it so that the user will see the 3 items in the <text>
> field (dynamically...not hardcoded):
>  1. Click Me 1
>  2. Click Me 2
>  3. Click Me 3
> and then when each is clicked they will be directed to their
> respective links: http://www.followthis1com,
http://www.followthis2com, http://www.followthis3com?
>
> Here is the flex code I am (wrongly) using:
> <mx:Script>
>  <![CDATA[
>                         import mx.events.ListEvent;
>    import mx.collections.ArrayCollection;
>    import mx.rpc.events.FaultEvent;
>    import mx.controls.Alert;
>    import mx.rpc.events.ResultEvent;
> [Bindable] private var thisList:ArrayCollection;
> private function changeHandler(event:ListEvent):void{
>    }
>    private function init():void{
>     goodsample.send();
>        }
> private function httpResultHandler(event:ResultEvent):void{
> thisList = event.result.sample.entry;
>       }
>
>  ]]>
> </mx:Script>
>
> <mx:HTTPService id="goodsample"
> url="http://localhost/sampleentries.php";
> result="httpResultHandler(event)"/>
>
>
> <mx:LinkBar labelField="text"
>         itemClick="navigateToURL(new URLRequest(
> String(event.label).toLowerCase()), '_blank');">
>         <mx:dataProvider>
>             {thisList}
>         </mx:dataProvider>
>     </mx:LinkBar>
>
> Many thanks!
>

Reply via email to