I don't know if I really understand what you are trying to do so correct
me if I am wrong...

My understanding: You have XML that you are using as a dataProvider for
a repeater; You want buttons to be created for each item in the
dataProvider; Each button (When Clicked) should navigate to a URL based
on data in the dataProvider.

OK, if it were me, I would create a custom component to encapsulate each
button. Here is an example:

MyCustomButton.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml";
click="onClick(event)">
     <mx:Script>
         <![CDATA[
             public var theURL:String;

             private function onClick(event:MouseEvent):void
             {
                 navigateToURL(new URLRequest(theURL), '_self');
             }
         ]]>
     </mx:Script>
</mx:Button>

And an Application to use it:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
     creationComplete="onCreationComplete()" xmlns:local="*">
     <mx:Script>
         <![CDATA[
             import mx.collections.XMLListCollection;

             [Bindable] private var buttonsXMLList:XMLListCollection;
             private var buttonsXML:XML;

             private function onCreationComplete():void
             {
                 buttonsXML =
                 <buttons>
                     <button label="Apple" url="http://www.apple.com"/>
                     <button label="Amazon" url="http://www.amazon.com"/>
                     <button label="EBay" url="http://www.ebay.com"/>
                     <button label="Adobe" url="http://www.adobe.com"/>
                 </buttons>
                 ;

                 buttonsXMLList= new
XMLListCollection(buttonsXML.button);
             }
         ]]>
     </mx:Script>
     <mx:Repeater id="buttonsRepeater" dataProvider="{buttonsXMLList}">
         <local:MyCustomButton
label="[EMAIL PROTECTED]"
             theURL="[EMAIL PROTECTED]"/>
     </mx:Repeater>
</mx:Application>

--- In [email protected], Gustavo Duenas <[EMAIL PROTECTED]> wrote:
>
> Hi I have a xml file and it has a <button1>800</button1> and so
> forth, and also I have a repeater (a horizontal list) which grabs the
> xml and the item renderer with a button, instead of doing the
horizontal
> list do the click I'd like to make the button inside the item
> renderer to do that.
>
> how could I do that?
>
> I was trying to use
> in the item rendered
>
> private function send():void{
>
> <mx:Script>
>  <![CDATA[
>    public function send(event:MouseEvent):void{
>      var urlRequest : URLRequest = new URLRequest("{data.button1}");
> navigateToURL( urlRequest, "_self" );
>      }
>  ]]>
> </mx:Script>
>
> and in the button: click="send()"
>
> so far, it is just putting in my browser mybroser/{data.button1}
> but I'd like to put in there the URL, how could I?
>
> Regards,
>
> Gus
>
>
> Gustavo A. Duenas
> Creative Director
> LEFT AND RIGHT SOLUTIONS
> 904.  265 0330 - 904. 386 7958
> www.leftandrightsolutions.com
> Jacksonville - Florida
>

Reply via email to