A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Mouse events in CS3

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    1

    Mouse events in CS3

    I used to play around with flash during the early days of action script 1.
    but now i can't seem to find my way around it. Used to be able to add the script to the button itself.

    here is my problem.

    I have 2 object movie clip instance
    object_red and object_blue

    and I have 2 buttons
    show_switch and hide_switch

    what I want to do is to have a toggle button show and hide
    the objects on the movie.

    how do i do this? please help.
    thank you

  2. #2
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    With AS3 you cannot put actionscript on objects anymore. The reasons why are numerous and overall it's a really great thing but I can totally understand how confusing that is if you haven't used it in a while.

    The simplest method of doing what you are wanting to do is by giving each object on the stage an instance name. If you click the object and then go to the properties panel in you can add an instance name there. Name the objects object_red and object_blue. I'm sorry if you already know this but I'm trying to start at the beginning!

    Then, create a blank layer and call it something like actions or code or scripts, it doesn't matter. The instance names also don't matter but for the sake of the example.

    To apply actions to the objects now you click on the blank layer, open the actions window, and type in something like:

    PHP Code:
    object_red.addEventListener(MouseEvent.MOUSE_DOWNRedDown);

    function 
    RedDown(e:Event){
       
    object_blue.alpha 0;

    That will make your blue object turn completely opaque when you click the red button. I'm not understanding exactly what you are wanting and which button should show what or hide what but this should get you started again. Let me know if this helps or if you need more.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center