Advertisement
terorama

gallery9 / ZClip.as

Aug 28th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.    
  3.     import flash.display.MovieClip;
  4.     import flash.events.Event;
  5.     import flash.utils.*;
  6.    
  7.     public class ZClip extends MovieClip {
  8.        
  9.         public var target_alpha:Number;
  10.         public var prev_alpha:Number;
  11.        
  12.         private var isFE:Boolean=false;
  13.         private var lit:Boolean=false;
  14.        
  15.         //----------------------------------
  16.         public function ZClip() {
  17.            
  18.         }
  19.         //----------------------------------
  20.         public function goUp():void {
  21.            
  22.             if ((isFE) || (lit)) return;
  23.            
  24.             /*this.parent.setChildIndex(this,
  25.                                 this.parent.numChildren-1);*/
  26.            
  27.             prev_alpha=alpha;
  28.             target_alpha=1;
  29.             lit=true;
  30.            
  31.             if (!isFE) {
  32.                 isFE=true;
  33.                 addEventListener(Event.ENTER_FRAME, on_frame);
  34.             }
  35.             setTimeout(goDown,1500);
  36.         }
  37.         //----------------------------------
  38.         public function goDown():void {
  39.            
  40.             target_alpha=prev_alpha;
  41.                        
  42.             if (!isFE) {
  43.                 isFE=true;
  44.                 addEventListener(Event.ENTER_FRAME, on_frame);
  45.             }
  46.             lit=false;
  47.         }
  48.         //----------------------------------
  49.         private function on_frame(e:Event):void {
  50.            
  51.             var stepp:Number=(target_alpha-alpha)/10;  
  52.            
  53.             var alpha_p:Number=alpha;
  54.             alpha+=stepp;
  55.  
  56.             if (alpha_p==alpha) {
  57.                 removeEventListener(Event.ENTER_FRAME,on_frame);
  58.                 isFE=false;
  59.             }
  60.            
  61.         }
  62.  
  63.     }
  64.    
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement