i basically have a gallery with thumbs loaded in via xml.
and then a currentThumb.onRollover function depending on which thumb was clicked.
Now this is all within the forloop function on frame1.
what if I want the actions to occur on frame 2 of the main timeline after the coinciding thumb has been clicked. How can I determine which thumb was clicked?
I tried using a _global.id = i; but that doesnt store the correct value from the loop.
any ideas?
try this:
- You could assign a “selected” variable to each movieClip. In other words, when you go through the whole for loop involving thumb.onRelease = functionToMakeItCurrentThumb, make it thumb.current = false;
That way in frame 2 each thumb will have attached to it a value of true or false for whether it’s selected. just check with another for loop.
could either post the .fla or some of the code? its sorta difficult to get a sense of the issue
function ScreenprintsLoad(screenprints_xml) {
var screenprintsThumbs = screenprints_xml.firstChild.firstChild.childNodes;
maincontent.createEmptyMovieClip("holder",1);
for (var i = 0; i<screenprintsThumbs.length; i++) {
var currentPicture = screenprintsThumbs*;
var currentThumb = maincontent.holder.createEmptyMovieClip("thumb_mc"+i, i);
var containerThumb = currentThumb.createEmptyMovieClip("container"+i, i);
currentThumb._x = i*100;
var fabricName = currentThumb.createTextField("fabric_name"+i, i+1, -50, -80, 100, 100);
fabricName.autoSize = "center";
fabricName.text = currentPicture.attributes.fabricname;
var style_fmt:TextFormat = new TextFormat();
style_fmt.font = "Times New Roman";
style_fmt.color = 0x666666;
style_fmt.size = 12;
fabricName.antiAliasType = "normal";
fabricName.setTextFormat(style_fmt);
currentThumb.attachMovie("thumb_bg_mc","thumb_bg_mc"+i,i-1);
currentThumb.onRelease = function() { //heres where I want it to go to Frame 2
};
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadClip(currentPicture.attributes.largethumb,containerThumb);
var container:Object = new Object();
mcl.addListener(container);
container.onLoadInit = function(target:MovieClip) {
target._x = target._x-(target._width/2);
target._y = target._y-(target._height/2);
};
}
}
//create xml object and load the xml data
var theContent:XML = new XML();
theContent.ignoreWhite = true;
theContent.load(“content.xml”);
theContent.onLoad = parseXMLData;
function parseXMLData(success:Boolean):Void {
//make sure the data is loaded and usable
if (success && this.status == 0) {
ScreenprintsLoad(this);
}
}
stop();
create an array or something?
Assign the value of i to a property of each button:
Maybe this will work:
var currentThumb = maincontent.holder.createEmptyMovieClip(“thumb_mc” +i, i);
this[“thumb_mc” + i].button_number = i;
Thanks but its not working for me…
I dont really understand it enough to make it work for my code. What is “this” referring to in this case? Cant I just use currentThumb.button_number = i;?
in the end it just gives me that last value of i.
“this” refers to the newly created movieclip. You could use currentThumb.button_number instead.
If you check that external link, it shows how to use it with an onRelease event and the question has also been asked here before:
Great! thanks it worked.
in my currentThumb.onRelease function
I had currentThumb.id but it did not work. having this.id works.
Why is this? isn’t it technically the same thing?
I’ve had issues with that sort of thing before… It has to do with the fact that currentThumb is a local variable created in the for loop. Even though your onRelease is also in the for loop, it works as if it’s outside. using “this” lets the onRelease function know to reference the MC that it’s a part of, so to speak. I’ll bet if you try to trace “currentThumb” within the onRelease, it will be undefined.