Class not loading, error 2007

i have two classes wich i should load to stage, both works fine when linked to a mc and dragged from library but when i try to added to stage using as i get “TypeError: Error #2007: Parameter child must be non-null.”
any idea??
here is the code of the class that “works” when inserted:


package {
    
import flash.display.Sprite;
import caurina.transitions.Tweener;
import flash.events.*;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Shape;
import flash.text.*;


public class slide extends MovieClip {
    // delay between slides
    const TIMER_DELAY:int = 500;
    // fade time between slides
    const FADE_TIME:int =    1;
    //contenedor del slide
    public var mcSlideHolder:MovieClip;
    // reference to the current slider container
    private var currentContainer:Sprite;
    // index of the current slide
    private var intCurrentSlide:int = -1;
    // total slides
    private var intSlideCount:int;
    // timer for switching slides
    private var slideTimer:Timer;
    // slides holder
    private var sprContainer1:Sprite;
    private var sprContainer2:Sprite;
    // slides loader
    private var slideLoader:Loader;
    // url to slideshow xml
    private var strXMLPath:String = "slideshow-data.xml";
    // slideshow xml loader
    private var xmlLoader:URLLoader;
    // slideshow xml
    private var xmlSlideshow:XML;
    private var mascaraFotos:Shape;
    private var botonPhoto:Sprite;
    private var envio:TextField;
    public var retratos:photoBooth;

public function slide()
{
    // create new urlloader for xml file
    xmlLoader = new URLLoader();
    // add listener for complete event
    xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
    // load xml file
    xmlLoader.load(new URLRequest(strXMLPath));
    // create new timer with delay from constant
    slideTimer = new Timer(TIMER_DELAY);
    // add event listener for timer event
    slideTimer.addEventListener(TimerEvent.TIMER, switchSlide);
    
    mcSlideHolder = new MovieClip;
    addChild(mcSlideHolder);
    mascaraFotos = new Shape;
    mascaraFotos.graphics.beginFill(999999, 1);
    mascaraFotos.graphics.drawRect(0,0,753,492);
    mascaraFotos.graphics.endFill();
    //addChild(mascaraFotos);
    mascaraFotos.x=114;
    mascaraFotos.y=105;
    // create 2 container sprite which will hold the slides and
    // add them to the masked movieclip
    sprContainer1 = new Sprite();
    sprContainer2 = new Sprite();
    mcSlideHolder.addChild(sprContainer1);
    //sprContainer1.x = 114;
    //sprContainer1.y = 105;
    
    mcSlideHolder.addChild(sprContainer2);
    //sprContainer2.x = 114;
    //sprContainer2.y = 105;
    // keep a reference of the container which is currently
    // in the front
    currentContainer = sprContainer2;
    
///////////////////////////boton para cargar photobooth
    botonPhoto = new Sprite;
    addChild(botonPhoto);
    botonPhoto.graphics.beginFill(0x2A56B3);
    botonPhoto.graphics.moveTo(60,0);
    botonPhoto.graphics.lineTo(300,0);
    botonPhoto.graphics.lineTo(300,60);
    botonPhoto.graphics.lineTo(0,60);
    botonPhoto.graphics.lineTo(60,0);
    botonPhoto.x = 580;
    botonPhoto.y =538;
    botonPhoto.buttonMode = true;

    var formatEnvio:TextFormat            = new TextFormat();
    formatEnvio.font                    = "Aller";
    formatEnvio.color                    = 0xFFFFFF;
    formatEnvio.size                    = 30;
    formatEnvio.bold                    = true;
                        
    var envio:TextField            = new TextField();
    envio.autoSize                  = TextFieldAutoSize.LEFT;
    envio.antiAliasType         = AntiAliasType.ADVANCED;
    envio.width                    = 330;
    envio.wordWrap                = true;
    envio.defaultTextFormat     = formatEnvio;
    envio.text                  = "Send a Postcard";
    envio.x                        = 640;
    envio.y                        = 550;
    envio.mouseEnabled = false;
    addChild(envio);
    
    botonPhoto.addEventListener(MouseEvent.CLICK, envioPostcard)
        function envioPostcard(e:MouseEvent):void{
        retratos = new photoBooth;
        addChild(retratos);
        
    }
}
    
function onXMLLoadComplete(e:Event):void {
    // create new xml with the received data
    xmlSlideshow = new XML(e.target.data);
    // get total slide count
    intSlideCount = xmlSlideshow..image.length();
    // switch the first slide without a delay
    switchSlide(null);
}
    
function fadeSlideIn(e:Event):void {
    // add loaded slide from slide loader to the
    // current container
    currentContainer.addChild(slideLoader.content);
    // fade the current container in and start the slide timer
    // when the tween is finished
    Tweener.addTween(currentContainer, {alpha:1, time:FADE_TIME, onComplete:function() { slideTimer.start(); }});
}

function switchSlide(e:Event):void {
    // check, if the timer is running (needed for the
    // very first switch of the slide)
    if(slideTimer.running)
        slideTimer.stop();
    
    // check if we have any slides left and increment
    // current slide index
    if(intCurrentSlide + 1 < intSlideCount)
        intCurrentSlide++;
    // if not, start slideshow from beginning
    else
        intCurrentSlide = 0;
    
    // check which container is currently in the front and
    // assign currentContainer to the one that's in the back with
    // the old slide
    if(currentContainer == sprContainer2)
        currentContainer = sprContainer1;
    else
        currentContainer = sprContainer2;
    
    // hide the old slide
    currentContainer.alpha = 0;
    // bring the old slide to the front
    mcSlideHolder.swapChildren(sprContainer2, sprContainer1);
    mcSlideHolder.mask = mascaraFotos;
    mcSlideHolder.x = 114;
    mcSlideHolder.y = 105;
    // create a new loader for the slide
    slideLoader = new Loader();
    // add event listener when slide is loaded
    slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeSlideIn);
    // load the next slide
    slideLoader.load(new URLRequest(xmlSlideshow..image[intCurrentSlide].@src));

    
    }
  }
}

