4 Replies Latest reply on Jul 24, 2009 8:36 AM by dmfsantacruz

    arranging loops

    dmfsantacruz

      soooo....

      progress is going well, but Im still having some base conceptual problems.

      I have my arraycollection which I am accessing individual items from and doing some basic math on.

      I need to display this newly calculated data in the repeater that I have, but mixing & matching the actionscript and MX is getting confusing.

       

      In php I would just create a for loop and have the php write the HTML portions and plug in the dynamic portions.

      can i create a similar for loop and have the actionscript write out the MX? or do I need to do the calculations separately and reimport them into an array and then use that array as a dataprovider?

       

      thanks!!

       

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

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

      creationComplete="init();" 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;

      import mx.utils.ObjectUtil

       

      private function init():void

      {

      inventoryService.send();

      dbTimer();

       

      }

       

      [Bindable]

      private var omArray:ArrayCollection

      private function resultHandler(event:ResultEvent):void

      {

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

      var omMachineID:Number

      var omMachineRecord:Object = omArray.getItemAt(2);

      trace(omMachineRecord.machine_id);

       

       

      }

       

      import flash.utils.Timer

      import flash.events.TimerEvent

      import flash.display.Sprite

       

      private function dbTimer():void

      {

      var mTimer:Timer=new Timer(10000)

      mTimer.addEventListener(TimerEvent.TIMER,Comple);

      mTimer.start();

      }

       

      private function Comple(e:TimerEvent):void

      {

      inventoryService.send();

       

      }

       

      ]]>

      </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:VBox width="262" height="353" borderStyle="solid" borderColor="#B7BABC">

      <mx:VBox width="100%">

      <mx:HBox width="100%">

      <mx:Text textAlign="left" text="Machine:{omRepeater.currentItem.machine_id}" fontWeight="bold" fontSize="16"/>

      <mx:ViewStack id="omStack" textAlign="right">

      <mx:VBox width="80" height="25" backgroundColor="#00FF00">

      <mx:Text text="OMRON SW" fontWeight="bold" color="#000000"/>

      </mx:VBox>

      <mx:VBox width="80" height="25" backgroundColor="#FF0000">

      <mx:Text text="OMRON SW"/>

      </mx:VBox>

      </mx:ViewStack>

      </mx:HBox>

      <mx:HBox>

      <mx:Text text="Location:{omRepeater.currentItem.location}" fontWeight="bold" fontSize="12"/>

      <mx:ViewStack id="osStack">

      <mx:VBox width="80" height="25" backgroundColor="#00FF00">

      <mx:Text text="SYSTEM SW" color="#000000" fontWeight="bold"/>

      </mx:VBox>

      <mx:VBox width="80" height="25" backgroundColor="#FF0000">

      <mx:Text text="SYSTEM SW"/>

      </mx:VBox>

      </mx:ViewStack>

      </mx:HBox>

      </mx:VBox>

       

       

      <mx:HBox>

       

      <mx:VBox width="125" height="100%">

      <mx:Text text="COINS" fontWeight="bold" color="#FEF500" textAlign="center"/>

      <mx:Text text="1¢:{omRepeater.currentItem.coin_01}" textAlign="center"/>

      <mx:Text text="5¢:{omRepeater.currentItem.coin_05}" textAlign="center"/>

      <mx:Text text="10¢:{omRepeater.currentItem.coin_10}" textAlign="center"/>

      <mx:Text text="25¢:{omRepeater.currentItem.coin_25}" textAlign="center"/>

      </mx:VBox>

      <mx:VBox width="125" height="100%">

      <mx:Text text="BILLS" fontWeight="bold" color="#FEF500"/>

      <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:VBox>

      </mx:HBox>

       

      <mx:HBox>

      <mx:Text text="Total: ${omRepeater.currentItem.bill_100}" textAlign="center" fontWeight="bold" fontSize="16" color="#E0EE00"/>

      <mx:Label id="lbltime"/>

      </mx:HBox>

       

       

       

      </mx:VBox>

      </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>