onStage instances being unexpectedly null

40 views Asked by At

I made a pre-loader for an SWF in the first frame i have following code

import flash.events.Event;
stop();
this.addEventListener(Event.ENTER_FRAME , onEnterHandler,false,0,false);
function onEnterHandler(e:Event)
{
    trace(progbar);
    trace(jot);
    trace(spark);
    progbar.width = (this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal) * 398;
    jot.x = progbar.x + progbar.width;
    jot.y = progbar.y;
    spark.x = jot.x;
    spark.y = jot.y + 10;
    jot.loadtext.text = String(Math.round(progbar.width / 398 * 100)) + " %";
    if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal)
    {
        gotoAndStop(2);
    }

}

when i run the code it gives the following output in output window .Below is just a part of the output

The thing which is confusig is at first trace statement produces the correct output but after that trace statements start to produce null

[object ProgBar]
[object Jot]
[object Spark]
null
null
null
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Final_fla::MainTimeline/onEnterHandler()
null
null
null
0

There are 0 answers