# On button rollover Dynamic text and Movieclip appear

**URL:** https://forum.kirupa.com/t/on-button-rollover-dynamic-text-and-movieclip-appear/314341
**Category:** flash
**Created:** [September 25, 2010, 11:13am UTC](https://forum.kirupa.com/t/on-button-rollover-dynamic-text-and-movieclip-appear/314341 "2010-09-25T11:13:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dragonkimber](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Dragonkimber](https://forum.kirupa.com/u/Dragonkimber)
#### Post date: [September 25, 2010, 11:13am UTC](https://forum.kirupa.com/t/on-button-rollover-dynamic-text-and-movieclip-appear/314341/1 "2010-09-25T11:13:48Z")

</div>

Hi guys,

I’ve got an issue - When one of my buttons is rolled over, I want text and a movieclip to appear. When the button is no longer rolled over, I want the text and movieclip to disappear.

The way that I was going to do this was to have anchor\_mc as an anchor, and upon rollover have the movieclip play from inside the anchor (as its at the exact X & Y that its needed at) and dynamic text appear.

Questions:

1. **Is there an alternative way of doing the below, to avoid so many listeners?**

2)\*\* Can the below functions be merged into one?  
I’ve tried merging them into one using IF statements, for example:

if(event.target.name == line1)  
{  
line\_output.text = “This is a test made by the MonkeyTest that has previously messed up  
And testing a new line”;  
gotoAndStop(2);  
}

However this does not work, and gives an error.\*\*

1. **I had to get the background to display by moving to the next frame. I could not work out how to get the textbox to appear at a specific XY, or how to get the textbox to disappear after a rollover. Is there a better way to do this, or is what I’m doing acceptable?** (NOTE: Textbox is a Movieclip)

AS3 code is attached below.

```auto
import flash.events.MouseEvent;

stop();

// QUESTION 1: Is there an alternative way of doing the below, to avoid so many listeners?

line1.addEventListener(MouseEvent.ROLL_OVER, line_in1, false, 0, true);
line1.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line2.addEventListener(MouseEvent.ROLL_OVER, line_in2, false, 0, true);
line2.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line3.addEventListener(MouseEvent.ROLL_OVER, line_in3, false, 0, true);
line3.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line4.addEventListener(MouseEvent.ROLL_OVER, line_in4, false, 0, true);
line4.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line5.addEventListener(MouseEvent.ROLL_OVER, line_in5, false, 0, true);
line5.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line6.addEventListener(MouseEvent.ROLL_OVER, line_in6, false, 0, true);
line6.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line7.addEventListener(MouseEvent.ROLL_OVER, line_in7, false, 0, true);
line7.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line8.addEventListener(MouseEvent.ROLL_OVER, line_in8, false, 0, true);
line8.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);
line9.addEventListener(MouseEvent.ROLL_OVER, line_in9, false, 0, true);
line9.addEventListener(MouseEvent.ROLL_OUT, line_out, false, 0, true);

/* QUESTION 2: Can the below functions be merged into one?
I've tried merging them into one using IF statements, for example:

if(event.target.name == line1)
    {
        line_output.text = "This is a test made by the MonkeyTest that has previously messed up
        And testing a new line";
        gotoAndStop(2);
    }

However this does not work, and gives an error.

QUESTION 3: I had to get the background to display by moving to the next frame. I could not work out
how to get the textbox to appear at a specific XY, or how to get the textbox to disappear after a
rollover. Is there a better way to do this, or is what I'm doing acceptable?
*/

function line_in1(e:MouseEvent):void
    {
        line_output.text = "This is a test made by the MonkeyTest that has previously messed up
        And testing a new line";
        gotoAndStop(2);
    }
function line_in2(e:MouseEvent):void
    {
        line_output.text = "up messed previously has that MonkeyTest the by made test a is This";
        gotoAndStop(2);
    }
function line_in3(e:MouseEvent):void
    {
        line_output.text = "This is a test made by the MonkeyTest that has previously messed up
        And testing a new line";
        gotoAndStop(2);
        
    }
function line_in4(e:MouseEvent):void
    {
        line_output.text = "up messed previously has that MonkeyTest the by made test a is This";
        gotoAndStop(2);
    }
function line_in5(e:MouseEvent):void
    {
        line_output.text = "This is a test made by the MonkeyTest that has previously messed up
        And testing a new line";
        gotoAndStop(2);
        
    }
function line_in6(e:MouseEvent):void
    {
        line_output.text = "up messed previously has that MonkeyTest the by made test a is This";
        gotoAndStop(2);
    }
function line_in7(e:MouseEvent):void
    {
        line_output.text = "This is a test made by the MonkeyTest that has previously messed up
        And testing a new line";
        gotoAndStop(2);
    }
function line_in8(e:MouseEvent):void
    {
        line_output.text = "up messed previously has that MonkeyTest the by made test a is This";
        gotoAndStop(2);
    }
function line_in9(e:MouseEvent):void
    {
        line_output.text = "up messed previously has that MonkeyTest the by made test a is This";
        gotoAndStop(2);
    }

function line_out(e:MouseEvent):void
    {
        line_output.text = "";
        gotoAndStop(1);
    }

```
