El codigo es este:
Código ActionScript :
/*--- declare variables and instances------*/ var btnStart:Button; var mcBubble:MovieClip; var bubbleCount:Number = 1; var score:Number = 0; /*--- create objects------*/ var initBubble:Object = new Object(); var sndRambo:Sound = new Sound(); sndRambo.attachSound("locooo"); /*--- handle events------*/ mcPin.onPress = function(){ } this.startDrag(false,0,65,635,450); mcPin.onRelease = function(){ this.stopDrag(); } initBubble.onEnterFrame = function(){ this._x += this.speedX; this._y += this.speedY; this._rotation += this.rotateAngle; this._alpha -= 2; if(this._x < 65 || this._x>635){ this.speedX *=-1; this.rotateAngle *=-1; } if(this._y< 80 || this._y> 375){ this.speedY *=-1; this.rotateAngle *=-1; } if(this._alpha <=0){ this.unloadMovie(); } if(this.hitTest(mcPin)){ this.unloadMovie(); sndRambo.start(); score++; txtScore.text = String(score); } } btnStart.onRelease = function() { for(var i = 0; i<10;i++){ makeABubble(); } score = 0; txtScore.text = String(score); mcPin._x = 350; mcPin.y = 410; } /*--- functions------*/ function makeABubble() { initBubble.speedX = Math.random()*20-10; initBubble.speedY = Math.random()*20-10; initBubble.rotateAngle = Math.random()*20-10; bubbleName = "mcBubble"+String(bubbleCount); bubbleDepth = this.getNextHighestDepth(); mcBubble.duplicateMovieClip(bubbleName,bubbleDepth,initBubble); this[bubbleName]._x = Math.random()*550+75; this[bubbleName]._y = Math.random()*250+75; bubbleCount++; }
En este caso estoy arrastrando un puntero sobre la escena para darle a una serie de objetos y conseguir una puntuación. Para conseguir arrastrar este movieclip he usado : mcPin.onPress = function(){
}
this.startDrag(false,0,65,635,450);
Sin embargo, deseaba mover el puntero pasando el ratón por la pantalla en vez de arrastrar , es decir, sin tener que presionar el botón del ratón.
Espero que me puedan ayudar.
Muchas gracias.