all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

mouseovers to show different text


mouseovers to show different text it3
12/3/2004 8:37:22 PM
flash actionscript:
Hello. I've read up on mouseovers a tad and have found the following code: on
(rollOver) { var body = 'Your text here.'; } on (rollOut) { var body = ''; }
I've read that the text appears in a dynamic text field. In the above code the
variable 'body', is that the instance name of the dynamic text field? Or is it
the variable name of the dynamic text field? How and where do I set the
dynamic text fields variable name? How do I reference the dynamic text field in
order to have the text ('your text here') appear there when the mouse rolls
over the image? I do not want to simply add the text
dynamic_text_box_instance_name_txt= 'text here'; because as I understand it
this will just put the text in the box and I want the text to change as the
mouse rolls over various product pictures. Thanks!
Re: mouseovers to show different text Christian_Flanagan
12/3/2004 9:18:13 PM
There's two ways to go, but either way you need to name the instance of the
graphic you want to rollover in order to trigger the rollover and rollout
events and make the text appear and disappear.

Create a new Flash file. Add a layer to the timeline. Name one layer
"elements" and the other "script". On the stage, in frame 1 of the elements
layer, draw two rectangles. Make each rectangle a symbol, F8, and make them
movieclips. Give each instance of the movie clips on stage a unique name in the
Properties palette. (I created a blue and an orange rectangle and named the
blue one "blue_mc" and the orange one "orange_mc".)

Next to blue_mc draw a dynamic text field. Name the text field "blue_txt."

Next to orange_mc draw a dynamic text field but do not give it an instance
name. In the Properties palette, find the field Var: and type "orange" in it.
That text field will display the value of the variable "orange."

On the first frame of the script layer, add the following code (F9) and then
test the movie.



blue_mc.onRollOver = function()
{
blue_txt.text = "You rolled over the blue button.";
}

blue_mc.onRollOut = function()
{
blue_txt.text = "";
}


var orange = "";

orange_mc.onRollOver = function()
{
orange = "You rolled over the orange button.";
}

orange_mc.onRollOut = function()
{
orange = "";
}
Re: mouseovers to show different text it3
12/3/2004 9:35:46 PM
That's awesome! Thanks so much!
AddThis Social Bookmark Button