# Little help with my class

**URL:** <https://forum.kirupa.com/t/little-help-with-my-class/230732>\
**Category:** flash\
**Created:** [June 28, 2007, 3:46pm UTC](https://forum.kirupa.com/t/little-help-with-my-class/230732 "2007-06-28T15:46:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quovadimus02](https://avatars.discourse-cdn.com/v4/letter/q/b3f665/32.png) [@quovadimus02](https://forum.kirupa.com/u/quovadimus02)\
**Post date:** [June 28, 2007, 3:46pm UTC](https://forum.kirupa.com/t/little-help-with-my-class/230732/1 "2007-06-28T15:46:10Z")

</div>

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.

```auto

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;        
    }
    
}

```
