A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Little help with my class

  1. #1
    Senior Member
    Join Date
    Aug 2002
    Location
    Philadelphia, PA
    Posts
    274

    Little help with my class

    I'm making a class for an image viewer movieclip. Right now the movieclip sits on the main timeline and is called fullSizeViewer_mc, the linkage identifier as well as the class name is fullSizeViewer. The only thing in the movieclip is another clip called bg_mc. This clip is supposed to function similar to a "lightbox". bg_mc fades in covering the entire stage, an image is loaded above it. when a user clicks on bg_mc it calls a function (fadeOut) to remove the clip picHolder_mc and fade out. my function is being called because my trace statement in it fires, but bg_mc is not fading out and I'm unable to remove the picHolder_mc clip.

    This is really my first dive into OOP so any help here would be appreciated.

    Code:
    import mx.transitions.easing.*; 
    import mx.transitions.Tween;
    
    class FullSizeViewer extends MovieClip {
    
    	private var preloader_mc:MovieClip;
    	private var picHolder_mc:MovieClip;
    	private var bg_mc:MovieClip;
    	private var bgFade:Tween;
    	private var imageFade:Tween;
    
    	public function FullSizeViewer() {
    		this.swapDepths(_root.getNextHighestDepth());
    		bg_mc._width = Stage.width;
    		bg_mc._height = Stage.height;
    		bg_mc._x = 0;
    		bg_mc._y = 0;
    		bg_mc._alpha = 0;
    	}
    
    	public function loadImage(_image:String):Void {
    		bgFade = new Tween(bg_mc, "_alpha", Regular.easeOut, bg_mc._alpha, 85, .5, true);
    		picHolder_mc = this.createEmptyMovieClip("picHolder_mc", 1);
    		picHolder_mc._alpha = 0;		
    		
    		this.attachMovie("MovieClipLoaderUI", "preloader_mc", 2);
    		centerClip(preloader_mc);			
    		preloader_mc.init(_image, picHolder_mc, this, imageLoaded);
    	}	
    
    	public function imageLoaded():Void {
    		centerClip(picHolder_mc);
    		imageFade = new Tween(picHolder_mc, "_alpha", Regular.easeOut, picHolder_mc._alpha, 100, .5, true);
    		bg_mc.onRelease = fadeOut;
    	}
    	
    	private function fadeOut():Void {
    		trace("wtf?");
    		bgFade = new Tween(bg_mc, "_alpha", Regular.easeOut, 100, 0, .5, true);
    		imageFade = new Tween(picHolder_mc, "_alpha", Regular.easeOut, 100, 0, .5, true);
    		removeMovieClip(picHolder_mc);
    	}
    	
    	private function centerClip(_clip:MovieClip):Void {			
    		_clip._x = (bg_mc._width - _clip._width) * .5;
    		_clip._y = (bg_mc._height - _clip._height) * .5;		
    	}
    	
    }
    Ohhhh jeez.......not again.

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Philadelphia, PA
    Posts
    274
    Anyone got any thoughts? I still haven't figured out why this isn't working for me. OOP is frustrating sometimes.
    Ohhhh jeez.......not again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center