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

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

BetweenAS3: Moved a delay setting to the BetweenAS3.delay method for more flexibility.

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.Cubic;
37         import org.libspark.betweenas3.easing.Exponential;
38         import org.libspark.betweenas3.easing.Linear;
39         import org.libspark.betweenas3.tweens.ITween;
40        
41         /**
42          * @author      yossy:beinteractive
43          */
44         public class SlicedTweenTest extends Sprite
45         {
46                 public function SlicedTweenTest()
47                 {
48                         addEventListener(Event.ADDED_TO_STAGE, initialize);
49                 }
50                
51                 private function initialize(e:Event):void
52                 {
53                         removeEventListener(Event.ADDED_TO_STAGE, initialize);
54                        
55                         var bg:Shape = new Shape();
56                         bg.graphics.beginFill(0xffffff);
57                         bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
58                         bg.graphics.endFill();
59                         addChild(bg);
60                        
61                         var mc:MovieClip = new MovieClip();
62                         mc.graphics.beginFill(0);
63                         mc.graphics.drawRect(-10, -10, 20, 20);
64                         mc.graphics.endFill();
65                         addChild(mc);
66                        
67                         mc.x = 100;
68                         mc.y = 100;
69                        
70                         // 一部分だけタイムスケールする
71                        
72                         var t:ITween = BetweenAS3.delay(BetweenAS3.tween(mc, {x: 500}, null, 1.0, Cubic.easeIn), 0.5);
73                        
74                         _t = BetweenAS3.serial(
75                                 BetweenAS3.slice(t, 0, 1.3),
76                                 BetweenAS3.scale(BetweenAS3.slice(t, 1.3, 1.4), 20),
77                                 BetweenAS3.slice(t, 1.4, 1.5)
78                         );
79                        
80                         _t.play();
81                        
82                         stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler)
83                 }
84                
85                 private var _t:ITween;
86                
87                 private function mouseDownHandler(e:MouseEvent):void
88                 {
89                         if (_t.isPlaying) {
90                                 _t.stop();
91                         }
92                         else {
93                                 if (_t.position == _t.duration) {
94                                         _t.gotoAndPlay(0);
95                                 }
96                                 else {
97                                         _t.play();
98                                 }
99                         }
100                 }
101         }
102 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。