1 Reply Latest reply on Dec 12, 2007 7:41 AM by dwkd

    Dynamic mc with onRelease = function attached Not working ??

    dwkd
      Hi
      Something is definitely wrong with my code here since i can`t get the created movie clips to have a function attached to them

      Here is my code

      -flash
      import flash.display.BitmapData;

      function loadXML(loaded) {
      if (loaded) {
      xmlNode = this.firstChild;
      image = [];
      image_height = [];
      image_width = [];
      total = xmlNode.childNodes.length;
      for (i=0; i<total; i++) {
      image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
      image_width = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
      image_height = xmlNode.childNodes.childNodes[2].firstChild.nodeValue;

      _parent.container_mc.createEmptyMovieClip("mc_" + i, this.getNextHighestDepth());

      _parent.container_mc["mc_" + i]._x = 30 * i;
      _parent.container_mc["mc_" + i]._y = (_parent.container_mc._height - image_height ) / 2;

      var target_mc:MovieClip;
      var mclListener:Object = new Object();
      mclListener.onLoadInit = function(target_mc:MovieClip) {
      var bitmap:BitmapData = new BitmapData(target_mc._width, target_mc._height, true);
      target_mc.attachBitmap(bitmap, target_mc.getNextHighestDepth(), "never", true);
      target_mc.clear();
      bitmap.draw(target_mc);
      target_mc._height = 250;
      target_mc._width *= target_mc._yscale/100;
      };


      this["image_" + i + "_mcl"] = new MovieClipLoader();
      this["image_" + i + "_mcl"].addListener(mclListener);
      this["image_" + i + "_mcl"].loadClip(image
      , _parent.container_mc["mc_" + i]);

      this.container_mc["mc_" + i].onRelease = function()
      {
      getURL(" http://www.google.com","_blank","GET");
      }

      }
      } else {
      content = "file not loaded!";
      }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("images.xml");

      -xml
      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <images>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/kresge.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/medialab.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/stata.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/stata_lobby.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/construction.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.v.com/developer/mx2004/pg/dome.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      <pic>
      <image> http://www.blabla.com/developer/mx2004/pg/structure.jpg</image>
      <image_width>300</image_width>
      <image_height>200</image_height>
      </pic>
      </images>

      The Reason i pasted the xml here is because i also have a problem outputing all 6 xml items
      It only ouputs the last one eventhough when i trace variables .. it loops through them just fine
      Thanks,
      -d