A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Start/Stop MC in a tooltip

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    3

    Start/Stop MC in a tooltip

    Hello,

    Attached is my .fla

    Basically, I followed a tutorial
    http://library.creativecow.net/artic...video-tutorial
    and have a basic tooltip working (actions in layer1, frame1 of main
    timeline).

    Code:
    tooltip._visible = false;
    
    var tipInt;
    
    b1.onRollOver = function() {
        tipInt = setInterval(showTip,100);
    }
    
    b1.onRollOut = function() {
        hideTip();
    }
    
    b2.onRollOver = function() {
        tipInt = setInterval(showTip,100);
    }
    
    b2.onRollOut = function() {
        hideTip();
    }
    
    var count = 0;
    
    function showTip() {
        if(count == 1) {
            clearInterval(tipInt);
            count = 0;
            tooltip._x = _root._xmouse;
            tooltip._y = _root._ymouse;
            tooltip._visible = true;
            _root.onMouseMove = function() {
                tooltip._x = _root._xmouse;
                tooltip._y = _root._ymouse;
                updateAfterEvent();
            }
        }
        
        else {
            count++;
        
        }
    }
    
    function hideTip() {
        clearInterval(tipInt);
        tooltip._visible = false;
        delete _root.onMouseMove;
    }
    However, I don't know enough to work out how to START the tooltip MC
    playing when it's visible and STOP it when hidden. Currently it's as if it
    loops continuously in the background. I don't wish to pause the MC when
    not visible, just restart it from beginning when the tooltip shows again.

    Hope that makes sense.

    Also, IDEALLY I'd like a quick fade-in and fade-out of the tooltip when
    it's made visible or hidden. From 0% alpha to 100% over a second
    or so. So it fades in to visible onRollOver and fades to hidden onRollOut,
    rather than just appearing instantly.

    If anyone could shed some light on this I'd be extremely grateful.

    Regards,
    Ralph
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Mar 2006
    Posts
    139
    hello,

    just add

    Actionscript Code:
    _root.tooltip.gotoAndPlay(1);

    to your showTip function so it reads:

    Actionscript Code:
    function showTip() {
    _root.tooltip.gotoAndPlay(1);
        if(count == 1) {
            clearInterval(tipInt);
            count = 0;
            tooltip._x = _root._xmouse;
            tooltip._y = _root._ymouse;
            tooltip._visible = true;
            _root.onMouseMove = function() {
                tooltip._x = _root._xmouse;
                tooltip._y = _root._ymouse;
                updateAfterEvent();
               
            }
        }

  3. #3
    Senior Member
    Join Date
    Mar 2006
    Posts
    139
    hello,

    just add

    Actionscript Code:
    _root.tooltip.gotoAndPlay(1);

    to your showTip function so it reads:

    Actionscript Code:
    function showTip() {_root.tooltip.gotoAndPlay(1);
        if(count == 1) {
            clearInterval(tipInt);
            count = 0;
            tooltip._x = _root._xmouse;
            tooltip._y = _root._ymouse;
            tooltip._visible = true;
            _root.onMouseMove = function() {
                tooltip._x = _root._xmouse;
                tooltip._y = _root._ymouse;
                updateAfterEvent();    
            }
        }

    and see if that works!

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    3
    pumpkin2006,

    It worked a treat! Thank you!


    Now just for this fade-in/out. I wonder if its something as simple. Or perhaps I'd be better off using TweenLite or something?

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