A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Mouse over to play movie clip woes

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Mouse over to play movie clip woes

    Truly basic question I know but I can't seem to find an answer elsewhere and you don't even want to know how long I've spent on this. I'm trying to create a button that plays a movie clip and stops when it's moused over. I've attached a file (help.fla) that illustrates my problem. I'm working in CS4 Flash (not sure if that's the same as MX04? Didn't see it on the pull down list) Your help would be more than appreciated! Thanks so much.
    Attached Files Attached Files

  2. #2
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    Can you clarify exactly what your problem is? I just looked at your file and it seems to be doing what you've described, so I'm thinking I don't quite get exactly what you want.

  3. #3
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Movie clip woes - MC reversal?

    The problem I had was the mc would run independently of any mouseover. it wasn't responding as a button. I was trying to get it to work via AS only, but I have since changed the format to play it by putting the mc in the "over" state of a button. It's working now.

    I do have a secondary question though. Is there a way to ease a transition from one state in a button to another? Meaning, my mc stops, then when the mouse leaves the "hit" area it quickly switches back to the up state. I'd like there to be a smooth "reversal" of my mc so the button is in it's original untouched state.

    Again, thanks for your help!

  4. #4
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    I don't know if there's an easier way of doing this, but when I needed to do this, I used to make my own "buttons" using movie clips. So you make a animation on the timeline of your movie clip symbol and have frames called, for example, "fadein", "fadeout", as the start of your animation. Then, on your MouseOver and MouseOut events, you'd tell the movie clip to goToAndPlay("fadein"); or whatever, and your little transition animation would run, until it reached the original state and obviously there'd be a stop(); on that frame. Hope that makes sense!

    Just note if you're using AS3 you will need to tell the movie clips to behave like a button in your code, otherwise the whole thing will fall down.

  5. #5
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Reversing a mc

    Thanks for your reply. I've attempted it and it's not exactly right. The mc keeps looping and the error message I get is:

    1046: Type was not found or was not a compile-time constant: MOUSE_OVER.

  6. #6
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    Can you post your whole code, or the .fla? It's a bit hard to help without more detail.

  7. #7
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Reversing a mc

    I did have a much longer message, but somehow it didn't upload. Anyway, here is my code:

    import flash.events.EventDispatcher;
    import flash.display.MovieClip;
    this.stop();
    function mcOver (event:MouseEvent.MOUSE_OVER) :void {
    this.gotoAndPlay("fadeon");
    }
    function mcOut (event:MouseEvent.MOUSE_OUT) :void {
    this.gotoAndPlay("fadeoff");
    }

    main_res_btn.addEventListener(MouseEvent.MOUSE_OVE R, mcOver);
    main_res_btn.addEventListener(MouseEvent.MOUSE_OUT , mcOut);

    My mc runs in a loop when moused over even though there is a stop at the end of the fadeon section. I also have a stop at the end of the fadeoff section.

    I'm using AS 3.0

    Thank you for your help.

  8. #8
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    Hey, don't know if you've already worked this out, I got a bit busy and haven't had time to reply. From looking at your code, you've just got a couple of little mistakes that I think are causing your problem.

    If you change the lines:
    function mcOver (event:MouseEvent.MOUSE_OVER) :void {
    and
    function mcOut (event:MouseEvent.MOUSE_OUT) :void {

    to

    function mcOver (event:MouseEvent) :void {
    and
    function mcOut (event:MouseEvent) :void {

    I think it should work for you. I'm pretty sure your stop(); is actually working - when there is a syntax error in the code, as you've got here, this is what causes the .swf to loop regardless of any actions you have applied to it.

  9. #9
    Junior Member
    Join Date
    May 2007
    Posts
    24
    No worries on the delayed response. I did get it turned around finally. Damn picky coding! Thanks for the reply regardless.

Tags for this Thread

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