this is the one that does not work


package  {
    
    import flash.display.MovieClip;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import com.adobe.images.JPGEncoder;
    import com.greensock.*;
    import flash.events.Event;
    import flash.sampler.NewObjectSample;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.desktop.Clipboard;
    import flash.desktop.ClipboardFormats;
    import flash.events.MouseEvent;
    import fl.containers.UILoader;
    import flash.text.*;
    import flash.media.Camera;
    import flash.media.Video;
    
    
    public class photoBooth extends MovieClip {
        private var baseGral:Sprite;
        private var capture_mc:Sprite;
        private var formatBTNCaptura:TextFormat;
        private var BTNCaptura:TextField;
        private var bandwidth:int;
        private var quality:int;
        private var cam:Camera;
        private var video:Video;
        private var bitmapData:BitmapData;
        private var fotoCliente:MovieClip;
        private var sombreado:Sprite;
        private var formatoInstrucciones:TextFormat;
        private var textoInstrucciones:TextField;
        private var conteo:contador;
        private var luzSonrien:Sprite;
        private var fondoLoader:UILoader;
        private var bitmap:Bitmap;
        private var custom:Bitmap;
        private var tryAgain:Sprite; 
        private var myFormatSalida:TextFormat;
        private var textoTryAgain:TextField;
        private var sendIt:Sprite;
        private var textoSendIt:TextField;
        private var frames:Number;
        
        
        public function photoBooth() {
            
            ////////////////////base de todo
    baseGral = new Sprite();
    baseGral.graphics.beginFill(0x4d4d4d);
    baseGral.graphics.moveTo(40, 0);
    baseGral.graphics.lineTo(600, 0); 
    baseGral.graphics.curveTo(640, 0, 640, 40);
    baseGral.graphics.lineTo(640,600);
    baseGral.graphics.curveTo(640, 640, 600, 640);
    baseGral.graphics.lineTo(40, 640); 
    baseGral.graphics.curveTo(0, 640, 0, 600);
    baseGral.graphics.lineTo(0, 40);
    baseGral.graphics.curveTo(0, 0, 40, 0);
    baseGral.graphics.beginFill(0x4d4d4d);
    baseGral.graphics.drawCircle(630, 10, 55);
    baseGral.graphics.beginFill(0x4d4d4d);
    baseGral.graphics.lineStyle(12, 0xFFFFFF);
    baseGral.graphics.drawCircle(630, 10,40);
    baseGral.graphics.moveTo(600, -15);
    baseGral.graphics.lineTo(660, 35);
    baseGral.graphics.moveTo(600, 35);
    baseGral.graphics.lineTo(660, -15);
    addChild(baseGral);

    baseGral.x = 363;
    baseGral.y = 75;

/////////////////////////////boton de acaptura
    capture_mc = new Sprite;
    addChild(capture_mc);
    capture_mc.graphics.beginFill(0x002B8D);
    capture_mc.graphics.lineStyle(1, 0x333333);
    capture_mc.graphics.drawCircle(685, 635, 55);
    capture_mc.graphics.beginFill(0x647DB7);
    capture_mc.graphics.drawCircle(685, 635, 50);
    capture_mc.graphics.beginFill(0x002B8D);
    capture_mc.graphics.drawCircle(685, 635, 48);
    
    formatBTNCaptura = new TextFormat;
            formatBTNCaptura.size = 60;
            formatBTNCaptura.font = "Aller";
            formatBTNCaptura.bold = true;
            //formatBTNCaptura.align = "center";
    BTNCaptura = new TextField();
            BTNCaptura.defaultTextFormat = formatBTNCaptura;
            BTNCaptura.antiAliasType = AntiAliasType.ADVANCED;
            BTNCaptura.text = "Go";
            BTNCaptura.textColor = 0xFFFFFF;
            BTNCaptura.width = 550;
            BTNCaptura.height = 90;
            BTNCaptura.x = 645;
            BTNCaptura.y = 600;
            BTNCaptura.wordWrap = true;
            BTNCaptura.mouseEnabled = false;
            addChild(BTNCaptura);
            
////////////////////////////seteo video y foto
bandwidth = 100;
quality = 100; // This value is 0-100 with 1 being the lowest quality. 
cam = Camera.getCamera()
    cam.setQuality(bandwidth, quality);
    cam.setMode(500,375,30,false); // setMode(videoWidth, videoHeight, video fps, favor area)
video = new Video(500, 375);
    video.attachCamera(cam);
    video.scaleX = -1;
    video.x = 930;
    video.y = 145;
    addChild(video);
 
bitmapData = new BitmapData(video.width,video.height);

///////////////////contenedor postal
fotoCliente = new MovieClip;
    
///////////////////oscurecimiento de fondo postal
sombreado = new Sprite;
sombreado.graphics.beginFill(0x000000, .7);
sombreado.graphics.drawRect(0, 0, 1400, 800);
sombreado.x = -700;
sombreado.y = -400;
fotoCliente.addChild(sombreado);

/////////////////////texto instrucciones
formatoInstrucciones = new TextFormat();
            formatoInstrucciones.size = 25;
            formatoInstrucciones.font = "Aller";
            formatoInstrucciones.bold = true;
            formatoInstrucciones.align = "center";
    textoInstrucciones = new TextField;
            textoInstrucciones.defaultTextFormat = formatoInstrucciones;
            textoInstrucciones.antiAliasType = AntiAliasType.ADVANCED;
            textoInstrucciones.text = "Take a picture to be used in your postcard. When ready hit the Go button";
            textoInstrucciones.textColor = 0xFFFFFF;
            textoInstrucciones.width = 550;
            textoInstrucciones.height = 90;
            textoInstrucciones.x = 408;
            textoInstrucciones.y = 518;
            textoInstrucciones.wordWrap = true;
            textoInstrucciones.mouseEnabled = false;
            addChild(textoInstrucciones);
            
///////////////////mc conteo
conteo = new contador;
addChild(conteo);
conteo.x = 688;
conteo.y = 616;
///////////////////flash para foto

luzSonrien = new Sprite;
luzSonrien.graphics.beginFill(0xFFFFFF);
luzSonrien.graphics.drawRect(0, 0, 1400, 800);
luzSonrien.x = 0;
luzSonrien.y = 0;

//////////////////////postal de tour
fondoLoader = new UILoader;
    fondoLoader.source = "postal.jpg";
    fondoLoader.x = -400
    fondoLoader.y = -300
    fondoLoader.width = 800;
    fondoLoader.height = 600;
    fotoCliente.addChild(fondoLoader);
    fotoCliente.x = 1366/2;
    fotoCliente.y = 768/2;

///////////////////foto de video
bitmap = new Bitmap(bitmapData);
    bitmap.x = 930;
    bitmap.y = 145;
    bitmap.scaleX = -1;
    bitmap.scaleY =  1;
    bitmap.visible=false;
    addChild(bitmap);

/////////////////////foto de la postal
custom= new Bitmap(bitmapData);
    custom.x = 393;
    custom.y = -138;
    custom.scaleX = -.75;
    custom.scaleY = .75
    custom.rotation = 6;
    fotoCliente.addChild(custom);

////////////////////boton tryAgain
tryAgain = new Sprite();
    addChild (tryAgain);
    tryAgain.graphics.beginFill(0x2B5CCc);
    tryAgain.graphics.lineStyle(4, 0x909090);
    tryAgain.graphics.moveTo(60, 20);
    tryAgain.graphics.lineTo(455, 20); 
    tryAgain.graphics.curveTo(490, 20, 490, 60);
    tryAgain.graphics.lineTo(490,80);
    tryAgain.graphics.lineStyle(4, 0x404040);
    tryAgain.graphics.curveTo(490, 120, 450, 120);
    tryAgain.graphics.lineTo(60, 120); 
    tryAgain.graphics.curveTo(20, 120, 20, 80);
    tryAgain.graphics.lineTo(20, 60);
    tryAgain.graphics.curveTo(20, 20, 60, 20);
    tryAgain.width = 490/3;
    tryAgain.height = 120/2.7;
    tryAgain.x = 430;
    tryAgain.y = 610;
    tryAgain.buttonMode = true;
    tryAgain.visible = false;
        
myFormatSalida = new TextFormat();
            myFormatSalida.size = 30;
            myFormatSalida.font = "Aller";
            myFormatSalida.bold = true;
textoTryAgain = new TextField();
            textoTryAgain.defaultTextFormat = myFormatSalida;
            textoTryAgain.antiAliasType = AntiAliasType.ADVANCED;
            textoTryAgain.text = "Try again";
            textoTryAgain.textColor = 0xFFFFFF;
            textoTryAgain.width = 400;
            textoTryAgain.height = 90;
            textoTryAgain.x = 452;
            textoTryAgain.y = 620;
            textoTryAgain.mouseEnabled = false;
            textoTryAgain.visible = false;
            addChild(textoTryAgain);
            
////////////////////////////boton sendIt
sendIt = new Sprite();
    addChild (sendIt);
    sendIt.graphics.beginFill(0x2B5CCc);
    sendIt.graphics.lineStyle(4, 0x909090);
    sendIt.graphics.moveTo(60, 20);
    sendIt.graphics.lineTo(455, 20); 
    sendIt.graphics.curveTo(490, 20, 490, 60);
    sendIt.graphics.lineTo(490,80);
    sendIt.graphics.lineStyle(4, 0x404040);
    sendIt.graphics.curveTo(490, 120, 450, 120);
    sendIt.graphics.lineTo(60, 120); 
    sendIt.graphics.curveTo(20, 120, 20, 80);
    sendIt.graphics.lineTo(20, 60);
    sendIt.graphics.curveTo(20, 20, 60, 20);
    sendIt.width = 490/3;
    sendIt.height = 120/2.7;
    sendIt.x = 760;
    sendIt.y = 610;
    sendIt.buttonMode = true;
    sendIt.visible = false;
        
    
textoSendIt = new TextField();
    textoSendIt.defaultTextFormat = myFormatSalida;
    textoSendIt.antiAliasType = AntiAliasType.ADVANCED;
    textoSendIt.text = "Send it";
    textoSendIt.textColor = 0xFFFFFF;
    textoSendIt.width = 400;
    textoSendIt.height = 90;
    textoSendIt.x = 795;
    textoSendIt.y = 620;
    textoSendIt.mouseEnabled = false;
    textoSendIt.visible = false;
    addChild(textoSendIt);

//////////////////trigger contador y foto
stage.addEventListener(Event.ENTER_FRAME, frameNumberText);
function frameNumberText(evt:Event):void {
    frames=conteo.currentFrame;
    if (conteo.currentFrame ==65)
    
    {
        captureImage();
        capture_mc.visible = false;
        BTNCaptura.visible = false;
        tryAgain.visible = true;
        textoTryAgain.visible = true;
        sendIt.visible = true;
        textoSendIt.visible = true;
    }
    
}
    
////////////////////comportamiento captura
    capture_mc.buttonMode = true;
    BTNCaptura.visible = true;
    capture_mc.addEventListener(MouseEvent.CLICK, countDown);
    
    tryAgain.addEventListener(MouseEvent.CLICK, reintento);

    function countDown(e:Event):void{
        tryAgain.visible =false;
        textoTryAgain.visible = false;
        sendIt.visible = false;
        textoSendIt.visible = false;
        capture_mc.visible = false;
        BTNCaptura.visible = false;
        conteo.play();
}

sendIt.addEventListener(MouseEvent.CLICK, postcard);
    function postcard(e:MouseEvent):void{
        addChild(fotoCliente);
    }
    
    ///////////////////////tomar foto de nuevo
    function reintento(e:Event):void{
        bitmap.visible = false;
        tryAgain.visible = false;
        textoTryAgain.visible = false;
        sendIt.visible = false;
        textoSendIt.visible = false;
        capture_mc.visible = true;
        BTNCaptura.visible = true;
    }
    
    
    ///////////////////////captura de imagen
    function captureImage():void {
        addChild(luzSonrien);
        luzSonrien.alpha = 1;
        luzSonrien.mouseEnabled = false;
        bitmap.visible = true;
        TweenMax.to(luzSonrien, 3, {alpha:0});
        TweenMax.delayedCall(.4, foto);
        TweenMax.delayedCall(3, apagon);
    
}
    function foto ():BitmapData{
        bitmapData.draw(video);
        return bitmapData;
}
     function apagon ():void{
         removeChild (luzSonrien)
 }
 

        }
    }
    
}

  


any help is welcome.

this line is the cause:


stage.addEventListener(Event.ENTER_FRAME, frameNumberText);

now my next question is how can i solve this? tried using this but didn’t work either.

solved this predicament changing “stage” for “this”