EasyCFM.COM ColdFusion Forums / Flex Development / Need some help... :)

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Need some help... :)

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Webmaster
08-10-2008 @ 3:30 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

I am trying to get this to work... what am I over looking?

The DataGrid works fine.. however what I want to do is populate the Label and Image items... Any help would be appreciated Wink

Basically I am invoking a web service.. that returns an array with a structure inside each array element... see image below, I am trying to reference the returned items in direct labels.. the DataGrid works fine but I don't want that... any suggestions?



This is the Flex application code I have thus far... Been a while since I worked in flex so I am pretty sure I am overlooking somthing stupid!

< ?xml version="1.0" encoding="utf-8"?>
< mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" applicationComplete="ws.returnRandomVehicleArray.send();">
     < mx:Script>
        < ![CDATA[
             import mx.rpc.events.ResultEvent;
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
            import mx.utils.ObjectUtil;
            import flash.utils.describeType;
            
            // Domain allow (cross domain calls)
            Security.allowDomain("http://www.carweek.com/");

            [Bindable]
            var aInventory:ArrayCollection;
               //var pDealerID:int = Application.application.parameters.dealerID;
               //var pNumOfVehicles:int = Application.application.parameters.NumOfVehicles;
               
               private function resultHandler(event:ResultEvent):void{
                    aInventory = event.result as ArrayCollection;
               }
        ]]>    
    < /mx:Script>
     < mx:WebService id="ws" wsdl="http://www.carweek.com/webservices/flashWS.cfc?wsdl" useProxy="false" showBusyCursor="true">
     
          < mx:operation name="returnRandomVehicleArray" result="resultHandler(event)" fault="Alert.show(event.fault.message)">
               < mx:request>
                     < numberOfVehicles>5< /numberOfVehicles>
                     < dealerID>347< /dealerID>
                < /mx:request>
          < /mx:operation>
          
     < /mx:WebService>
     
     < mx:Panel title="My Spotlight Inventory" height="206" width="670" paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5">

          < mx:Canvas width="621" height="154" id="pagecontainer">
               < mx:Canvas x="10" y="10" width="114" height="134">
                    < mx:Image x="10" y="10" width="94" height="93" id="inv_1_image" source="{aInventory.getItemAt(0).SmallImage}" />
                    < mx:Label x="10" y="111" width="94" id="inv_1_label" text="Year: {aInventory.getItemAt(0).inventory_year}"/>
               < /mx:Canvas>
               < mx:Canvas x="132" y="10" width="114" height="134">
                    < mx:Image x="10" y="10" width="94" height="93" id="inv_2_image" source="{aInventory.getItemAt(1).SmallImage}" />
                    < mx:Label x="10" y="111" width="94" id="inv_2_label" text="Year: {aInventory.getItemAt(1).inventory_year}" />
               < /mx:Canvas>
               < mx:Canvas x="254" y="10" width="114" height="134">
                    < mx:Image x="10" y="10" width="94" height="93" id="inv_3_image" source="{aInventory.getItemAt(2).SmallImage}" />
                    < mx:Label x="10" y="111" width="94" id="inv_3_label" text="Year: {aInventory.getItemAt(2).inventory_year}" />
               < /mx:Canvas>
               < mx:Canvas x="376" y="10" width="114" height="134">
                    < mx:Image x="10" y="10" width="94" height="93" id="inv_4_image" source="{aInventory.getItemAt(3).SmallImage}" />
                    < mx:Label x="10" y="111" width="94" id="inv_4_label" text="Year: {aInventory.getItemAt(3).inventory_year}" />
               < /mx:Canvas>
               < mx:Canvas x="498" y="10" width="114" height="134">
                    < mx:Image x="10" y="10" width="94" height="93" id="inv_5_image" source="{aInventory.getItemAt(4).SmallImage}" />
                    < mx:Label x="10" y="111" width="94" id="inv_5_label" text="Year: { aInventory.getItemAt(4).inventory_year}" />
               < /mx:Canvas>
          < /mx:Canvas>
          
     < /mx:Panel>
     < mx:DataGrid id="foo" dataProvider="{aInventory}" />

< /mx:Application>


Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

This message was edited by Webmaster on 8-10-08 @ 3:38 AM

kicker
08-10-2008 @ 5:47 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

This is probably one of the most frustrating things about working with data from cf to flex or any data source to flex.

Sometimes dependent on how you call the data and the db type, you need to play around with the actual column name to get the data to display. That being said in this case capitalize all the db column names in your code. That will fix the problem. So your call should look like this.

aInventory.getItemAt(0).SMALLIMAGE

Your stuff will work then already gave it a go.

Also if I may make a suggestion, not that it's absolutely needed, but it will help keep alot of problems from happening later is to make your aInventory variable either a public or private variable. Right now you have just this:

[Bindable]
var aIneventory:ArrayCollection;

This will help scope out the variable.  Wink

Craig

PS: It's nice to see that sometimes even the  master needs help.  Playful Wink

This message was edited by kicker on 8-10-08 @ 5:48 AM


Website Designed and Developed by Pablo Varando.