La bola del ratón se come y cuando usted sacuda el ratón se cae
- amexudo
- Born


- Registrado: May 05, 2009
- Mensajes: 2
- Status: Offline
Hola a todos,
Yo no soy muy experimentado en desarrollo, pero estoy tratando de hacer un sitio web en flash y no se puede hacer una cosa de trabajo: Dentro de la "¿Quiénes somos?" Página del swf adjunto (haga clic en "¿Quiénes somos?") hay una bola que salta del agua y me gustaría que el comportamiento de una manera que cuando el ratón se acerca a la pelota, que se come el ratón y el ratón desaparece . Y cuando la bola se mueve dentro del ratón, si se agita el ratón, se cae.
No puedo obtener el efecto que desea.
¿Alguien puede tratar de darme direcciones?
Gracias y espero que disfrutes de mis sitios de diseño.
Yo no soy muy experimentado en desarrollo, pero estoy tratando de hacer un sitio web en flash y no se puede hacer una cosa de trabajo: Dentro de la "¿Quiénes somos?" Página del swf adjunto (haga clic en "¿Quiénes somos?") hay una bola que salta del agua y me gustaría que el comportamiento de una manera que cuando el ratón se acerca a la pelota, que se come el ratón y el ratón desaparece . Y cuando la bola se mueve dentro del ratón, si se agita el ratón, se cae.
No puedo obtener el efecto que desea.
¿Alguien puede tratar de darme direcciones?
Gracias y espero que disfrutes de mis sitios de diseño.
Código: [ Select ]
package
{
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.MovieClip;
import flash.events.*;
import flash.ui.Mouse;
import flash.utils.Timer;
public class MyBall extends MovieClip
{
private const MOUSE_CLOSE:String = "mouse close";
private const MOUSE_SHAKE:String = "mouse shake";
public var glued:Boolean;//whether the ball is glued to mouse or not
private var _count:Number = 0;//counts how many times the user shakes the mouse
private var lastMouseX:Number;
private var lastMouseY:Number;
private var fishTimer:Timer;
private var myTimer:Timer;
private var myTimer2:Timer;
private var _myTweenX:Tween;
private var _myTweenY:Tween;
private var _edge:Boolean;
private var _sideMove:Number;
private var evt:Event;//event of approaching the mouse to the ball
private var evt2:Event;//event of shaking the mouse
public function MyBall()
{
this.x = 149.3;
this.y = 555.3;
this._sideMove = 100;
this.glued = false;
this.fishTimer = new Timer(1500);
this.fishTimer.addEventListener(TimerEvent.TIMER,onTimerJump);
this.fishTimer.start();
evt = new Event(MOUSE_CLOSE);//event of approaching the mouse to the ball
evt2 = new Event(MOUSE_SHAKE);//event of shaking the mouse
this.myTimer = new Timer(5);
this.myTimer.start();
this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
addEventListener(this.MOUSE_CLOSE, onMouseClose);
this.myTimer2 = new Timer(5);
this.myTimer2.start();
this.myTimer2.addEventListener(TimerEvent.TIMER, onTimer2);
}
//timer that the ball flies when it's not glued to the mouse
private function onTimerJump(e:TimerEvent):void
{
if(this.glued == false)
{
this.fly();
}
}
public function fly():void
{
if ((this.x > 530) || (this.x <100))
{
_edge = true;
}
else
{
_edge = false;
}
if(_edge)
{
_sideMove *= -1;
}
this._myTweenX = new Tween(this, "x", None.easeOut, this.x, this.x + _sideMove , 1.1, true);
this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y - 200, 0.6, true);
this._myTweenY.addEventListener(TweenEvent.MOTION_FINISH, onTweenYEnd);
}
private function onTweenYEnd(e:TweenEvent):void
{
this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y + 200, 1.1, true);
this._myTweenX = new Tween(this, "x", Strong.easeOut, this.x, this.x + _sideMove/2, 0.6, true);
}
private function onMouseClose(e:Event):void {
this.glued = true;
addEventListener(MOUSE_SHAKE, onMouseShake);
}
//timer that checks if the mouse is close to the ball
private function onTimerEvent(e:TimerEvent):void {
if ((Math.abs(this.x - stage.mouseX) < 40) && (Math.abs(this.y - stage.mouseY) < 40)) {
dispatchEvent(evt);//event of approaching the mouse to the ball
this.fishTimer.stop();
}
if (this.glued == true) {
Mouse.hide();
this.x = stage.mouseX;
this.y = stage.mouseY;
this.myTimer2.addEventListener(TimerEvent.TIMER,onTimer2);
this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
}
else {
this.fishTimer.start();
}
}
//timer for when the ball is glued
function onTimer2(e:TimerEvent):void {
if ((Math.abs(lastMouseX - stage.mouseX)>120) || (Math.abs(lastMouseY - stage.mouseY)>120)) {
_count++;
}
else {
_count = 0;
}
lastMouseX = mouseX;
lastMouseY = mouseY;
if (_count == 6) {
dispatchEvent(evt2);//event of shaking the mouse
_count = 0;
//trace("shaked");
removeEventListener(MOUSE_SHAKE, onMouseShake);
}
}
//when the user shakes the mouse, the ball falls down
function onMouseShake(e:Event):void {
this.glued = false;
this._myTweenY = new Tween(this,"y",None.easeIn,this.y, 500, 3);
this.x = 149.3;
this.y = 535.3;
Mouse.show();
this.fishTimer.start();
addEventListener(MOUSE_CLOSE, onMouseClose);
}
}
}
{
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.MovieClip;
import flash.events.*;
import flash.ui.Mouse;
import flash.utils.Timer;
public class MyBall extends MovieClip
{
private const MOUSE_CLOSE:String = "mouse close";
private const MOUSE_SHAKE:String = "mouse shake";
public var glued:Boolean;//whether the ball is glued to mouse or not
private var _count:Number = 0;//counts how many times the user shakes the mouse
private var lastMouseX:Number;
private var lastMouseY:Number;
private var fishTimer:Timer;
private var myTimer:Timer;
private var myTimer2:Timer;
private var _myTweenX:Tween;
private var _myTweenY:Tween;
private var _edge:Boolean;
private var _sideMove:Number;
private var evt:Event;//event of approaching the mouse to the ball
private var evt2:Event;//event of shaking the mouse
public function MyBall()
{
this.x = 149.3;
this.y = 555.3;
this._sideMove = 100;
this.glued = false;
this.fishTimer = new Timer(1500);
this.fishTimer.addEventListener(TimerEvent.TIMER,onTimerJump);
this.fishTimer.start();
evt = new Event(MOUSE_CLOSE);//event of approaching the mouse to the ball
evt2 = new Event(MOUSE_SHAKE);//event of shaking the mouse
this.myTimer = new Timer(5);
this.myTimer.start();
this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
addEventListener(this.MOUSE_CLOSE, onMouseClose);
this.myTimer2 = new Timer(5);
this.myTimer2.start();
this.myTimer2.addEventListener(TimerEvent.TIMER, onTimer2);
}
//timer that the ball flies when it's not glued to the mouse
private function onTimerJump(e:TimerEvent):void
{
if(this.glued == false)
{
this.fly();
}
}
public function fly():void
{
if ((this.x > 530) || (this.x <100))
{
_edge = true;
}
else
{
_edge = false;
}
if(_edge)
{
_sideMove *= -1;
}
this._myTweenX = new Tween(this, "x", None.easeOut, this.x, this.x + _sideMove , 1.1, true);
this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y - 200, 0.6, true);
this._myTweenY.addEventListener(TweenEvent.MOTION_FINISH, onTweenYEnd);
}
private function onTweenYEnd(e:TweenEvent):void
{
this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y + 200, 1.1, true);
this._myTweenX = new Tween(this, "x", Strong.easeOut, this.x, this.x + _sideMove/2, 0.6, true);
}
private function onMouseClose(e:Event):void {
this.glued = true;
addEventListener(MOUSE_SHAKE, onMouseShake);
}
//timer that checks if the mouse is close to the ball
private function onTimerEvent(e:TimerEvent):void {
if ((Math.abs(this.x - stage.mouseX) < 40) && (Math.abs(this.y - stage.mouseY) < 40)) {
dispatchEvent(evt);//event of approaching the mouse to the ball
this.fishTimer.stop();
}
if (this.glued == true) {
Mouse.hide();
this.x = stage.mouseX;
this.y = stage.mouseY;
this.myTimer2.addEventListener(TimerEvent.TIMER,onTimer2);
this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
}
else {
this.fishTimer.start();
}
}
//timer for when the ball is glued
function onTimer2(e:TimerEvent):void {
if ((Math.abs(lastMouseX - stage.mouseX)>120) || (Math.abs(lastMouseY - stage.mouseY)>120)) {
_count++;
}
else {
_count = 0;
}
lastMouseX = mouseX;
lastMouseY = mouseY;
if (_count == 6) {
dispatchEvent(evt2);//event of shaking the mouse
_count = 0;
//trace("shaked");
removeEventListener(MOUSE_SHAKE, onMouseShake);
}
}
//when the user shakes the mouse, the ball falls down
function onMouseShake(e:Event):void {
this.glued = false;
this._myTweenY = new Tween(this,"y",None.easeIn,this.y, 500, 3);
this.x = 149.3;
this.y = 535.3;
Mouse.show();
this.fishTimer.start();
addEventListener(MOUSE_CLOSE, onMouseClose);
}
}
}
- package
- {
- import fl.transitions.*;
- import fl.transitions.easing.*;
- import flash.display.MovieClip;
- import flash.events.*;
- import flash.ui.Mouse;
- import flash.utils.Timer;
- public class MyBall extends MovieClip
- {
- private const MOUSE_CLOSE:String = "mouse close";
- private const MOUSE_SHAKE:String = "mouse shake";
- public var glued:Boolean;//whether the ball is glued to mouse or not
- private var _count:Number = 0;//counts how many times the user shakes the mouse
- private var lastMouseX:Number;
- private var lastMouseY:Number;
- private var fishTimer:Timer;
- private var myTimer:Timer;
- private var myTimer2:Timer;
- private var _myTweenX:Tween;
- private var _myTweenY:Tween;
- private var _edge:Boolean;
- private var _sideMove:Number;
- private var evt:Event;//event of approaching the mouse to the ball
- private var evt2:Event;//event of shaking the mouse
- public function MyBall()
- {
- this.x = 149.3;
- this.y = 555.3;
- this._sideMove = 100;
- this.glued = false;
- this.fishTimer = new Timer(1500);
- this.fishTimer.addEventListener(TimerEvent.TIMER,onTimerJump);
- this.fishTimer.start();
- evt = new Event(MOUSE_CLOSE);//event of approaching the mouse to the ball
- evt2 = new Event(MOUSE_SHAKE);//event of shaking the mouse
- this.myTimer = new Timer(5);
- this.myTimer.start();
- this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
- addEventListener(this.MOUSE_CLOSE, onMouseClose);
- this.myTimer2 = new Timer(5);
- this.myTimer2.start();
- this.myTimer2.addEventListener(TimerEvent.TIMER, onTimer2);
- }
- //timer that the ball flies when it's not glued to the mouse
- private function onTimerJump(e:TimerEvent):void
- {
- if(this.glued == false)
- {
- this.fly();
- }
- }
- public function fly():void
- {
- if ((this.x > 530) || (this.x <100))
- {
- _edge = true;
- }
- else
- {
- _edge = false;
- }
- if(_edge)
- {
- _sideMove *= -1;
- }
- this._myTweenX = new Tween(this, "x", None.easeOut, this.x, this.x + _sideMove , 1.1, true);
- this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y - 200, 0.6, true);
- this._myTweenY.addEventListener(TweenEvent.MOTION_FINISH, onTweenYEnd);
- }
- private function onTweenYEnd(e:TweenEvent):void
- {
- this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y + 200, 1.1, true);
- this._myTweenX = new Tween(this, "x", Strong.easeOut, this.x, this.x + _sideMove/2, 0.6, true);
- }
- private function onMouseClose(e:Event):void {
- this.glued = true;
- addEventListener(MOUSE_SHAKE, onMouseShake);
- }
- //timer that checks if the mouse is close to the ball
- private function onTimerEvent(e:TimerEvent):void {
- if ((Math.abs(this.x - stage.mouseX) < 40) && (Math.abs(this.y - stage.mouseY) < 40)) {
- dispatchEvent(evt);//event of approaching the mouse to the ball
- this.fishTimer.stop();
- }
- if (this.glued == true) {
- Mouse.hide();
- this.x = stage.mouseX;
- this.y = stage.mouseY;
- this.myTimer2.addEventListener(TimerEvent.TIMER,onTimer2);
- this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
- }
- else {
- this.fishTimer.start();
- }
- }
- //timer for when the ball is glued
- function onTimer2(e:TimerEvent):void {
- if ((Math.abs(lastMouseX - stage.mouseX)>120) || (Math.abs(lastMouseY - stage.mouseY)>120)) {
- _count++;
- }
- else {
- _count = 0;
- }
- lastMouseX = mouseX;
- lastMouseY = mouseY;
- if (_count == 6) {
- dispatchEvent(evt2);//event of shaking the mouse
- _count = 0;
- //trace("shaked");
- removeEventListener(MOUSE_SHAKE, onMouseShake);
- }
- }
- //when the user shakes the mouse, the ball falls down
- function onMouseShake(e:Event):void {
- this.glued = false;
- this._myTweenY = new Tween(this,"y",None.easeIn,this.y, 500, 3);
- this.x = 149.3;
- this.y = 535.3;
- Mouse.show();
- this.fishTimer.start();
- addEventListener(MOUSE_CLOSE, onMouseClose);
- }
- }
- }
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Mayo 5th, 2009, 8:07 am
- amexudo
- Born


- Registrado: May 05, 2009
- Mensajes: 2
- Status: Offline
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 3 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 42 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro

