Link to home
Start Free TrialLog in
Avatar of skylabel
skylabel

asked on

help with script

Hi,
I've got a movieclip with many graphic symbol instances, named tn1, tn2, tn3, tn4. When I click one of these, I want to open the appropriate links defined in the array called url. For some reason, whatever button I click on, I'm taken to url[3] (i.e. four.swf). Here's my code. Any ideas?


function loadPage(target){
     geturl(target);
}
onclipEvent (load) {

  url= new Array();
   url[0]="one.swf";
   url[1]="two.swf";
   url[2]="three.swf";
   url[3]="four.swf";
   
   for (x=1; x<=url.length; x++){
      target=url[x-1];
      ("tn" + x).onRelease=function() {
              loadPage(target);
              }
     } //end for
}
Avatar of Vicker Leung
Vicker Leung
Flag of Hong Kong image

Skylabel,

Actually I don't think that this line of code will work
("tn" + x).onRelease=function() {

You can't specify an instance like that
(If I am wrong, someone please let me know)

What I suggest here is the following


function loadPage(target){
     geturl(target);
}

onclipEvent (load) {

  url= new Array();
   url[1]="one.swf";
   url[2]="two.swf";
   url[3]="three.swf";
   url[4]="four.swf";
   
   for (x=1; x<=url.length; x++){
      target=url[x];
      temp_instance_name = "tn" add x;
      _root [temp_instance_name].onRelease=function() {
              loadPage(target);
              }
     } //end for
}

Hope it works~!! :)
Vicker
Skylabel,

I am sorry that mislook the scripts

Actually the line of error is this line

loadPage(target);

Because this line is inside your clip event section
So actually when you click the button,
It will use the latest value of target
in this case url [3];

So in order to do what you wanna do,
You have to rewrite that part
Give me some time and I will give you a sample file

Vicker
ASKER CERTIFIED SOLUTION
Avatar of Vicker Leung
Vicker Leung
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of skylabel
skylabel

ASKER

thank you sir!
You are welcome Skylabel ^^