I have about 60 buttons to load jpeg images. Instead of putting the long script to load the images on each individual button, I want to put it on a frame and then only set the variables in the buttons to tell the script which image to load from a XML file - this will allow me to make any changes to the loading transitions easily.
Initially I wanted to use:
[AS]
buttonName.onRelease = function() {
//script here
}
[/AS]
However, it seems you can only habe one name to one button. In other words - I can not call all my buttons “thumbnail”
This basicaly means I can’t cut down on the script in the way I want - unless there is a way that I am unaware of whereby I can set variables in a button and for a script on a frame (orMC) to act on the variable change on button release.
Hi,
I don’t know anything about XML, however the following may put you in the right direction.
If you are not producing your buttons dynamically, try this
Make one button mc, open the button and on the first frame put this
[AS]
stop();
//
this.enabled = 1;
//
this.onRelease = function(){
loadMovie(_name + “.jpg”);
}[/AS]
Then drag the button onto the stage, duplicate 60 times and give each button an instance name relative to what you are loading in.
This assumes that you are NOT using Flash buttons, but mc’s
Thanks for your help, but its not quite what I am after. I want the button to set variabes that a script in frame 1 on main stage acts on.
Basically:
Main stage frame 1: script that preloads, animates etc and loads correct jpeg.
Button: to load correct picture, the button sets the variable specific to the jpeg and changes the node value for the XML path. This works great
HOWEVER - The script in frame 1 is only run if a button with the specified instance name is pressed (see script in first posting). This means I can only use 1 button with that name which would mean I would need to have the script repeated 60 times on frame one as each button has to have a unique instance name.
I want the script to run when any of these buttons are pressed - but I can’t give them all the same name?
Hi,
No, its not possible to give them all the same name, however what you could try is to implement a var on your button, like this:
[AS]
this.onRelease = function(){
_root.count++;
//in here your code to play your animation
}[/AS]
and on the _root timeline at the end of the animation
[AS]loadMovie(“imagename” + count + “.jpg”)[/AS]
This means that all your jpgs should have the same name + a number, that way whatever button is clicked the the correct jpg will load in regardless of the instance name of the button
If this isn’yt what you want, I am obviously missing something and it might be better if you posted an example fla
SteveD edit should add that how you address your var ( count) will depend on how the movie is set up