Gravando o Movimento do Mouse




Neste tutorial iremos ensinar a gravar todos os movimentos do mouse dentro do seu filme flash, em seguida, uma cópia do seu mouse irá repetir os movimentos.

>Prévia

01. Crie três botões: "Record", "Play" e "Stop", e dê a eles o nome: "recBtn", "playBtn" e "stopBtn" respectivamente.

02. Em seguida, crie o mouse Movie Clip para simular um mouse "real".Pegue a figura abaixo para fazer isto.



03. Arraste a setinha do mouse que a gente criou para o palco. Dê nome a setinha de "mouseMC"

04. Abra o Action Script na camada da setinha e cole:


//make the mouse copy invisible mouseMC._visible = false; //we are not recording the mouse yet so its false var recording = false; //not playing the mouse var playing = false; //index for the arrays that will store the mouse movement var index = 0; //arrays for the x and y position of the mouse var mPosX = new Array(); var mPosY = new Array(); _root.onEnterFrame = function() { //if we are recording we copy the mouse position to the arrays if(recording) { //copy _x and _y coordinate mPosX[index] = _root._xmouse; mPosY[index] = _root._ymouse; //increase index by 1 to use an empty position inside the arrays on the next frame index++ } //if we are playing what we recorded else if (playing) { //set the mouse Movie Clip position to the coordinates inside the arrays mouseMC._x = mPosX[index] mouseMC._y = mPosY[index] //increase index to move to the next position inside the arrays index++; //if we are at the last position of the mouse if(index == mPosX.length) { //show the original mouse Mouse.show(); //and make the copy invisible _root.mouseMC._visible = false; } } }



Agora seu programinha de gravar o movimento do mouse está pronto.

>Baixar o arquivo (.fla)

Site de origem: http://www.webzo.org

Até a próxima.

Gostou do blog? comenta blz? :D

0 comentários: