Ball mange la souris et lorsque vous secouez la souris, elle tombe
- amexudo
- Born


- Inscription: Mai 05, 2009
- Messages: 2
- Status: Offline
Bonjour à tous,
Je ne suis pas très expérimenté en développement, mais j'essaie de faire un site en flash et ne peut pas faire une chose travail: A l'intérieur du «Qui sommes-nous?" page de l'swf ci-joint (cliquer sur "Qui sommes-nous?") il ya un ballon qui saute de l'eau et je voudrais qu'il le comportement d'une manière que, lorsque la souris s'approche du ballon, il mange la souris et la souris disparaît . Et lorsque la balle se déplace dans la souris, si vous secouez la souris, il tombe.
Je ne peux pas obtenir l'effet je voudrais.
Quelqu'un peut-il essayer de me donner les directions?
Je vous remercie et j'espère que vous apprécierez mes sites de conception.
Je ne suis pas très expérimenté en développement, mais j'essaie de faire un site en flash et ne peut pas faire une chose travail: A l'intérieur du «Qui sommes-nous?" page de l'swf ci-joint (cliquer sur "Qui sommes-nous?") il ya un ballon qui saute de l'eau et je voudrais qu'il le comportement d'une manière que, lorsque la souris s'approche du ballon, il mange la souris et la souris disparaît . Et lorsque la balle se déplace dans la souris, si vous secouez la souris, il tombe.
Je ne peux pas obtenir l'effet je voudrais.
Quelqu'un peut-il essayer de me donner les directions?
Je vous remercie et j'espère que vous apprécierez mes sites de conception.
Code: [ 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


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Mai 5th, 2009, 8:07 am
- amexudo
- Born


- Inscription: Mai 05, 2009
- Messages: 2
- Status: Offline
Page 1 sur 1
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
Afficher de l'information
- Total des messages de ce sujet: 3 messages
- Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 55 invités
- Vous ne pouvez pas poster de nouveaux sujets
- Vous ne pouvez pas répondre aux sujets
- Vous ne pouvez pas éditer vos messages
- Vous ne pouvez pas supprimer vos messages
- Vous ne pouvez pas joindre des fichiers

