开发者

Flash to iPhone Very Slow Performance

开发者 https://www.devze.com 2023-03-13 12:17 出处:网络
I\'m creating an iPhone app in Flash, and I\'ve run into performance problems. I\'ve stripped the entire thing down to a simple example (below). It draws a box to the screen, and uses TouchEvent to tr

I'm creating an iPhone app in Flash, and I've run into performance problems. I've stripped the entire thing down to a simple example (below). It draws a box to the screen, and uses TouchEvent to track finger gestures. Here's the problem: it is extremely sluggish on the iPhone 3G I am testing on. The box stutters up and down the page.

GPU mode is enabled in the application.xml, and when I set the -renderingdiagnostics flag, the text turns blue (meaning it is being rendered each time, which is correct), but the square stays white. It doesn't turn any of the three colors of diagnostics mode. Here is a screen of that:

http://whit.info/dev/flashapp/screen.jpg

And here is a video of the sluggishness:

http://vimeo.com/25160240

So, given that this is only one cached sprite moving vertically, am I missing something about enabling the GPU or bitmap caching? Or is this as good as it gets on this hardware? Other apps seem to glide brilliantly.

Can anyone assist?

Many thanks!

-Whit

package {

import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;

[SWF(width='320', height='480', backgroundColor='#B开发者_开发知识库ACC00', frameRate='60')]

public class Main extends MovieClip{
    private var square:Sprite;  
    private var txt:TextField;  
    private var startDragY:Number;
    private var startObjY:Number;

    public function Main(){
        Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;

        stage.addEventListener(TouchEvent.TOUCH_BEGIN, beginhandler); 
        stage.addEventListener(TouchEvent.TOUCH_MOVE, movehandler); 
        stage.addEventListener(TouchEvent.TOUCH_END, endhandler);

        drawBox(0xffffff);
        makeOutput();
    }

    private function beginhandler(evt:TouchEvent): void { 
        startDragY = evt.stageY;
        startObjY = square.y;
    }

    private function movehandler(evt:TouchEvent): void { 
        out(String(evt.stageY));
        square.y = startObjY - (startDragY - evt.stageY); 
    }

    private function drawBox(fill:Number):void {
        square = new Sprite();

        square.graphics.beginFill(fill);
        square.graphics.drawRect(20,60,40,40);
        square.graphics.endFill();

        stage.addChild(square);
        square.cacheAsBitmap = true;
    }

    private function makeOutput():void {
        txt = new TextField();
        stage.addChild(txt);
        txt.selectable = false; 
        txt.autoSize = TextFieldAutoSize.CENTER;
        txt.defaultTextFormat = new TextFormat("Arial", 22, 0x000000);
        txt.text = "Touch Screen";
        txt.x = stage.stageWidth/2 - txt.width/2;
        txt.y = stage.stageHeight/2 - txt.height/2;
    }

    private function out(str:String):void {
        txt.text = str;
    }
}
}

Also, here are the commands I'm using to compile:

.amxmlc ~/Files/Code/iOS/MyApp/Main.as

.pfi -package -renderingdiagnostics -target ipa-test -provisioning-profile MyApp.mobileprovision -storetype pkcs12 -keystore Certificates.p12 -storepass MyPass MyApp.ipa application.xml Main.swf Default.png icons


Latest Adobe updates are meant for the devices.

Our team was also facing the same problem and kinda solved the problem by updating the products.

We updated to:

Flash professional CS5.5 
AIR 2.7 

and the performance difference is noticeable.


Which version of the Flash exporter are you using? The CS5.5 update allegedly came with some speed boosts.

Also, the iPhone 3g on iOS 4 is already memory starved and I wouldn't be surprised if you were running out of memory with AIR loaded.


If you want good animation performance on an iPhone 3G (perhaps any iOS device), write your app in Objective C using Apple's provided Xcode tools. The result will run tons faster and eat up far less of your customer's device's battery and memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消