i am making a basic picture viewer....and trying to better understand for loops. i have the 7 thumbnails programatically generated and positioned. The onRollOver, and onRollOut effects work fine for each. The only thing i am not understanding is how to make each thumbnail upon onRelease unique...in other words, i have to write the onRelease functions seperately for each thumbnail in order to bring a new large picture to the stage....is there a way to do this within the "for" loop- or at least more dynamically?:
Code:function loadImages(myXML) { var mcImage:MovieClip; // Load the four images. for (var i = 0; i<=7; i++) { frames[i]._visible=false mcImage = this.createEmptyMovieClip("mcImage"+i, this.getNextHighestDepth()); mcImage.createEmptyMovieClip("mcHolder", mcImage.getNextHighestDepth()); mcImage._alpha = 30; mcImage.onRollOver = function() { upAlpha(this); }; mcImage.onRollOut = function() { downAlpha(this); }; mcImage0.onPress = function() { loadBigImage(0); }; mcImage1.onPress = function() { loadBigImage(1) }; mcImage2.onPress = function() { loadBigImage(2) }; mcImage3.onPress = function() { loadBigImage(3) }; mcImage4.onPress = function() { loadBigImage(4) }; mcImage5.onPress = function() { loadBigImage(5) }; mcImage6.onPress = function() { loadBigImage(6) }; mcImage7.onPress = function() { loadBigImage(7) }; var mclLoader:MovieClipLoader = new MovieClipLoader(); var mclListener:Object = new Object(); var mclLoader:MovieClipLoader = new MovieClipLoader(); mclLoader.addListener(mclListener); //this listerner will always refrence the clip immediately loaded mclListener.onLoadInit = function(mcClip:MovieClip) { if(nX==undefined){ nX=Stage.width/2-(mcClip._width +200); nY=20; } mcClip._parent._x=nX; mcClip._parent._y=nY; nX+= mcClip._width+10; if (mcClip._x>Stage.width){ //define method to start second row } }; mclLoader.addListener(mclListener); mclLoader.loadClip("images/"+myXML.firstChild.childNodes[i].attributes.thumb,mcImage.mcHolder); } } function loadBigImage(index) { var bigImageX:Number; var bigImageY:Number; var bigImageLoader:MovieClipLoader= new MovieClipLoader; var bigImageListener:Object= new Object bigImageListener.onLoadInit=function (mcCurrentBigImage:MovieClip):Void{ mcCurrentBigImage._alpha=80; /*if(bigImageX==undefined){ bigImageX= Stage.width/2- (mcCurrentBigImage._width)/2 bigImageY= Stage.height/4-50; } mcCurrentBigImage._x=bigImageX; mcCurrentBigImage._y=bigImageY;*/ } bigImageLoader.loadClip("images/"+myXML.firstChild.childNodes[index].attributes.picture, imageTank); bigImageLoader.addListener(bigImageListener); } var myXML:XML = new XML(); myXML.ignoreWhite = true; myXML.onLoad = function(success:Boolean) { if (success) { loadImages(this); } }; myXML.load("images/images.xml");


Reply With Quote