2
\$\begingroup\$

I am currently working on making Android apps using AIR for Android.

This is a sample file and package that I am running to test the FPS and Memory usage of my application while it is not even doing anything,

it appears to hit flat at 6,975,488 FPS: 0

Which from what I can work out is 7 megabytes and a frame rate of 1/0 frames per second...

I was wondering if anyone could help me improve the way I write as3 in order to improve this and get my framerate back up to scratch.

Also I was wondering if people thought it was generally better to mix timeline and package coding or stick to just package/class coding.

Been working on this and my other file for a few days now, I am hoping to get some sleep and solve it in the morning as I know this file is a mess and that there is way too much going on in one file, but I thought after having cut everything out except the base key functions as well as leaving the memory/fps tracer there would bring the fps back up to 60 but it does not appear to have done so.

I have also noticed a blank AIR template running the mem/fps test seems to hit 60fps no problem, I guess I will just have to trace out that data 24/7 while developing so as to keep on top of it.

I apologise because I know my coding is terrible and probably very messy/poorly written.

Thank you for any help in advance.

package com.qr.maze{
import flash.desktop.NativeApplication
import flash.desktop.SystemIdleMode;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.utils.getTimer;
import flash.system.System;
[SWF(width="480",height="800",frameRate="60",backgroundColor="#000000")]
public class menu extends MovieClip{

    public function menu(){
        NativeApplication.nativeApplication.systemIdleMode=SystemIdleMode.KEEP_AWAKE;
        NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN,keyOn);
        NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE,onActivate);
        NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE,onDeactivate);
        NativeApplication.nativeApplication.addEventListener(Event.EXITING,onDeactivate);
        this.addEventListener(Event.ENTER_FRAME,performMemTest);
        this.addEventListener(Event.ENTER_FRAME,performFrameTest);
    }protected function keyOn(e:KeyboardEvent):void{
        if(e.keyCode==Keyboard.BACK){e.preventDefault();}
        else if(e.keyCode==Keyboard.HOME){onDeactivate(null);}
        else if(e.keyCode==Keyboard.MENU){e.preventDefault();}
    }protected function onActivate(e:Event):void{}
    protected function onDeactivate(e:Event):void{NativeApplication.nativeApplication.exit();}
    public function performMemTest(e:Event):void{trace(System.totalMemory);}
    public function performFrameTest(e:Event):void{
        var prevTimer:Number=0;
        var curTimer:Number=0;
        var frames:int;
        frames+=1;
        curTimer=getTimer();
        if(curTimer-prevTimer>=1000){
            trace("FPS: "); trace(Math.round(frames*1000/(curTimer-prevTimer)));
                prevTimer=curTimer;
                frames=0;
        }
    }
}
}
\$\endgroup\$
2
\$\begingroup\$

It appears I was just being tired and overworking on the file after having got some sleep and re made the file in timeline I am maintaining a steady memory usage and steady framerate, but the framerate appears to differ heavily on the Android Device.

I will continue working on this.

\$\endgroup\$
  • \$\begingroup\$ Dude! Does AIR actually work for Android devices? I thought AIR was just for desktop, while normal Flex builds for android, ios, and web... \$\endgroup\$ – Luis Masuelli Dec 22 '15 at 21:43
  • \$\begingroup\$ AIR works for mobile (Android & iOS) too. \$\endgroup\$ – dns Feb 12 '18 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.