Eh bien, vous faire cela d'une manière vraiment dur. Je suggère aux soins dans une bibliothèque pré-compilés, comme l'assouplissement
tweenlite qui va faire tout cela pour vous.
Si vous voulez vraiment faire cela en main, vous devez utiliser le onEnterFrame "()" fonction qui est exécutée une fois par trame basée sur le taux de trame.
Je ne sais pas quelle version d'ActionScript de votre aide car le vôtre n'est pas correct pour soit la version 2 ou 3. Si mal de vous donner un exemple en AS2 depuis son un peu plus facile à suivre.
function moveObject(targObject, targX){
targObject.onEnterframe = function(){
var currX = this._x;
if(math.floor(currX) > targX){ // round so we don't try to move sub pixels.
// you'll have to change the pluses and greater thans based on your start/end locations
// move object half the distance to the target each frame (linear ease)
targObject._x = (currX - targX)/2;
}else{
delete this.onEnterFrame; // delete the onEnterFrame so its now always using up ram
}
}
}
- function moveObject(targObject, targX){
- targObject.onEnterframe = function(){
- var currX = this._x;
- if(math.floor(currX) > targX){ // round so we don't try to move sub pixels.
- // you'll have to change the pluses and greater thans based on your start/end locations
- // move object half the distance to the target each frame (linear ease)
- targObject._x = (currX - targX)/2;
- }else{
- delete this.onEnterFrame; // delete the onEnterFrame so its now always using up ram
- }
- }
- }
Je n'ai pas testé ce code, mais elle devrait vous donner un point de départ.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com