1 Reply Latest reply on May 22, 2007 1:54 PM by Newsgroup_User

    nested movie clips and as3

    zibber
      hi wondered if someone could help me as this problemo is really slowing me down an dmy head hurts:|

      in this instance what i want to do is load in an image into a movieclip that I have already created (by hand if u will ) and place don the stage. The main clip i have placed on the stage is called port and this is the code i am using to load it in.

      function showMainImage(event:MouseEvent):void {
      var mainLdr:Loader = new Loader();
      mainLdr.load(new URLRequest("images/" + event.currentTarget.imagePath));
      port.addChild(mainLdr);
      port.mainLdr.x = 2
      port.mainLdr.y = 2
      bitmap.visible = true;

      }

      the bit that throws up and error seems to be the two lines that try and position the clip. I get the following as an error message:

      TypeError: Error #1010: A term is undefined and has no properties.
      at AS3_main_fla::MainTimeline/showMainImage()

      its really got me stumped this one and in this respec tlife used to be much easier with as2:) but i know the benefits are there so i will stop whining.

      can anyone help me please? a crate of belgian beer is in it if u live close by;)

      reagards

      ade
        • 1. Re: nested movie clips and as3
          Level 7
          var mainLdr is a local variable within your function, not one defined within
          your port object. When you reference mainLdr to change its location, you
          simply use mainLdr, not port.mainLdr.


          "zibber" <webforumsuser@macromedia.com> wrote in message
          news:f2vecq$scp$1@forums.macromedia.com...
          > hi wondered if someone could help me as this problemo is really slowing me
          > down
          > an dmy head hurts:|
          >
          > in this instance what i want to do is load in an image into a movieclip
          > that I
          > have already created (by hand if u will ) and place don the stage. The
          > main
          > clip i have placed on the stage is called port and this is the code i am
          > using
          > to load it in.
          >
          > function showMainImage(event:MouseEvent):void {
          > var mainLdr:Loader = new Loader();
          > mainLdr.load(new URLRequest("images/" + event.currentTarget.imagePath));
          > port.addChild(mainLdr);
          > port.mainLdr.x = 2
          > port.mainLdr.y = 2
          > bitmap.visible = true;
          >
          > }
          >
          > the bit that throws up and error seems to be the two lines that try and
          > position the clip. I get the following as an error message:
          >
          > TypeError: Error #1010: A term is undefined and has no properties.
          > at AS3_main_fla::MainTimeline/showMainImage()
          >
          > its really got me stumped this one and in this respec tlife used to be
          > much
          > easier with as2:) but i know the benefits are there so i will stop
          > whining.
          >
          > can anyone help me please? a crate of belgian beer is in it if u live
          > close
          > by;)
          >
          > reagards
          >
          > ade
          >