5 Replies Latest reply on Jul 18, 2009 11:57 AM by dmfsantacruz

    a few questions on my script

    dmfsantacruz

      here is my script

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1920" height="1080"
      creationComplete="inventoryService.send()" borderColor="#797979" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#636363, #9A9A9A]" color="#F3F3F3">
      
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      [Bindable]
      private var omArray:ArrayCollection
      private function resultHandler(event:ResultEvent):void
      {
      
      omArray = event.result.response.data.row;
      
      }
      
      
      ]]>
      </mx:Script>
      
      <mx:HTTPService id="inventoryService"
      url="http://localhost/OMRON-debug/Inventory.php?method=FindAll"
      result="resultHandler(event)"/>
      
      <mx:VBox width="1900" height="1060" x="10" y="10" borderColor="#7F8081">
      <mx:ToggleButtonBar dataProvider="{mainStack}"/>
      <mx:ViewStack id="mainStack" width="100%" height="100%">
      <mx:HBox label="OVERVIEW" width="100%" height="100%">
      <mx:Tile width="100%" height="100%">
      <mx:Repeater id="omRepeater" dataProvider="{omArray}">
      <mx:HBox width="271" height="353">
      <mx:VBox>
      <mx:HBox>
      <mx:Text text="Machine:{omRepeater.currentItem.machine_id}"/>
      <mx:Text text="Location:{omRepeater.currentItem.location}"/>
      </mx:HBox>
      <mx:HBox>
      <mx:Text text="OS Status:{omRepeater.currentItem.os_status}"/>
      <mx:Text text="Software Status:{omRepeater.currentItem.om_status}"/>
      </mx:HBox>
      <mx:Tile width="100%" height="100%">
      
      <mx:Text text="1:{omRepeater.currentItem.coin_01}"/>
      <mx:Text text="5:{omRepeater.currentItem.coin_05}"/>
      <mx:Text text="10:{omRepeater.currentItem.coin_10}"/>
      <mx:Text text="25:{omRepeater.currentItem.coin_25}"/>
      </mx:Tile>
      <mx:Tile width="100%" height="100%">
      <mx:Text text="1:{omRepeater.currentItem.bill_1}"/>
      <mx:Text text="5:{omRepeater.currentItem.bill_5}"/>
      <mx:Text text="10:{omRepeater.currentItem.bill_10}"/>
      <mx:Text text="20:{omRepeater.currentItem.bill_20}"/>
      <mx:Text text="50:{omRepeater.currentItem.bill_50}"/>
      <mx:Text text="100:{omRepeater.currentItem.bill_100}"/>
      </mx:Tile>
      <mx:HBox>
      
      </mx:HBox>
      <mx:HBox>
      <mx:Text text="Running Total:{omRepeater.currentItem.bill_100}" textAlign="center"/>
      </mx:HBox>
      </mx:VBox>
      
      </mx:HBox>
      </mx:Repeater>
      </mx:Tile>
      
      </mx:HBox>
      <mx:HBox label="RAW DATA">
      
      </mx:HBox>
      <mx:HBox label="SETTINGS">
      
      </mx:HBox>
      </mx:ViewStack>
      </mx:VBox>
      </mx:WindowedApplication>
      
      
      
      

       

      I need to be able to do a few things.

       

      1. Instead of doing the database query on creationComplete I need it to reload the database info "live" or every 10 seconds or so.

      2. Right now the {omRepeater.currentItem.bill_xx} entries are raw count data from the database. I need to multiply this number by the bill type (5,10,20 etc) and display the actual currency amount.

      3. For each entry I need to create a vertical bar graph. I checked out the bar graph component example but I cant figure out how to plug the database array into it.

       

      thanks!!!

        • 1. Re: a few questions on my script
          rgadiparthi Level 2

          1. create a timer for 10 sec and add eventlistner to call the database.

           

          2.once you get the data from database do the calculations and then bind it the component.

           

          3. wht is your dataprovider for bar graph??

           

          • 2. Re: a few questions on my script
            dmfsantacruz Level 1

            Thank you for the reply. I know some actionscript (v2) and some flex, so I am still a bit of a noob when it comes to interacting between the two and doing calls and binding. Any reference would be greatly appreciated!

             

             

            1. I will look up that call

            2. I know how to do the calc in actionscript, but I am not totally clear on getting the database data into the actionscript and back out.

            3. the omArray will be the data provider for the chart. each coin and each bill has a different range so I need the graph to represent 0-100% of their designated maximum. ie. the maximum pennies is 2000 and there are 1000 in the machine. the bar graph needs to read 50%.

             

            cheers,

            -brian

            • 3. Re: a few questions on my script
              sri harsha namala Level 2

              Hi,

                  For this type of Application you can use ServerPush also which will  send the DataBase Data continously for 10 Seconds...

              • 4. Re: a few questions on my script
                aaravind Level 1

                Try out settimeout function...ur updatoin to the database should be written in a function..in settime out specify tat function name and specify the time after it ishould  be called(10000ms)

                • 5. Re: a few questions on my script
                  dmfsantacruz Level 1

                  While waiting for responses, I came up with this reload script after a little research. The only major problem is that it makes the entire page blink when it reloads. Any thoughts on improving or completely changing it to get rid of the blink and keeping everything efficient?

                  
                  

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

                  <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1920" height="1080"

                  creationComplete="dbTimer()" borderColor="#797979" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#636363, #9A9A9A]" color="#F3F3F3">

                   

                  <mx:Script>

                  <![CDATA[

                  import mx.controls.Text;

                  import mx.controls.Label;

                  import mx.collections.ArrayCollection;

                  import mx.rpc.events.ResultEvent;

                  [Bindable]

                  private var omArray:ArrayCollection

                  private function resultHandler(event:ResultEvent):void

                  {

                  omArray = event.result.response.data.row;

                   

                  }

                   

                  import flash.utils.Timer

                  import flash.events.TimerEvent

                  import flash.display.Sprite

                   

                  private function dbTimer():void

                  {

                  inventoryService.send();

                  var mTimer:Timer=new Timer(1000,10)

                  mTimer.addEventListener(TimerEvent.TIMER_COMPLETE,Comple);

                  mTimer.start();

                  }

                   

                  private function Comple(e:TimerEvent):void

                  {

                  inventoryService.send();

                  dbTimer();

                   

                  }

                   

                  ]]>

                  </mx:Script>