Jump to content

repetição


anuskka
 Share

Recommended Posts

hmmm.. 😛   nao sei se venho tarde, mas aqui vai:


//importar as libs de tween e easing (classes de animacao)...
import mx.transitions.Tween;
import mx.transitions.easing.*

//defines o teu objecto de animacao...
var motion:Tween = new Tween();

//as seguintes linhas de codigo, constroiem um movie clip, que no teu caso nao deverás precisar pois ja deves ter o teu...
this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc._x = 50;
mc._y = 50;

mc.beginFill(0xFFCC00, 100);
mc.moveTo(-50, -50);
mc.lineTo(50, -50);
mc.lineTo(50, 50);
mc.lineTo(-50, 50);


//prototipo de metodo para a class MovieClip...
MovieClip.prototype.init = function()
{
        //cria variaveis com os pontos para onde o teu mc deve ir, neste caso, esta-se a criar um numero aliatorio com os valores de dimensao do stage...
var val1:Number = Math.ceil(Math.random() * Stage.width);
var val2:Number = Math.ceil(Math.random() * Stage.height);


        //cria a animacao com os valores definidos pelas variaveis "val1" e "val2"
motion = new Tween(this, "_x", Strong.easeOut, this._x, val1, 1, true);
motion = new Tween(this, "_y", Strong.easeOut, this._y, val2, 1, true);

       //metodo para fazer a "repiticao" da animacao (para sempre)...
motion.onMotionFinished = function()
{
	init();
}
}

this.init();

Se estiveres a usar AS3.0, a historia e completamente diferente... 😛

hope that helps...

?

Cumps,

cc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.