Design e programação criativa na web.

Drag and Drop – AS3

Exemplo de como fazer um “drag and Drop” em actionscript 3.

Código

//

mc1.addEventListener(MouseEvent.MOUSE_OVER,traceName);
mc1.addEventListener(MouseEvent.MOUSE_DOWN,arrastar);
mc1.addEventListener(MouseEvent.MOUSE_UP,parar);
mc1.addEventListener(MouseEvent.MOUSE_UP, colisao);

function traceName(event:MouseEvent):void {
trace(event.target.name);
useHandCursor = true;
buttonMode = true
}

function arrastar(evt:MouseEvent):void{
mc1.startDrag();
}
function parar(evt:MouseEvent):void{
mc1.stopDrag();
}

function colisao(evt:MouseEvent):void{
if(mc1.dropTarget){
texto.text = “Dentro”;
}else{
texto.text = “Fora”;
}
}
//

Ficheiro .fla
-> Download

Comentários a: "Drag and Drop – AS3" (1)

  1. [...] Drag and Drop – AS3 Outubro, 2008 5 [...]

Deixar uma resposta

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Modificar )

Imagem do Twitter

You are commenting using your Twitter account. Log Out / Modificar )

Facebook photo

You are commenting using your Facebook account. Log Out / Modificar )

Connecting to %s

Nuvem de etiquetas

Seguir

Get every new post delivered to your Inbox.