Bonbon4345 Calculating status...
Currently Being Moderated
performance issue on iPad
Dec 28, 2011 4:50 AM
Tags: none (add) #issue #ipad #chart #performance #animation #moving #animate #animatingHello everyone.
Im developing application for an iPad in Flash Builder 4.6 SDK 4.6.0 AIR 3.1 and i have a serious problem with making smooth animations, even with some simple objects that are not sprites. All i get is 5-10 fps while elements are moving. Normal it sticks to 60 fps.
I was trying to set renderMode to GPU with no luck.
My sample Main.xml looks like this (based on http://coenraets.org/blog/2011/04/scrollable-and-touch-friendly-flex-c harts/ ):
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="completeHandler()" cacheAsBitmap="true" cacheAsBitmapMatrix = "{new Matrix()}" frameRate="35">
<fx:Script>
<![CDATA[
protected var lastX:Number = 0;
[Bindable] protected var viewportMax:Number = 10;
[Bindable]
private var frames:int,curTimer:int,prevTimer:int;
[Bindable]
private var framerate:String;
protected function completeHandler():void
{
setInterval(updateFrameRate,1);
// Simulate values
var results:Array = [];
for (var i:int=0; i<50; i++)
{
results[i] = Math.random() * 100;
}
chart.dataProvider = results;
}
protected function mouseDownHandler(event:MouseEvent):void
{
lastX = event.stageX;
systemManager.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
systemManager.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
protected function mouseMoveHandler(event:MouseEvent):void
{
var delta:Number = (lastX - event.stageX) / chart.width * viewportMax;
if (hAxis.minimum + delta < 0)
{
hAxis.minimum = 0;
hAxis.maximum = viewportMax;
}
else if (hAxis.maximum + delta > chart.dataProvider.length - 1)
{
hAxis.maximum = chart.dataProvider.length - 1;
hAxis.minimum = hAxis.maximum - viewportMax;
}
else
{
hAxis.minimum += delta;
hAxis.maximum += delta;
}
lastX = event.stageX;
}
protected function mouseUpHandler(event:MouseEvent):void
{
systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseUpHandler);
}
private final function updateFrameRate():void
{
frames+=1;
curTimer=getTimer();
if(curTimer-prevTimer>=1000){
framerate = String(Math.round(frames*1000/(curTimer-prevTimer)));
prevTimer=curTimer;
frames=0;
}
memBox.text="MEM in MB: "+ String(Math.round(1000*System.totalMemory/1048576)/1000);
}
]]>
</fx:Script>
<mx:ColumnChart id="chart" top="100" left="10" width="400" height="250"
mouseDown="mouseDownHandler(event)" cacheAsBitmap="true" cacheAsBitmapMatrix = "{new Matrix()}">
<mx:series>
<mx:ColumnSeries />
</mx:series>
<mx:horizontalAxis>
<mx:LinearAxis id="hAxis" minimum="0" maximum="{viewportMax}"/>
</mx:horizontalAxis>
</mx:ColumnChart>
<s:VGroup>
<s:Label text="FPS: {framerate}" />
<s:Label text="" id="memBox" />
<s:Label text="test" id="storedLang" />
</s:VGroup>
</s:Application>
i'll be thankful for any help
TIA
726 Views
2 Replies
Latest reply:
kshi.gupta, May 21, 2012 3:35 AM


