Tutorial 6 - Animación con ActionScript 3.0

Paso 18 de 19

Este es el aspecto completo que tendrá la programación completa de este tutorial:

cloud1_mc.alpha = .6;
cloud2_mc.alpha = .4;
cloud2_mc.scaleY = .7;
cloud2_mc.z = 300;
cloud1_mc.buttonMode = true;
cloud2_mc.buttonMode = true;

cloud1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
cloud1_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
cloud1_mc.addEventListener(MouseEvent.ROLL_OUT, drop);
cloud1_mc.addEventListener(Event.ENTER_FRAME, wind);

cloud2_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
cloud2_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
cloud2_mc.addEventListener(MouseEvent.ROLL_OUT, drop);
cloud2_mc.addEventListener(Event.ENTER_FRAME, wind);
function drag(e:MouseEvent):void 
{
    e.target.startDrag();
}

function drop(e:MouseEvent):void 
{
    e.target.stopDrag();
}

function wind(e:Event):void 
{
    e.target.x += .4;
    if (e.target.x > 715) 
    {
        e.target.x = -315;
    }
}