Mega Code Archive

 
Categories / Flex / Event
 

Use Timer event to track flash total memory

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"   initialize="initTimer()">   <mx:Script>     import mx.collections.ArrayCollection;     import flash.utils.Timer;     import flash.events.TimerEvent;     [Bindable]     public var time:Number = 0;     [Bindable]     public var totmem:Number = 0;     public function initTimer():void {         var myTimer:Timer = new Timer(1000, 0);         myTimer.addEventListener("timer", timerHandler);         myTimer.start();    }    public function timerHandler(event:TimerEvent):void {        time = getTimer()        totmem = flash.system.System.totalMemory;    }   </mx:Script>   <mx:Form>     <mx:FormItem label="Time:">       <mx:Label text="{time} ms" />     </mx:FormItem>     <mx:FormItem label="Total Memory:">       <mx:Label text="{totmem} bytes" />     </mx:FormItem>   </mx:Form> </mx:Application>