Skip to main content
Known Participant
March 27, 2013
Question

application loading complete

  • March 27, 2013
  • 6 replies
  • 999 views

hi.

i have an air app for ios with everything embedded in the primary swf and using a doc class and some classes. it uses large retina bitmaps and gpu rendering. i didn't think i would need a preloader since there is a splash screen that sort of handles that. i thought the splash screen displayed until the app is fully loaded. i used the addedtostage event for my start up function but I'm still getting inconsistencies for some opening animation tweens which are called after init. (sometimes frames are skipped etc when the app opens on my ipad3.)


how can i make sure the entire code is initialized before my animations begin? I'm not loading anything so i assume i can't use loader COMPLETE.


or maybe my doc class is setup incorrectly. here is what i did:


public function DocClass() {

  init();

}

public function init():void {

  ...initializing code...

  addEventListener(Event.ADDED_TO_STAGE, startUpAnimation);

}

function startUpAnimation(event:Event):void {

   ...

}

(btw, i embedded everything in one swf since i believe at the time, air for iOS would not allow opening external swfs. i think this has been corrected with air 3.7 beta)

thank you.

This topic has been closed for replies.

6 replies

Participating Frequently
March 30, 2013

I have had similar issues before. My method of dampering the stutter effect was to put things on separate frames and separate layers on the timeline. It seems like the fps will never be friendly on the first frame, so I decided to live with it. My method on Flash Pro is kind of like,

Frame #1 : only the splash screen that covers the whole screen (non transparent), which should be the same of the default screen of the app.

Frame #2 : load in things below the splash screen layer, but every movieClip is stop() on first frame.

Frame #3 : remove the splash screen.

Frame #4 : start all the necessary movieClip, or start only one movieClip per frame.

I guess the runtime will sacrifice fps just to make sure it loads in everything before moving onto the next frame. And things aren't loaded until they are on stage and visible (even if under the splash screen). While relying on the onLoad events doesn't seem to guarantee a smooth experience.

Since my app relies on timeline, this method seems to work for me. Not sure how Flash Builder handles that though. Good luck

brad5151Author
Known Participant
March 30, 2013

thanks alot eddy. this is very helpful to hear this technique you are using.

i am not using the flash IDE timeline for any animations so i don't use frames. maybe i'll try out a version of this at some point.

right now, i feel like the important part of  these techniques didn't work for me, though. as described in my previous post, i have tried placing movieclips underneath static images on the stage and it hasn't helped my performance. also all of my animations are delayed after startup already (using greensock tween "delay").

Participating Frequently
March 31, 2013

If your animations doesn't contain sound, how about trying something crazy.

1 : Set your FPS to a really large number and let the movieClip play under the splash screen.

2 : Using a counter or something, somehow check if all movieClip played once.

3 : All movieClip gotoAndStop(1);

4 : Set your FPS back to normal

5 : Remove the splash screen

6. Play your movieClips

If you have stop() at the end of the movieClip that will make it really easy. Just check if your movieClip.currentFrame == movieClip.totalFrames;

If your movieClip loops then add something like,

At root or stage,

     var isInitializing:Boolean = true;

Inside each movieClips at the last frame.

     if(MovieClip(root).isInitializing){ stop(); }

When you've removed the splash, just isInitializing= false;

Not sure if this helps though

brad5151Author
Known Participant
March 29, 2013

i tried out Adobe Scout on my app. i can see a cpu spike at about 95% and higher and a super low framerate for a few frames at the beginning.

this seems normal for the initial loading frame. but the spike is still occurring as the opening animation happens which makes it stutter. this animation occurs again later but without any stuttering.

i also get a major stutter later, when the main control panel opens which is a huge graphic. this seems to be expected. it happens on addChild.

except!:

i tried moving the addChild into the init function since this control panel will eventually have to used for the app to function. if i set its visibility to false during init, then set it to visible when the panel is called later, i get the exact same spike i saw before. so this didn't help at all. its its visible and offstage, i move it back on stage as the panel is called and i get the same problem.

the only way i could remove the cpu spike was to addchild during init and set its visibility to true but hide it under my main stage graphic. then later when the control panel is called i just bring it to the front with setChildIndex.

i thought i was saved from this big framerate slowdown at last, but it made the opening animations stutter even worse. in scout i can see that adding the graphic in init, causes the cpu to spike and the framerate to decrease over several frames. so really its worse than before.

is my app just too bloated and ridiculous to work in air? boy, i'm scared of that answer!! hehe. i'm not a great programmer and i'm sure the code could be much cleaner. i tried to avoid many things listed as performance hungry. but i could not go without bitmaps with transparency. so lots of those.

so the big questions:

how to make the opening animation without stuttering? (i know it can work since it doesn't stutter on the 2nd attempt at the same animation.)

how to remove the framerate slowdown caused by displaying a large control panel?

any thoughts?

thanks.