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!

concatenate variable

Status
Not open for further replies.

docstw

Technical User
Sep 30, 2003
3
CA
Hi. I'm sure it's so simple but I'm struggling.

I want to declare a variable in my .swf that will (for example) range from 1 to 5. I'm calling it "courseID".

Later, in a movie clip, I want to use the value of that variable to complete a URL address that is opened in a new browser window. I'm getting the no syntax errors, but my URL address is not using the variable value. I am trying this:

In first frame of Flash movie, I set the variable:

var courseID = 5;

In movie clip, I am trying to concatenate that value of the variable in my URL:

on (release) {
getURL((" + courseID), "_blank");
}

It should be returning this URL:


Any suggestions? THanks.
 
Maybe try...
Code:
courseID = 5;
my_url = "[URL unfurl="true"]http://www..."[/URL] + courseID;
trace(my_url);
Then...
Code:
on(release){
    getURL(my_url, "_blank");
}


Regards,

cubalibre2.gif
 
Thank you oldnewbie.

I modified your solution a bit, because I have the movie clip attached dynamically (it's created in the first frame of the AS) and I don't think the variable was being accessed outside of the main timeline.

So I declared a global variable on frame 1:

_global.myUrl = "trace(myUrl);

And, in the MC, I use the script as you have it:

on (release)
{
getURL(myUrl, "_blank");
}

Now I can share the MC across different Flash files, because the source is in a shared library, and I just have to declare the global variable value in the first frame of the destination .swfs.

Works perfectly! Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top