2 Replies Latest reply on Dec 4, 2007 6:04 PM by vij010

    XML list to Flex

    vij010 Level 1
      Might be pretty stupid to ask....I have an XML list that has shows some pictures thru a horizontal scroll bar....when i click on a column, I want the name of the file and it's info to pop up in an alert

      The structure of the file goes like this:

      <product id ="1">

      This is the code....The renderer

      <?xml version="1.0"?>
      <!-- itemRenderers\htlistMainlistThumbnailRenderer.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
      public function showtext():void {

      Alert.show('You Clicked'+ ,'SampleApp')

      <mx:Model id="catalog" source="catalog.xml"/>

      <mx:HorizontalList id="myList"
      itemRenderer="myComponents.thumbnail" click="showtext()"/>

      <mx:LinkButton label="Product images courtesy of Lavish"
      click="navigateToURL(new URLRequest(' http://www.shoplavish.com'), '_blank')"/>

      The script tag was what I was attempting to write...but I can't find out a way to get the XML data to pop out in an alert.

      The MXML file
      <?xml version="1.0" ?>
      <!-- itemRenderers\htlist\myComponents\Thumbnail.mxml -->
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml"
      verticalGap="0" borderStyle="outset" backgroundColor="white" >

      <mx:Image id="image" width="100" height="100" source="{data.image}"/>
      <mx:Label text="{data.name}" width="120" textAlign="center"/>
      <mx:Label text="${data.price}" fontWeight="bold"/>

      Hope someone can help on this....

      The more important question is this: How can we pass a data bound property to a function ?...Do we need the ArrayCollection interface too ?
        • 1. Re: XML list to Flex
          ntsiii Level 3
          One way is to have the renderer dispatch an bubbling event, which you can listen for anywhere above.

          You can expose a public property containing the "data", and in the result handler, access that data through the target or currentTarget properties.

          • 2. Re: XML list to Flex
            vij010 Level 1

            Can you post s simple example of such a request where I can get a XML property into Flex, going by the event bubbling methodology ?...I read the help files but I am a lttile blurred on implementing the same.