0 Replies Latest reply on Jan 8, 2008 9:12 AM by infinateLoop

    Some Gallery Help

      Ladies and gentlemen of the flash community I offer a sincere plea for assistance in building a flash photo gallery. I have cobbled/borrowed the following bits of code together to create a gallery however I would like to have the ability to place the holder clips on stage (_x values) dynamically.
      A user could upload jpgs of different widths and the holder clip would adjust itself accordingly. I imagine one way to do this is to perform a hit test and use a listener. I have tried this but I don’t seem to be able to get the listener to respond. I am shaky at best in the world of ActionScript so any insight would be beneficial.
      In addition I realise I am exactly the 4 trillionth person to ask this but if someone could provide a hint towards a clear explanation of how to pass a variable out of a function I would be most indebt. I have tried both _global and return and have had no success with either.

      _root.onEnterFrame = function() {
      reelSpeed = (_xmouse-center)/10;
      reel_mc._x += reelSpeed;
      if (reel_mc._x < LEFTSTOP) {
      reel_mc._x = LEFTSTOP;
      } else if (reel_mc._x > RIGHTSTOP) {
      reel_mc._x = RIGHTSTOP;


      function Picture (name, link, color, description, high, wide) {
      this.picName = name;
      this.picLink = link;
      this.picColor = color;
      this.description = description;

      //-----------create a listenr-----------------\\
      var mclListener:Object = new Object();

      function newCell (num, details) {
      originalClip = _root.reel_mc.cell_mc;
      newClip = originalClip.duplicateMovieClip("cell"+num, num);

      newClip.name_txt.text = num+1+". "+ details.picName;
      newClip.description_txt.text =details.description;
      newClip._height = details.high;
      newClip._width = details.wide;

      //---------x position-------------\\
      newClip._x = num*newClip._width; //---want to change to hit test---\\
      //newClip._x = num*300;

      // Set cell content
      picContent = newClip.placeholder_mc;
      // Set color of cell background
      myColor = new Color(newClip.bgnd_mc);

      //---------add a listenr------------\\
      newClip.addListener(mclListener); //----doesn't work at all----\\
      //----------listener function--------\\
      mclListener.onLoadInit = function(mc:MovieClip) {
      trace("a listner has been added");

      cellWidth = reel_mc.cell_mc._width;
      center = Stage.width/2;

      // this will be the variable that gets passed from php to flash
      // with a url encode to tell the gallery how many pictures exist
      var arrayLength:Number = 4;

      pics = new Array();
      // Set up picture objects
      pics[0] = new Picture("cobblestones", "cobblestones.jpg", 0xFF9999,"from an English country lane...");
      pics[1] = new Picture("planet", "planet.jpg", 0x99FF99,"the view from 400km up...");
      pics[2] = new Picture("water", "water.jpg", 0x9999FF,"ripples in a pond...");
      pics[3] = new Picture("water2", "water2.jpg", 0x9999FF,"some text");
      // Loop through array of picture objects,
      // creating a new cell for each
      // a variable is substituted here instead of "pics.length" because we need to
      // pass a variable from php to tell flash how many pictures exist.
      for (var i = 0; i< arrayLength; i++) {
      newCell(i, pics );

      // Hide the original cell movie clip after duplicating it
      reel_mc.cell_mc._visible = false;
      LEFTSTOP = center - reel_mc._width + cellWidth/2;
      RIGHTSTOP = center - cellWidth/2;