A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Flip MC on MouseOver

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    493

    Flip MC on MouseOver

    Hi there,

    I'd like to create a MC that flips when a button is rolled over.

    e.g. a square with a solid color on one side and another color on the other (or images etc). When the mouse is over the button, the MC will flip once from one side to the other.

    If possible would like it to do a return flip on Mouse out.

    Can anyone help with this or know a good tutorial?

    Any time/help is greatly appreciated
    Cheers
    G

  2. #2
    Senior Member Pporksoda's Avatar
    Join Date
    Jul 2000
    Location
    baltimore
    Posts
    174
    Hand animate the flipping animation, and apply a script that will play your animation when rolled over and rewind when rolled off. See attachment for sample.
    Attached Files Attached Files

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Location
    G-Vegas, NC
    Posts
    155

    Cool...

    That was a pretty good example, and I got a lot out of it. Thanks.
    FrankenMoro

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    493
    tnx pporksoda, problem is, I'm trying to figure out how to build a 'flip' effect...got the following code from another post, but it coninuously flips the movieclip. I'm sure there is a simple way to get the effect I'm talking about.

    here's the fairly complex code I've got so far (continuously flips). I'm looking for a flip on, flip off effect.

    .................

    PHP Code:
    Create a two frame MC,Place some graphic in frame one.... same graphic in frame two.... different colorStop action on the first frame and frame label "front" ..... frame label "back" on frame two.

    Then on the clip paste this code.....
    ActionScript:

    PRE {font normal normal normal 13 "Courier New"CourierArial;;}
    onClipEvent (load) {
            
    rpm 18;    // number of full cycles per minute (a full cycle travels the range twice)
    }

    onClipEvent(enterFrame) {
            
    _root.oscillateUsingCos(rpm);
            
    _root.spin(this"horizontal");
    }




    kalmost done....... Paste this into the first frame of the main timeline......

    ActionScript:

    PRE {font normal normal normal 13 "Courier New"CourierArial;;}
    // ### set range, speed and starting direction of oscillation
    var minValue = -100;
    var 
    maxValue 100;
    var 
    degree 0;
    // start angle, relative to the positive x-axis.
    //    degree of 0 starts at maxValue and descends
    //    degree of 180 starts at minValue and ascends
    // ### define system globals
    var delta = (maxValue-minValue)/2;
    // radius of a cycle
    var midPoint minValue+delta;
    // midPoint of oscillation range
    var lastTimer getTimer();
    // time stamp used to measure how much to move
    // ### oscillateUsingCos moves between two values using a cosine-wave pattern
    function oscillateUsingCos(rpm) {
            
    // measure how much time has passed, and set the appropriate
            // amount to move
            
    var now getTimer();
            var 
    elapsed = (now-lastTimer)/1000;
            var 
    degIncrement = (360*rpm)*(elapsed/60);
            
    // remember the current time for the next move
            
    lastTimer now;
            
    // increment the degree
            
    degree += degIncrement;
            
    // keep the degree looping between -360 and 360
            
    if (degree>360) {
                    
    degree -= 360;
            } else if (
    degree<0) {
                    
    degree += 360;
            }
            
    // determine the new value
            
    var degreeRad radian(degree);
            
    currentValue midPoint+Math.cos(degreeRad)*delta;
    }
    // ### set the vertical or horizontal size of the clip
    // this function is called from a clip's enterframe event,
    // and relies on values set in the clip via onload
    function spin(clipaxis) {
            if (
    axis == "horizontal") {
                    
    clip._xscale currentValue;
            } else {
                    
    clip._yscale currentValue;
            }
            if (
    currentValue<0) {
                    
    clip.gotoAndStop("back");
            } else if (
    currentValue>0) {
                    
    clip.gotoAndStop("front");
            }
    }
    // ### degree to radian converter (used by oscillateUsingCos)
    function radian(degree) {
            return (
    Math.PI/180)*degree

    ...................

    any help/time is greatly appreciated!
    Cheers
    G

  5. #5
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Take a look at this example.
    Attached Files Attached Files

  6. #6
    Senior Member
    Join Date
    Jul 2003
    Location
    G-Vegas, NC
    Posts
    155

    Nice

    Nice simple work there, I like it.

    Thanks,
    FrankenMoro

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    493
    tnx sergwiz.
    nice work!
    Interesting way to control the button.
    Do you know how I could flip it from the diagonal?
    tried adding the code for the _Yscale, strange effect.
    anyway
    Thanks for your help with this, very much appreciated!
    G
    ps can u recommend a good practical book on code?

  8. #8
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    Do you know how I could flip it from the diagonal?
    Do you mean like this (take a look)?

    It's shame on me, but I didn't read any book on ActionScript, I just have no opportunity.
    There are lots of excellent sources in the net like flashkit.com, actionscript.org, flasher.ru and many-many other sites where I can learn something new and useful.
    And I think that the best way for learning is - not to ask questions but to try answering questions by myself.

    Books try here:
    http://www.amazon.com/exec/obidos/AS...565060-3381658
    http://www.amazon.com/exec/obidos/AS...565060-3381658
    http://www.searchbox.org/books.html
    Try looking for Colin Moock
    Attached Files Attached Files

  9. #9
    Senior Member
    Join Date
    May 2001
    Posts
    493

    sergwiz, thank you again for your help.

    Most of the flash I've learned has been through online tutes ... time to get into a'scripting -- I'm going to get a book for reference, your rite about working out things for yourself -- good to have a helping hand here and there.
    what goes around and all that!
    tnx again, your help is v much appreciated.
    G

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