A.Zidan
A.Zidan

Reputation: 563

External swf plays very slow on iOS

I'm writing an application using as3 and adobe air that loads external SWF files and plays them internally in the application. The container works just fine with android and the animation of the external swf file is very cool.

However, on the iOS (iPad 2), it runs very slow as if its playing only 1 frame per second.

Is there anyway at all to make it play faster.

My application configuration is as follow:

<initialWindow>
    <autoOrients>false</autoOrients>
    <aspectRatio>landscape</aspectRatio>
    <renderMode>gpu</renderMode>
    <fullScreen>false</fullScreen>
    <visible>true</visible>
    <softKeyboardBehavior>none</softKeyboardBehavior>
</initialWindow>

This is the part of code where I load the external swf:

    public function set url(value:String):void
    {
        _url = value;
        object.source = File.applicationDirectory.resolvePath(value).url;
        object.addEventListener(Event.COMPLETE , onLoaded);
    }

    protected function onLoaded(event:Event):void
    {
        object.addEventListener(Event.ENTER_FRAME, onEnterFrame);

    }
    protected function onEnterFrame(event:Event):void
    {
        if((object.content as Object).currentFrameLabel == "stop")
            (object.content as Object).stop();
    }   

I also tried to comment the Enter frame event listener but nothing changed.

Thanks in advance.

Edit: I figured out something that is very strange actually. When I run the application from the application with the Fast configuration, it runs fast. But when I publish it or use the Standard option while running it runs really slow. Tested with AIR 3.2

Upvotes: 2

Views: 1168

Answers (2)

Hoecuspocus
Hoecuspocus

Reputation: 302

A couple of things:

You aren't allowed to load SWFs that have any code in them, in AIR for iOS. This is forbidden by Apple.

You should only use swf at most as a library of graphics / resources when compiling for iOS. If a movieclip inside has stop(); on one of the frames, then this counts as an 'addFrameScript()' under the hood, which means that SWF contains ActionScript.

I suggest if you need functionality as such, create a list of predefined behaviours to be compiled into your main app, then run these behaviours based on the type or name of asset you are instantiating from your SWF library, attaching them at runtime.

Besides, if you are doing this to allow updates -- or the ability to modify the app, post-release, then you may as well compile it into the release build, and just republish next time you want an update to the app. This will help your ranking in the app store to some extent, and remove a lot of versioning issues down the line.

Upvotes: 0

anber
anber

Reputation: 874

try setting your render mode to direct:

<renderMode>direct</renderMode>

Remember, when you are rendering exclusively to the GPU, it will slow things down if you are rendering animations. Although rendering to the GPU is fast, allocating Video Memory to the GPU is slow. If you render exclusivity to the GPU, on every frame, the video memory will need to be updated.

Another thing is that all vectors will be rasterized so some things will render pixelated.

Upvotes: 0

Related Questions