6 Replies Latest reply on Jun 6, 2008 1:31 PM by Shelady

    5 Elements in XML. 1 is not responding.

    Shelady
      Hi,
      Im my XML there are 5 elements. Name, Author, Image, Link and time. All the elements are showing via Item Renderer but when I click on the image, the relavent page is not opening. Any suggestion?
      Thanks

      Here are my 3 files.
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
      backgroundGradientColors="[#eeeeee, #eeeeee]"
      initialize="titleService.send()">

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      import flash.events.Event;
      import flash.events.MouseEvent;

      [Bindable]
      private var myData:ArrayCollection;

      private function resultHandler(event:ResultEvent):void {
      myData = event.result.titles.title;
      }
      ]]>
      </mx:Script>

      <mx:HTTPService id="titleService"
      url="data/newtitles.xml"
      result="resultHandler(event)"/>

      <mx:Label text="Technology News" fontSize="20"/>

      <mx:TileList id="myList" dataProvider="{myData}"
      itemRenderer="view.MyRenderer"
      width="720" height="600" verticalScrollPolicy="off" />

      <mx:Label text="{myList.selectedIndex}"/>
      <mx:Label text="{myList.selectedItem.name}"/>



      </mx:Application>


      Here is the item renderer

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="700" height="100"
      paddingLeft="25" verticalScrollPolicy="off" horizontalScrollPolicy="off">

      <mx:HBox>
      <mx:Image source="assets/{data.image}" buttonMode="true" useHandCursor="true" click="{data.link}"/>
      </mx:HBox>
      <mx:VBox>
      <mx:HBox>
      <mx:Text text="{data.name}"
      textAlign="left" fontWeight="bold" fontSize="10"/>
      </mx:HBox>

      <mx:HBox>
      <mx:Text text="{data.author}"
      width="650" condenseWhite="true" textAlign="left"/>
      </mx:HBox>

      </mx:VBox>

      </mx:HBox>



      Here is the XML file


      <?xml version="1.0"?>
      <titles>
      <title>
      <name>The Future of Windows</name>
      <author>Vistas successor may be the real winner for Microsoft. What does Windows 7 hold in store? Here's what we've gleaned so far.</author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>9</runningtime>
      <image>vsta.jpg</image>
      </title>
      <title>
      <name>QUARKXPRESS 7 NEW FEATURES</name>
      <author>Jay Nelson</author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>5</runningtime>
      <image>tips.jpg</image>
      </title>
      <title>
      <name>PODCASTING WITH GARAGEBAND 3</name>
      <author>Scott Bourne</author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>4.75</runningtime>
      <image>amd.jpg</image>
      </title>
      <title>
      <name>iWEB ESSENTIAL TRAINING</name>
      <author>Garrick Chow</author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>3.5</runningtime>
      <image>charger.jpg</image>
      </title>
      <title>
      <name>EFFECTIVE EMAIL</name>
      <author>Jeff Van West </author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>6.5</runningtime>
      <image>gadgts.jpg</image>
      </title>
      <title>
      <name>MAC OS X SERVER v10.4 TIGER ESSENTIAL TRAINING</name>
      <author>Sean Collins</author>
      <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
      <runningtime>9.25</runningtime>
      <image>gps.jpg</image>
      </title>
      </titles>
        • 1. Re: 5 Elements in XML. 1 is not responding.
          VarioPegged Level 2
          Use navigateToURL() on the click event of your image in the itemRenderer...

          TS
          • 2. Re: 5 Elements in XML. 1 is not responding.
            Shelady Level 1
            Thanks its working but now I m facing another problem.
            In my XMl I have changed the length of the text in author from 3 words to 50 words <description instead of author> now when I am rendering this, first couple of items are showing all the text but last 3 are cutting the text where the box end and are not word wrapping.
            Now If I have done something wrong then every item should be cut down but it is only happening with the last 3 items and other items are word wrapping.

            Any idea?

            Thanks
            • 3. Re: 5 Elements in XML. 1 is not responding.
              VarioPegged Level 2
              I'll need to see what you're talking about, so best thing would be to post some code.

              TS
              • 4. Re: 5 Elements in XML. 1 is not responding.
                Shelady Level 1
                Here is my does. The only problem is from XML, the author list is getting truncate for the last 3 items. All other items are word wrapping.
                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
                backgroundGradientColors="[#000000, #660707]"
                initialize="titleService.send()" verticalScrollPolicy="off" backgroundGradientAlphas="[1.0, 1.0]">



                <mx:Script>
                <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
                import flash.events.Event;
                import flash.events.MouseEvent;

                [Bindable]
                private var myData:ArrayCollection;

                private function resultHandler(event:ResultEvent):void {
                myData = event.result.titles.title;
                }
                ]]>
                </mx:Script>

                <mx:HTTPService id="titleService"
                url="data/newtitles.xml"
                result="resultHandler(event)"/>

                <mx:Label text="Technology News" fontSize="20" color="#F9CD00"/>

                <mx:TileList id="myList" dataProvider="{myData}"
                itemRenderer="view.MyRenderer"
                width="720" height="600" verticalScrollPolicy="off" backgroundAlpha="0"
                selectionColor="#976543" alpha="1"
                rollOverColor="#f9cd00" borderThickness="0" />

                <mx:Label text="{myList.selectedIndex}" />
                <mx:Label text="{myList.selectedItem.name}"/>



                </mx:Application>



                <?xml version="1.0" encoding="utf-8"?>

                <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml"
                width="700" height="90"
                paddingLeft="25" verticalScrollPolicy="off" horizontalScrollPolicy="off" >

                <mx:HBox>
                <mx:Image source="assets/{data.image}" buttonMode="true" useHandCursor="true"
                click="navigateToURL(new URLRequest(data.link))"/>

                </mx:HBox>
                <mx:VBox backgroundAlpha="0" width="670">
                <mx:HBox backgroundAlpha="0">
                <mx:Text text="{data.name}"
                textAlign="left" fontWeight="bold" fontSize="12" color="#eb260c"/>
                </mx:HBox>

                <mx:HBox>
                <mx:Text text="{data.author}"
                width="650" condenseWhite="true" textAlign="left" color="#bdab5a" alpha="1"/>
                </mx:HBox>

                </mx:VBox>

                </mx:HBox>




                <?xml version="1.0"?>
                <titles>
                <title>
                <name>The Future of Windows.</name>
                <author>Vistas successor may be the real winner for Microsoft. What does Windows 7 hold in store? Here's what we have gleaned so far.</author>
                <link> http://www.pcmag.com/article2/0,2817,2314409,00.asp</link>
                <runningtime>9</runningtime>
                <image>vsta.jpg</image>
                </title>
                <title>
                <name>Alternative Gadget Chargers.</name>
                <author>Cell phone run out of juice with no AC outlet in sight? An alternative-energy charger may be your best bet. We put three to the test.</author>
                <link> http://www.pcmag.com/article2/0,2817,2316586,00.asp</link>
                <runningtime>5</runningtime>
                <image>gadgts.jpg</image>
                </title>
                <title>
                <name>AMD Introduces Puma Platform.</name>
                <author>The battleground for AMD and Intel is likely to shift from CPUs to laptop platforms.</author>
                <link> http://www.pcmag.com/article2/0,2817,2316739,00.asp</link>
                <runningtime>4.75</runningtime>
                <image>amd.jpg</image>
                </title>
                <title>
                <name>91 Utilities to Supercharge XP and Vista.</name>
                <author>These top utilities are all about tweaking, manipulating, and totally dominating the looks and functionality of Windows.</author>
                <link> http://www.pcmag.com/article2/0,2817,2279207,00.asp</link>
                <runningtime>3.5</runningtime>
                <image>utilites.jpg</image>
                </title>
                <title>
                <name>The Best Dual-Band Routers.</name>
                <author>If you are looking for optimal 802.11n wireless performance, dual band routers like these four are the way to go.</author>
                <link> http://www.pcmag.com/article2/0,2817,2316324,00.asp</link>
                <runningtime>6.5</runningtime>
                <image>router.jpg</image>
                </title>
                <title>
                <name>529 Tips for Better Computing.</name>
                <author>Our vast list of tips includes computing basics as well as multimedia, mobility, business, and online solutions.</author>
                <link> http://www.pcmag.com/article2/0,2817,2282468,00.asp</link>
                <runningtime>9.25</runningtime>
                <image>tips.jpg</image>
                </title>
                </titles>
                • 5. Re: 5 Elements in XML. 1 is not responding.
                  VarioPegged Level 2
                  Try setting the explicitWidth property on the Text in your itemRenderer. Also, make sure that your math is correct when setting absolute values. BTW, you have a bunch of unnecessary instantiations of HBox ... there's no point in wrapping a single element in an HBox (or VBox for that matter), your component is already an HBox. Finally, condenseWhite only works with htmlText. Reworked itemRenderer below.

                  TS
                  • 6. Re: 5 Elements in XML. 1 is not responding.
                    Shelady Level 1
                    :) thanks a million.