Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically working with library objects

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I need to take 10 instances of a library button and place them on different locations of the stage. I need to give each of them a unique name, URL, and position them on the stage according to database information. Any help would be great!.
 
If you put your button inside a movieclip then you can pick that clip from the library using attachMovie.

You'll have to set the mc an identifier and check 'export for actionscript' in the 'linkage' properties (select the clip in the library and right click to get to this option).

Then the code for attaching 10 instances would be similar to:

for (var i=1;i<=10;i++){
this.attachMovie('libraryClip', 'stageClip'+i, i);
var activeClip=this['stageClip'+i];
//pick up database info and apply it
activeClip._x=db_XValue;
activeClip.URL=db_URLValue;
}
 
I changed the code to this and the problem is that it makes the link for all of them the same

for(mynum = 0;mynum<5;mynum++) {
this.attachMovie('propstar', 'stageClip'+i, mynum);
var activeClip=this['stageClip'+i];
//pick up database info and apply it
activeClip._x=100 * mynum;
activeClip._y=100 * mynum;
//activeClip.URL= &quot; //activeClip.URL=db_URLValue;
activeClip.onRelease=function(){
getURL(&quot; + i, &quot;_blank&quot;, &quot;POST&quot;);

}
Any ideas?
 
Using it this way

this.attachMovie('propstar', 'stageClip'+mynum, mynum);
var activeClip=this['stageClip'+mynum];
//pick up database info and apply it
activeClip._x=50 * mynum;
activeClip._y=50 * mynum;
activeClip.URL=db_URLValue;

it doesn't attach the URL to each button. I also tried getURL() function and that just loads up a bunch of pages. but it doesn't attach the URL to the actual button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top