View Single Post
Codemonkey's Avatar Codemonkey Codemonkey is offline Super Moderator 2006-11-05 #16 Old  
014 - fading your mx.screens.Forms
Last edited by Codemonkey : 2007-05-06 at 02:25.
 
If you are working with Forms (mx.screens.Form), you can use this enhanced version to make your screens smoothly fade in/out when showing/hiding your form:

ActionScript Code:
  1. import mx.transitions.*;
  2. import mx.transitions.easing.*;
  3.  
  4. // use this class on your forms instead
  5. class codemonkey.util.BasicForm extends mx.screens.Form {
  6.     private var __visible:Boolean = false;
  7.    
  8.     public function BasicForm() {
  9.         this.addEventListener("allTransitionsInDone", this);
  10.         this.addEventListener("allTransitionsOutDone", this);
  11.         this.createEmptyMovieClip("bg", this.getNextHighestDepth());
  12.     }
  13.     // display form (show/hide)
  14.     public function show(flag:Boolean) {
  15.         if (flag != this.__visible) {
  16.             this.__visible = flag;
  17.             this.visible = (__visible) ? true : this.visible;
  18.             var fadetype:Number = (flag) ? Transition.IN : Transition.OUT;
  19.             TransitionManager.start(
  20. this, {type:Fade, direction:fadetype, duration:1, easing:None.easeNone}
  21. );
  22.         }
  23.     }
  24.     // called by Flash' transition manager
  25.     private function allTransitionsInDone(eventObj:Object) {
  26.         this.visible = this.__visible;
  27.     }
  28.     private function allTransitionsOutDone(eventObj:Object) {
  29.         this.visible = this.__visible;
  30.     }
  31. }
To use this class, do as you normally would, but extend from the BasicForm class instead:

ActionScript Code:
  1. class LoadingScreen extends BasicForm {}
screenshot of applying your form in Flash