A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [CS3] Buttons

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    26

    [CS3] Buttons

    Hi all

    I have a row of buttons in a movie clip. does anyone know how to make it so that a square or something will follow the mouse along the buttons highlighting each one along the way? eg

    home faq contact us gallery

    when mouse is moved over home a square appears highlighting the whole thing but if you stay on the button movie and move over to faq the square moves along and highlights faq. hope this makes sense its hard to explain...

    thanks

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    use the TWEEN CLASS to accomplish this...

    here is an example: (all code in frame 1 in timeline) 3 buttons, 1 highlight_mc clip

    PHP Code:
    //import the tween class os you can use it
    import mx.transitions.Tween;

    //create a tween function so you can re-use it

    function highlightMe(targetCliptargetPos){
            var 
    myTween:Tween = new Tween(targetClip"_x"mx.transitions.easing.Strong.easeOuttargetClip._xtargetPos.5true);
            
    //var myTween:Tween = new Tween(targetClip, "_x", mx.transitions.easing.Elastic.easeOut, this._x, targetPos, .5, true);
    }
        

    home_btn.onRollOver = function(){
        
    highlightMe(highlight_mc132);
    }

    gallery_btn.onRollOver = function(){
        
    highlightMe(highlight_mc335);
    }

    contact_btn.onRollOver = function(){
        
    highlightMe(highlight_mc581);

    this is using AS2..you didnt specify what you are using.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    26
    hey whispers... thanks so much for that you nailed it!

  4. #4
    Junior Member
    Join Date
    May 2008
    Posts
    26
    hi whispers an anyone else looking at this post

    thanks for the code. i was wondering if it was possible for when the mouse is not hovering over the button make your triangle for example disappear as when the mosue leaves the movie area on my webpage the triangle stays on the last position it was at. thanks again

  5. #5
    Junior Member
    Join Date
    May 2008
    Posts
    26
    heres the code



    //import the tween class os you can use it
    import mx.transitions.Tween;

    //create a tween function so you can re-use it

    function highlightMe(targetClip, targetPos){
    var myTween:Tween = new Tween(targetClip, "_x", mx.transitions.easing.Strong.easeOut, targetClip._x, targetPos, .5, true);
    //var myTween:Tween = new Tween(targetClip, "_x", mx.transitions.easing.Elastic.easeOut, this._x, targetPos, .5, true);
    }


    home_btn.onRollOver = function(){
    highlightMe(highlight_mc, 66);
    }

    faq_btn.onRollOver = function(){
    highlightMe(highlight_mc, 195);
    }

    pricing_btn.onRollOver = function(){
    highlightMe(highlight_mc, 324.5);
    }

    gallery_btn.onRollOver = function(){
    highlightMe(highlight_mc, 454.5);
    }

    process_btn.onRollOver = function(){
    highlightMe(highlight_mc, 584);
    }

    contact_btn.onRollOver = function(){
    highlightMe(highlight_mc, 714.5);
    }

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    well..you 'can' but Im not sure if this is the effect you'd want.. it looks kinda 'choppy' or something..

    PHP Code:
    home_btn.onRollOver = function(){
        
    highlight_mc._visible true;
        
    highlightMe(highlight_mc132);
    }
    home_btn.onRollOut = function(){
        
    highlight_mc._visible false;
    }
    gallery_btn.onRollOver = function(){
        
    highlight_mc._visible true;
        
    highlightMe(highlight_mc335);
    }
    gallery_btn.onRollOut = function(){
        
    highlight_mc._visible false;
    }
    contact_btn.onRollOver = function(){
        
    highlight_mc._visible true;
        
    highlightMe(highlight_mc581);
    }
    contact_btn.onRollOut = function(){
        
    highlight_mc._visible false;


  7. #7
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    You could use the tween class to make the triangle fade out (by controlling the _alpha instead of _x or _y positions).

    -Sportzguy933

  8. #8

  9. #9
    Junior Member
    Join Date
    May 2008
    Posts
    26
    cheers.. this menu bar is just a line of buttons on an html page. what i want is when the mouse leaves the flash movie the triangle disappears.. not individual rollouts for each button because like you said it looks jerky and kind of pointless cos i could just put a triangle in the over frame of each button to achieve a similar effect. is there anyway to define the area the mouse is in and if it leaves this area highlight_mc alphas to 0? the dimensions of the stage are 779x28. thanks again

  10. #10
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I think using AS3 there is a new option to check if the mouse is on the stage...

    but I do NOT think there is one in AS2.

  11. #11
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Why not just leave more space around the buttons so that Flash detects when the user rolls out?

    -Sportzguy933

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