2 Replies Latest reply on Apr 24, 2008 10:34 AM by taosd2003

    Accessing Child Dynamic MovieClips

    taosd2003
      Dev Environment: Flash 9 Pro

      Alright, I have a movie that has one movieclip (imageHolder, this is defined in the Library and is an empty movieClip used as a place holder) which is on the stage. I read in and load images to the flash file, and create them in their own movie clips WITHIN imageHolder like so:

      ========================
      var nm= imageHolder.createEmptyMovieClip("swfHolder"+i,-(i * 10));
      nm.loadMovie(filename);
      ========================

      Obviously this is a code snippet, I am using the LoadVars object to load these files. Once everything is loaded, it is displayed on the stage, with a depth in order from first image to last (first image on top, last image on the bottom). After this, I have an interval set, to call a function called "selectImage" which gets a variable called photonum, and changes images to the number you have passed in. In selectImage, I ensure that the image that is coming up next is one depth level below the currently displayed image using swapDepths, and I am constantly incrementing a variable called "curdepth" which is global, and always assigning that depth to the currently displayed image to that depth. So, the current image will be displayed at depth 30, and the next image up will be displayed at depth 29. Then I fade the current image out using the tween object, and it works like a charm! To reference these MovieClips I use the following code:

      ====================
      var cmc:MovieClip = eval("imageHolder.swfHolder" + (curpho + 1));
      var nmc:MovieClip = eval("imageHolder.swfHolder" + (nexpho + 1));

      // Force current clip to front
      cmc.swapDepths(curdep);
      // Force next clip to one below front
      nmc.swapDepths(curdepth - 1);
      ====================

      and this works perfectly... in flash. Once it's on the page, or displayed within the standalone movie player, everything goes south. I assigned the typeof cmc and nmc to a textbox, and i got "movieclip", in flash and on the page. However, if I store "cmc.getDepth()" to the textbox, I get "[type function]" in flash, but, on the page "undefined" It seems anything that is specific to the MovieClip object, such as getDepth(), or swapDepths() is undefined when I plug it into the textbox, but, things that are inherited, such as enabled, _x, or _y are all available for my perusal and setting.

      Does anyone have any idea how to remedy this? I can attach all my code in a couple of hours if necessary. I have tried not putting the loaded images into the imageHolder, and I found that didn't help. I have also tried a combination of adding "_level0." and "_root." to my cmc and nmc references to no avail. Any help would be greatly appreciated.