Problem with external SWF loading

I have a SWF download in a SWF containing a papervision scene.

I did this before the problem occurred, I get an error message - I'm not sure what the problem really is.

    private function downloadSWF(url:String):void
  {
   trace(url);
   var urlRequest:URLRequest = new URLRequest(url);
   var loader:Loader = new Loader(); 
   loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loaderProgressEventHandler);
   loader.load(urlRequest);
  }



 private function loaderProgressEventHandler(ev:ProgressEvent):void
  {

   loader.preloaderCircle.percent = ev.bytesLoaded / ev.bytesTotal;
  }

When the application runs the code, I get an error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at com.dehash.pv3d.examples.physics::WowDemo()

Why do I get this if the download is not completed yet?

Thanks in advance guys.


Edit: Try an empty child swf, see if the other one is trying to access something in the parent element. - Jorge

I did this, it seems, even using a simple SWF with a mouse listener causes an error:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at simple_fla::MainTimeline/frame1()

My code for this:

import flash.events.MouseEvent;

this.stage.addEventListener(MouseEvent.CLICK, onClick);

function onClick(ev:MouseEvent):void
{
    trace("MouseClick");
}

Did I miss something obviously obvious?

+3
source share
3 answers

, swf . , stage null, .

addToStageEventHandler , stage , , stage .

. , swf , stage.

+3

, . unreferenced WowDemo()... ?

+1

, , SWF:

this.addEventListener(Event.ADDED_TO_STAGE, addedToStageEventHandler);

function onClick(ev:MouseEvent):void
{
    trace("MouseClick");
    var event:Event = new Event("END", true, false);
    this.dispatchEvent(event);
}

function addedToStageEventHandler(ev:Event):void
{
    this.stage.addEventListener(MouseEvent.CLICK, onClick);

}

- , ?

0

Source: https://habr.com/ru/post/1742645/


All Articles