2 Replies Latest reply on Jun 9, 2007 10:09 AM by _gary_

    loaded swf with button , not communicating to main timeline

    _gary_
      my main stage/timeline has a UILoader "UILoaderOne" and another one "UIloaderTwo".

      i have some buttons on the main stage which pull up some images into the UILoaderOne.
      these work fine and look like this.

      //BEGIN BUTTONCODE\\
      //button to load image into loader "loaderOne" x01_btn and x01_ldr, thumb image is "x01.jpg and main image is p01.jpg\\
      //crop thumb image to size 50px tall by whatever wide and resize loaderButton if needed, main image will resize proportionatly\\

      x01_btn.addEventListener(MouseEvent.CLICK, onClick);
      function onClick(event:MouseEvent):void
      {
      //import fl.containers.UILoader;
      import fl.controls.Label;
      import fl.controls.ProgressBar;

      var url:String = "assets/01.jpg";

      //var myUILoader:UILoader //= new UILoader();
      myUILoader.unload();
      myUILoader.autoLoad = false;
      myUILoader.source = url;
      //myUILoader.move(10, 10);
      myUILoader.scaleContent = true;
      myUILoader.load();

      var myProgressBar:ProgressBar = new ProgressBar();
      myProgressBar.source = myUILoader;
      myProgressBar.setSize(100, 10);
      myProgressBar.move(myUILoader.x+340, myUILoader.y+250)
      myProgressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler);
      myProgressBar.addEventListener(Event.COMPLETE, completeHandler);
      addChild(myProgressBar)

      var myLabel:Label = new Label();
      myLabel.text = ". . . . . X . . . . . ";
      myLabel.autoSize = TextFieldAutoSize.LEFT;
      myLabel.move(myProgressBar.x, myProgressBar.y + myProgressBar.height);
      addChild(myLabel);

      function progressHandler(event:ProgressEvent):void {
      //trace("progress:", event.bytesLoaded, event.bytesTotal, int(event.currentTarget.percentComplete) + "%");
      //myLabel.text = event.bytesLoaded + " of " + event.bytesTotal + " bytes loaded.";
      myLabel.text = ("progress:", event.bytesLoaded, event.bytesTotal, int(event.currentTarget.percentComplete) + "%")
      //myLabel.text = Math.round((event.bytesLoaded/event.bytesTotal)*100) +"%";
      }

      function completeHandler(event:Event):void {
      trace("complete:");
      myProgressBar.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
      myProgressBar.removeEventListener(Event.COMPLETE, completeHandler);
      removeChild(myProgressBar);
      removeChild(myLabel);

      //addChild(myUILoader);
      }

      //trace("typeMe");

      }
      //end BUTTONCODE\\
      //end BUTTONCODE\\

      the second Loader "UILoaderTwo" auto loads another swf file with the INTENT to load from buttons, images into the ULLoader "UILoaderOne" which is on the main timeline.

      this part is failing
      the error i get in Output window is
      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at sOne_fla::MainTimeline/onClickz()

      the swf that loads is sOne.swf

      and it has code of this

      z01_btn.addEventListener(MouseEvent.CLICK, onClickz);
      function onClickz(event:MouseEvent):void
      {
      import fl.containers.UILoader;
      import fl.controls.Label;
      import fl.controls.ProgressBar;

      var url:String = "assets/xx.jpg";

      var myUILoader:UILoader //= new UILoader();
      myUILoader.unload();
      myUILoader.autoLoad = false;
      myUILoader.source = url;
      //myUILoader.move(10, 10);
      myUILoader.scaleContent = true;
      myUILoader.load();

      var myProgressBar:ProgressBar = new ProgressBar();
      myProgressBar.source = myUILoader;
      myProgressBar.setSize(100, 10);
      myProgressBar.move(myUILoader.x+340, myUILoader.y+250)
      myProgressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler);
      myProgressBar.addEventListener(Event.COMPLETE, completeHandler);
      addChild(myProgressBar)

      var myLabel:Label = new Label();
      myLabel.text = ". . . . . X . . . . . ";
      myLabel.autoSize = TextFieldAutoSize.LEFT;
      myLabel.move(myProgressBar.x, myProgressBar.y + myProgressBar.height);
      addChild(myLabel);

      function progressHandler(event:ProgressEvent):void {
      //trace("progress:", event.bytesLoaded, event.bytesTotal, int(event.currentTarget.percentComplete) + "%");
      //myLabel.text = event.bytesLoaded + " of " + event.bytesTotal + " bytes loaded.";
      myLabel.text = ("progress:", event.bytesLoaded, event.bytesTotal, int(event.currentTarget.percentComplete) + "%")
      //myLabel.text = Math.round((event.bytesLoaded/event.bytesTotal)*100) +"%";
      }

      function completeHandler(event:Event):void {
      trace("complete:");
      myProgressBar.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
      myProgressBar.removeEventListener(Event.COMPLETE, completeHandler);
      removeChild(myProgressBar);
      removeChild(myLabel);

      //addChild(myUILoader);
      }

      //trace("typeMe");

      }
      //end BUTTONCODE\\
      //end BUTTONCODE\\