root/as3/BetweenAS3/trunk/tests/fp10/BezierTweenTest.as

リビジョン 3079, 2.8 kB (コミッタ: yossy, コミット時期: 4 年 前)

BetweenAS3: Fix: RangeError? has occurred when using bezier tween with Elastic or Back easing. (fixed #106)

Line 
1 /*
2  * BetweenAS3
3  *
4  * Licensed under the MIT License
5  *
6  * Copyright (c) 2009 BeInteractive! (www.be-interactive.org) and
7  *                    Spark project  (www.libspark.org)
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  * THE SOFTWARE.
26  *
27  */
28 package
29 {
30         import flash.display.MovieClip;
31         import flash.display.Shape;
32         import flash.display.Sprite;
33         import flash.events.Event;
34         import flash.events.MouseEvent;
35         import org.libspark.betweenas3.BetweenAS3;
36         import org.libspark.betweenas3.easing.Elastic;
37         import org.libspark.betweenas3.tweens.ITween;
38        
39         /**
40          * @author      yossy:beinteractive
41          */
42         public class BezierTweenTest extends Sprite
43         {
44                 public function BezierTweenTest()
45                 {
46                         addEventListener(Event.ADDED_TO_STAGE, initialize);
47                 }
48                
49                 private function initialize(e:Event):void
50                 {
51                         removeEventListener(Event.ADDED_TO_STAGE, initialize);
52                        
53                         var bg:Shape = new Shape();
54                         bg.graphics.beginFill(0xffffff);
55                         bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
56                         bg.graphics.endFill();
57                         addChild(bg);
58                        
59                         var mc:MovieClip = new MovieClip();
60                         mc.graphics.beginFill(0);
61                         mc.graphics.drawRect(-10, -10, 20, 20);
62                         mc.graphics.endFill();
63                         addChild(mc);
64                        
65                         mc.x = 10;
66                         mc.y = 100;
67                        
68                         _t = BetweenAS3.bezier(mc, {x: 385, y: 207}, null, {x: [58.05, 145.9, 246.7, 345.55], y: [61.4, 80.65, 167.05, 209.3]}, 3.0, Elastic.easeOut);
69                        
70                         _t.play();
71                        
72                         stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler)
73                 }
74                
75                 private var _t:ITween;
76                
77                 private function mouseDownHandler(e:MouseEvent):void
78                 {
79                         if (_t.isPlaying) {
80                                 _t.stop();
81                         }
82                         else {
83                                 if (_t.position == _t.duration) {
84                                         _t.gotoAndPlay(0);
85                                 }
86                                 else {
87                                         _t.play();
88                                 }
89                         }
90                 }
91         }
92 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。