Hello, i am trying to replicate putting a button click in a loop but in AS3.
I know a little about as3 now and have tried to do it but cannot…
I quickly wrote something in AS2 code to show what i am trying to achieve in AS3:
var count = 10
for(var i=0; i<count; i++){
p = pane.content.attachMovie("holder", "holder"+(z++), z, {_y:10+(118*int(z/4)), _x:(111*(z%4))+5})
//external and internal holder where the material images will be loaded
p.createEmptyMovieClip("foto"+i, 1)
p["foto"+i].createEmptyMovieClip("holder", 1)
//load the timage
p["foto"+i].holder.loadMovie("products/pics/picture"+i)
p["foto"+i].onPress = function(){
var target = this._parent.details
target.holder.loadMovie("products/pics/picturetwo"+i)
}
}
this is as far as i have got in AS3. I can load the images no problem, but i cannot change the picturetwo to the one which is clicked… the ‘i’ in the loop is just 10 every time it is clicked…
var holder:Sprite = new Sprite();
var p:Array = new Array();
var hor = -100
var ver = 10
var rows = 0
var count = 0
for(var i=0; i<count; i++){
p* = new Loader();
p*.load(new URLRequest("products/pics/picture"+i+".jpg");
holder.addChild(p*);
p*.addEventListener(MouseEvent.CLICK, clickHandler)
//this is just to place the images in columns of 4. i made it more simple here. no maths!! :)
if(rows==4){
rows = 0
hor = -100
ver = ver + 110
} else {
hor = hor + 110
rows++
}
p*.x = hor
p*.y = ver
function clickHandler(event:MouseEvent):void {
//here i want to make it so when i click on one of the images, the same name of the image clicked is loaded into another place somewhere else
trace(i) //result is 10
}
}
Thanks so much for any help with this…
My main problem is i just dont understand how to store unqiue info for every image for the onclick event, so when that image is clicked i can, for example, trace(nameoftheimageclicked). then i could use it to change descriptions etc on the page of the image clicked…
reagrds,
j