Flash AS2 Q

  • Started
  • Last post
  • 3 Responses
  • bartosz

    i've got an xml file with all my info, and image paths. i'm able to parse it and attach thumbnails to the stage as i want to. but when i want to display the large jpeg in a movieclip i've already placed on the stage, i can't correctly reference the thumbnail movieclips i've layed out. i need it to be able to work whether there's 2 or 200 thumbnails, but i'm a little stumped right now. not sure my holder.onRelease funcion should be in the for loop, or if it should point to another function outside of this one. if anyone can steer me in the right direction, i'd appreciate it

    here's the code:

    function showByType(p_type){
    var holder = createEmptyMovieClip("holder_mc... getNextHighestDepth());
    holder._x = 0;
    holder._y = 300;

    for(var i=0; i less than myDataArray.length; i++){
    var item = myDataArray[i].itemType;
    //trace("ITEM: "+item);

    if(item == p_type){
    var mc= holder.attachMovie("thumb_mc", "thumb_mc"+i, i);
    mc._x=i*155;
    mc.loadMovie(myDataArray[i].item...
    mc._xscale = 25;
    mc._yscale = 25;
    trace("MC: "+mc);

    // here's where i can't
    // reference correctly
    holder.onRelease = function(){
    trace("hit MC: "+mc);
    trace("hit THIS: "+this);
    //display_mc.loadMovie(myDataArr...
    }
    }
    }
    }

    thanks in advance.

  • caseyc0

    Shouldnt your onRelease be on the thummbnail mc and not the holder? Also, if you reference [i] its always going to be the last value it was set to in the for loop. So do something like:

    mc.itemURL = myDataArray[i ].itemURL;

    mc.onRelease = function(){
    trace("hit MC: "+mc);
    trace("hit THIS: "+this);
    trace("hit URL: "+this.itemURL);
    }

  • bartosz0

    i would have thought to soo, the onRelease being on the mc. but when i do that, i can't click on the thumbnail to call the onRelease. when i trace mc._width and mc._height it comes back as 0.

    mc.itemURL works though. but holder.onRelease = function(){
    trace("hit URL: "+mc.itemURL);
    }
    comes back as undefined cause i'm within the holder.

    thanks though... i think i may know where i need to go from here.

    cross your fingers :)

  • jpea0