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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing a text URL to open in a new window (_blank) 3

Status
Not open for further replies.

Rohdem

Programmer
Sep 20, 2000
553
US
Is it possible to make a piece of text that has a URL (entered in the URL section on the text panel) associated with it open in a new window? I know I could convert the text to a button and use the 'get url', but this would require A LOT of buttons. Mike Rohde
rohdem@marshallengines.com
 
It wouldn't necessarily take that many buttons....

You could create one button, for example my_links_button, and then put a piece of dynamic text in the normal/over/down states with a name like my_links_text, or something.

I think, although I could be wrong, that all you would need to do then is to duplicate the button whereever you need the text, and then use a piece of ActionScript to change the text, something like my_links_text = "
You would then need to setup the getURL action on the button to read this variable.

(You may need to embed the button into a movie clip; to allow the dynamic text variable to be set-up differently for each button.)

I presume this will work although it is Monday morning so, to be honest, I could just be writting anything!!!

=)

PetitPal
 
I have been using flash for less than a month, so I'm a little shaky on the actionscripting. Do you declare variables? Can I simply assign a value to a variable and access it anywhere else in the movie?

Since I already have all the text on the scenes, I thought maybe I could just create a button that was the same color as my background and create an instance of that button behind each piece of text, changing the URL for each button. Still somewhat time consuming, but it should work, right?

Thanks Mike Rohde
rohdem@marshallengines.com
 
Yup, that would work fine... if, as you say, a little time consuming. In fact you could just put the button behind the background (i.e.: put all the buttons on a new layer and move it below the background layer) meaning that if you ever change the background it won't affect the buttons...

You don't need to declare variables in ActionScript (in fact I'm not sure if you even can.), just use 'em! The only thing you might find is that you can't reference a variable in the main movie from inside a movie clip (fi you know what I mean) - to get round this simply tag the level in front of the variable name. So for the variables declared in the main movie use _root.my_variable.

Anyway, good luck and if you need any more help, give me a shout.

=)

PetitPal.
 
Thanks for your help!!! Mike Rohde
rohdem@marshallengines.com
 
PetitPal,
Just to correct you a little...

You don't need to declare variables in ActionScript
(in fact I'm not sure if you even can.), just use 'em!

var

Syntax

var variableName1 [= value1] [...,variableNameN [=valueN]];
Arguments

variableName The name of the variable to declare.

value The value being assigned to the variable.

Description

Action; used to declare local variables. If you declare local variables inside a function, the variables are defined for the function and expire at the end of the function call. If variables are not declared inside a block, but the action list was executed with a call action, the variables are local and expire at the end of the current list. If variables are not declared inside a block and the current action list was not executed with the call action, the variables are not local.

...The only thing you might find is that you can't reference a variable in the main movie from inside a movie clip (fi you know what I mean) - to get round this simply tag the level in front of the variable name. So for the variables declared in the main movie use _root.my_variable.

...What do you think you're doing... When using _root.my_variable? You're referencing a variable from a mc!

;-)
 
hi all

just another addition to Old's corrections, simply adding a forward-slash and colon preceding the targetted variable name allows access from within any movie-clip. ie: if you have a variable called 'name1' on the main timeline, then you could target (or read) this from within an mc as
Code:
/:name1
.

dave davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
OK... so I didn't know about the var bit oldnewbie... but I did say I wasn't sure (i know you can declare locals in JS etc) - but there you go, you live and learn...

As for referencing variables within movie clips (etc) - I know that you can do that (as you pointed out, is what the whole _root, etc thing is about), I was just trying to intecept a potential newbie 'oh my god what's going on here' for Rohdem, before it happened. (I think maybe my post was a little lax in it's style; all I meant by you might find that you can't is that you may not know how to.... if you see what I mean...).

Thanks for clarifying the post though, that'll teach me to write 'em on a Monday, eh? =)

PetitPal.
 
we all get bitten by the Monday bug now and again, it's a horrible thing.

;-)
dave davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
Good job it only lasts until Tuesday... ...at which point the mid-week bug slips in... ...shortly after which is the 'oh-my-god-its-got-to-be-finished-for-monday-and-its-friday-now' bug hits...

Life, eh? =)

*grins*

PetitPal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top