Ball mange la souris et lorsque vous secouez la souris, elle tombe

  • amexudo
  • Born
  • Born
  • No Avatar
  • Inscription: Mai 05, 2009
  • Messages: 2
  • Status: Offline

Message Mai 5th, 2009, 8:07 am

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.

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);
        }
    }
}
  1. package
  2. {
  3.     import fl.transitions.*;
  4.     import fl.transitions.easing.*;
  5.     
  6.     import flash.display.MovieClip;
  7.     import flash.events.*;
  8.     import flash.ui.Mouse;
  9.     import flash.utils.Timer;
  10.     
  11.     public class MyBall extends MovieClip
  12.     {
  13.         
  14.         private const MOUSE_CLOSE:String = "mouse close";
  15.         private const MOUSE_SHAKE:String = "mouse shake";
  16.         public var glued:Boolean;//whether the ball is glued to mouse or not
  17.         private var _count:Number = 0;//counts how many times the user shakes the mouse
  18.         private var lastMouseX:Number;
  19.         private var lastMouseY:Number;
  20.         private var fishTimer:Timer;
  21.         private var myTimer:Timer;
  22.         private var myTimer2:Timer;
  23.         private var _myTweenX:Tween;
  24.         private var _myTweenY:Tween;
  25.         private var _edge:Boolean;
  26.         private var _sideMove:Number;
  27.         private var evt:Event;//event of approaching the mouse to the ball
  28.         private var evt2:Event;//event of shaking the mouse
  29.         
  30.         public function MyBall()
  31.         {
  32.             this.x = 149.3;
  33.             this.y = 555.3;
  34.             this._sideMove = 100;
  35.             this.glued = false;
  36.             this.fishTimer = new Timer(1500);
  37.             this.fishTimer.addEventListener(TimerEvent.TIMER,onTimerJump);
  38.             this.fishTimer.start();
  39.             evt = new Event(MOUSE_CLOSE);//event of approaching the mouse to the ball
  40.             evt2 = new Event(MOUSE_SHAKE);//event of shaking the mouse
  41.             this.myTimer = new Timer(5);
  42.             this.myTimer.start();
  43.             this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
  44.             addEventListener(this.MOUSE_CLOSE, onMouseClose);
  45.             this.myTimer2 = new Timer(5);
  46.             this.myTimer2.start();
  47.             this.myTimer2.addEventListener(TimerEvent.TIMER, onTimer2);
  48.         }
  49.         
  50.         
  51.         //timer that the ball flies when it's not glued to the mouse
  52.         private function onTimerJump(e:TimerEvent):void
  53.         {
  54.             if(this.glued == false)
  55.             {
  56.                 this.fly();
  57.             }
  58.         }
  59.         
  60.         public function fly():void
  61.         {
  62.             if ((this.x > 530) || (this.x <100))
  63.             {
  64.                 _edge = true;
  65.             }
  66.             else
  67.             {
  68.                 _edge = false;
  69.             }
  70.             
  71.             if(_edge)
  72.             {
  73.                 _sideMove *= -1;
  74.             }
  75.                 
  76.             this._myTweenX = new Tween(this, "x", None.easeOut, this.x, this.x + _sideMove , 1.1, true);
  77.             this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y - 200, 0.6, true);
  78.             this._myTweenY.addEventListener(TweenEvent.MOTION_FINISH, onTweenYEnd);
  79.             
  80.             
  81.         }
  82.         
  83.         private function onTweenYEnd(e:TweenEvent):void
  84.         {
  85.             this._myTweenY = new Tween(this, "y", Strong.easeOut, this.y, this.y + 200, 1.1, true);
  86.             this._myTweenX = new Tween(this, "x", Strong.easeOut, this.x, this.x + _sideMove/2, 0.6, true);
  87.         }
  88.         
  89.         
  90.         
  91.         
  92.         private function onMouseClose(e:Event):void {
  93.             this.glued = true;
  94.             addEventListener(MOUSE_SHAKE, onMouseShake);
  95.         }
  96.         
  97.         //timer that checks if the mouse is close to the ball
  98.         private function onTimerEvent(e:TimerEvent):void {
  99.                 
  100.             if ((Math.abs(this.x - stage.mouseX) < 40) && (Math.abs(this.y - stage.mouseY) < 40)) {
  101.                 dispatchEvent(evt);//event of approaching the mouse to the ball
  102.                 this.fishTimer.stop();
  103.             }
  104.             
  105.                     
  106.             if (this.glued == true) {
  107.                 Mouse.hide();
  108.                 this.x = stage.mouseX;
  109.                 this.y = stage.mouseY;
  110.                 this.myTimer2.addEventListener(TimerEvent.TIMER,onTimer2);
  111.                 this.myTimer.addEventListener(TimerEvent.TIMER, onTimerEvent);
  112.             }
  113.             else {
  114.                 this.fishTimer.start();
  115.             }
  116.         }
  117.         
  118.         //timer for when the ball is glued
  119.         function onTimer2(e:TimerEvent):void {
  120.             if ((Math.abs(lastMouseX - stage.mouseX)>120) || (Math.abs(lastMouseY - stage.mouseY)>120)) {
  121.                 _count++;
  122.             }
  123.             else {
  124.                 _count = 0;
  125.             }
  126.             lastMouseX = mouseX;
  127.             lastMouseY = mouseY;
  128.             if (_count == 6) {
  129.                 dispatchEvent(evt2);//event of shaking the mouse
  130.                 _count = 0;
  131.                 //trace("shaked");
  132.                 removeEventListener(MOUSE_SHAKE, onMouseShake);
  133.                 
  134.             }
  135.         }
  136.         
  137.         //when the user shakes the mouse, the ball falls down
  138.         function onMouseShake(e:Event):void {
  139.             this.glued = false;
  140.             this._myTweenY = new Tween(this,"y",None.easeIn,this.y, 500, 3);
  141.             this.x = 149.3;
  142.             this.y = 535.3;
  143.             Mouse.show();
  144.             this.fishTimer.start();
  145.             addEventListener(MOUSE_CLOSE, onMouseClose);
  146.         }
  147.     }
  148. }
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Mai 5th, 2009, 8:07 am

  • amexudo
  • Born
  • Born
  • No Avatar
  • Inscription: Mai 05, 2009
  • Messages: 2
  • Status: Offline

Message Mai 5th, 2009, 8:08 am

http://www.dreamfarmer.com/ - C'est le site
  • Flanders
  • Beginner
  • Beginner
  • Avatar de l’utilisateur
  • Inscription: Fév 27, 2006
  • Messages: 48
  • Loc: Reno, Nevada US
  • Status: Offline

Message Mai 7th, 2009, 1:45 am

J'ai bien aimé les graphismes sur la page d'accueil. Pretty cool. Je ne peux pas vraiment répondre à votre question si.

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
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC