Actionscript: if statement?

  • Started
  • Last post
  • 2 Responses
  • mikeim

    Can someone show me how to add an if statement to my existing as? This is for a banner ad so if a user rolls-over it, the 'reanimate' function happens, and if not then the timeout function should kick in. I'm trying to avoid the same function happening if it's already taking place i.e. the user has rolled over the button:

    //
    stop();
    //
    import textTransition;
    import mx.transitions.easing.*;
    function rand():String {
    return String(Math.ceil(Math.random()*2...
    }

    var t:textTransition = new textTransition(yourTextfield, {_x:[rand, rand], _y:[rand, rand], _rotation:[rand, rand], ease:Elastic.easeOut, speed:1600, gap:20});
    //

    var my_timedProcess:Number = setTimeout(reanimate, 8000);

    function reanimate () {
    t.reanimate({_x:"0", _y:"0", _rotation:"0", onComplete:fadeUpdated2, onCompleteScope:this});
    function fadeUpdated2():Void {
    t.reanimate({delay:1000, _alpha:0});
    play();
    }
    }

    _root.bg.onRollOver = function():Void {
    t.reanimate({_x:"0", _y:"0", _rotation:"0", onComplete:fadeUpdated, onCompleteScope:this});
    function fadeUpdated():Void {
    t.reanimate({delay:1000, _alpha:0});
    play();
    }
    }

  • mrbee28280

    set a var called isAnimating to true and then in the function you're calling say:

    if(!isAnimating)// only runs if flash
    {
    // then do whatever
    }
    then just set isAnimating to false onComplete of the transition

  • mikeim0

    thx, mrbee
    could u mark up my a.s. so I can see exactly how to implement this?
    i'm no programmer.