Skip to main content
New Participant
December 7, 2012
Question

Help with AS3 Mouse_Over, Mouse_Out

  • December 7, 2012
  • 1 reply
  • 1138 views

I am new to Flash and ActionScript so please bare with me...I created a graphic that has a row of 5 separate buttons at the top. What i am going for is for when you mouse over the button a box rolls down with text  and then to roll back up when Mouse Out. At first I converted each of these into a button symbol and used the UP, Over, Down, Hit states, but it seems that you don't have to rollover that buttons specifically but can mouse over where that popout is on the stage and it will show up. then I tried to use Masks and moviclip buttons, but I am having a hard time now. I've gotten to the point with the masks and AS# code that it will roll down for the first button but not the rest and the url in the text in the roll downs doesnot work. Can anyone help me figure out or give a step by step on how to do this. It doesn't have to be real technical or great, just simply work as I described. Please help.

This topic has been closed for replies.

1 reply

Ned Murphy
Braniac
December 7, 2012

Can you show the code that you have now and explain the object(s) setup that supports it?

New Participant
December 7, 2012

I have an outlined box on the main stage/timeline with text in the center stating what it is. My intentions are if you Mouse Over that than another box (a larger box, with text boxes on top of it) pulls down to give more information. In that text on the roll down I want to also embed url links. I will have 5 of these buttons side by side looking like a menu bar, and they are all situated on the same layer. I have a layer that holds other buttons that I have towards the bottom of my stage. And my top layer will hold my actions.

When I double click on one of these buttons (movieclips), to enter its isolated state (sorry if that's the wrong terminology) I have added frames up to 30 on the timeline.  I have labeled my first layer actions, and I have added a stop action at frame 1 and frame 15, and a gotoAndStop (1); at frmae 30. My next layer is my main button, which is the button on my main stage. With that I have added frames up to 30. Next layer is my mask, which is a moviclip symbol of the roll down box with the text boxes that shows my "More Information" and this is where I want url links clickable from certain pieces of text. On the timeline, (and this is where I'm most confused and don't know how I even added this) but I have a frame at 1 with the box, a frame at 2 with the box then a motion tween to 16 that then has the box returning ot its original point. I also included a sub mask with that because I thought I needed it to tell the movieclip mask where to move along. In that part , I just have a rectangle drawing object that is the same sixze as the box that I want to roll down on mouse over.

Back to my main stage, in my actions the only code I wrote was for the very first box. the code I wrote is:

cair_btn.onRollOver = function(){
cair_btn.gotoAndPlay(2);
}

cair_btn.onRollOut = function(){
cair_btn.gotoAndPlay(16);
}

csapr_btn.onRollOver = function(){
csapr_btn.gotoAndPlay(2);
}

csapr_btn.onRollOut = function(){
csapr_btn.gotoAndPlay(16);
}

This code works but isn't perfet and I can't click on the text to go to the link, when I try thisa the box just blinks rapidly until i mouse out. The other thing is I want to do this in AS3.

I hope I provided enough info. thanks for your help.

Ned Murphy
Braniac
December 7, 2012

If you want to use AS3, then you can't use the code you show since it is AS2.  For AS3 you need to assign event listeners and event handler functions.  Here is an example.

    cair_btn.addEventListener(MouseEvent.ROLL_OVER, cairOver);

    function cairOver(evt:MouseEvent):void {

        cair_btn.gotoAndPlay(2);

    }

The blue and green text in the code above is just to indicate you can name those things as you please.   Based on what you described, you would also be creating ROLL_OUT and CLICK event listeners/handlers.

The problem you had using the clicking for AS2 is that when you assign interactive code to the button movieclip in AS2, that will block access to interact with objects contained within it.  I don't think you will have that problem in AS3.