2

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

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142
A.Zidan
  • 523
  • 4
  • 6
  • Since when can yopu load external swf on IOS? – The_asMan Sep 19 '12 at 14:58
  • You could always load external swf on iOS when they do not have code inside. And I didn't need much code, I just needed some stops at some places, I replaced the action script with the frameLabel "stop" and check for it in the code as you see in the ENTER_FRAME event handler. :) – A.Zidan Sep 19 '12 at 15:23
  • Check the FLA of the loaded SWF and verify that it is set to the same frame rate as the loader if that doesn't show anything then look here. http://community.stencyl.com/index.php?topic=11644.0 – The_asMan Sep 19 '12 at 19:24

2 Answers2

0

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.

anber
  • 864
  • 1
  • 12
  • 28
  • I tried the direct mode, still getting the same results. But thanks anyways. – A.Zidan Sep 20 '12 at 10:27
  • Cool, stick with direct render mode. Another thing that you may want to look at is that the movie you playing is not set to rendered to Bitmap or inside a container that is rendered to bitmap. Refreshing bitmap Data may also be your problem. Something else to consider is: Make sure that the animation SWF is NOT compiled as Debug. The setting is usually easy to miss and can cause slowdowns as well. Check in Flash's publishing settings, permit Debug should not be clicked. – anber Sep 21 '12 at 05:21
0

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.

Hoecuspocus
  • 192
  • 3
  • 11