1 Reply Latest reply on Apr 27, 2006 4:45 PM by blemmo

    Attach Movie...How Do I reference the dynamic movieclips?

    GDrider
      I have a script I am working on and it loads xml and dynamically creates a movie clip for each xml node. This works, but I need to make each node a button, or at least be able to call a function on each node to basically pull up information about the particular node. I cannot figure out how to call on the dynamic movieclips....


      Here is my code...

      _global.d = this.canvas.depth++
      var mc = this.canvas.attachMovie(this._nodeSymbol ,"test",d ,{name:"node"+d});


      /////////////////////////////
      When I trace the output of this at the end of the movie with this code:
      //////////////////////////////////////////////

      for(each in geoPlotter_gp){
      var obj = geoPlotter_gp[each];
      if(obj instanceof MovieClip) {
      var objDepth = obj.getDepth();
      trace (obj._name + ":" + objDepth)
      }}

      for(each in geoPlotter_gp.canvas){
      var obj = geoPlotter_gp.canvas[each];
      if(obj instanceof MovieClip) {
      var objDepth = obj.getDepth();
      trace (obj._name + ":" + objDepth)
      }}

      //////////////////////////I get///////////////////////

      canvas:12
      background:-16383
      node9:9
      node8:8
      node7:7
      node6:6
      node5:5
      node4:4
      node3:3
      node2:2
      node1:1


      //////////////////So I am seeing "node1" and it is at a level of 1, but I cannot get to it...Any Ideas?
        • 1. Re: Attach Movie...How Do I reference the dynamic movieclips?
          blemmo Level 1
          The code you posted doesn't fit the output... MCs attached with
          var mc = this.canvas.attachMovie(this._nodeSymbol ,"test",d ,{name:"node"+d});
          would all have the instance name "test" and a "name" property with value "nodeX". The trace outputs the property "_name", which is different from "name", and should display the instance name ("test").
          To access the MCs, you would need "mc" (returned from the attachMovie function, if it's still valid), or "this.canvas.test", because the name on stage is "test". So I guess attachMovie is better this way:
          var mc = this.canvas.attachMovie(this._nodeSymbol ,"node"+d,d);
          then you can access the clips with "this.canvas.nodeX" (X standing for the node number).

          hth,
          blemmo