8 Replies Latest reply on Dec 28, 2006 10:43 AM by Jaap_Kooiker

    convert dynamically created MCs into buttons

    Level 1
      I'm working on a Flash/XML photo album that loads image thumbnails dynamically by creating individual movie clips for each thumbnail. The thumbnails are divided into 10 groups. Every time a new group of thumbnails is selected from the album the XML array is upadated with the correspondig image file name and path. Now, I'd like to make each individual thumbnail_mc a button that when released loads the corresponding photo in the main stage. The first function loads the photo onto the main stage with back and forward buttons. The second function displays the thumbnails as movie clips. And the last function makes the movie clips active as buttons but does not work. How can I fix the last function? Any help is very much appreciated. Thanks!

      // Loads actual images and text into empty_mc, content_txt, and comment_txt
      function loadPhoto(nodePos:Number):Void {
      PhotoNode = GalleryNode.childNodes[nodePos];
      var filename:String = PhotoNode.attributes.filename;
      var caption:String = PhotoNode.attributes.caption;

      // Loads thumbnails as individual mc's, thumbnails is an Array
      function thumbDisplay(thumbnails) {
      var galleryLength:Number = thumbnails.length;
      // loop through each of the images in the gallery_array.
      for (var i = 0; i<galleryLength; i++) {
      /* create a movie clip instance which holds the image, also sets a variable,
      thisMC, which is an alias to the movie clip instance. */
      thisMC = this.createEmptyMovieClip("image"+i+"_mc", i);
      /* load the current image source into the new movie clip instance,
      using the MovieClipLoader class. */
      mcLoader_mcl.loadClip("photos/"+selectedGallery+"/thumbs/"+thumbnails , thisMC);

      // makes each thumbnail image_mc a button that loads the corresponding photo in the main stage
      function thumbButton():Void {
      for (var i = 0; i<thumbnails.length; i++) {
      thisMC("image"+i+"_mc").onPress = function() {