6 Replies Latest reply on Jul 11, 2007 9:16 PM by NaveenRam

    Referencing a movieclip instance from an (loaded) external swf.

      Hi everybody

      I'm new to AS3. Even experienced in AS2, i'm a bit confused in getting the following result.

      Let's assume the following.

      The mainmovie has a movieclip instance called 'window1'. I need to have loaded a movieclip (submov.swf) in the mainmovie. As a final result a button is to be added to 'window1' after everytime an instance of submov is created.

      The document class of submov.swf is as follows

      import flash.display.*;
      import fl.controls.Button;
      public class submov extends Sprite
      function submov():void
      var firstbutton:Button = new Button();
      firstbutton.label = "Submit";
      stage.window1.addChild(firstbutton); //this is the place where error occurs (my assumption)

      the first frame of the mainmovie express the following code to load mainmov.

      import flash.display.*;
      import flash.net.URLRequest;

      var ldr:Loader = new Loader();
      var url:String = "mainmov.swf";
      var urlReq:URLRequest = new URLRequest(url);
      ldr.load(urlReq); // the first instance of mainmov created here

      var a:submov = new submov(); // the second instance of mainmov created here
      var b:submov = new submov(); // the third one created here

      so the final result must be the button symbol created three times in 'window1' (the position of the buttons may be ignored).

      But what i'm getting is an error reporting

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at submov$iinit()

      PLEASE HELP ME at this stage to overcome the problem.