无法找到定义com.greensock.TweenMax错误

时间:2015-10-25 15:18:19

标签: actionscript-3 flash tweenmax

这是我从Google获得的示例项目。这是一个简单的财富轮项目。当我运行此代码时。我收到错误定义com.greensock.TweenMax无法找到。我知道项目中没有TweenMax路径。我从TweenMax网站下载了包,我的问题是如何将包导入我的项目?有人可以帮帮我吗。我是flash编程的新手。

package
{
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import com.greensock.TweenMax;

    public final class Main extends Sprite
    {
        private var speed:Number = 0;
        private var paddles:Vector.<Sprite> = new Vector.<Sprite>();
        private var line:Shape;
        private var lastPaddle:String;

        public final function Main():void
        {
            paddles.push(wheel.p1, wheel.p2, wheel.p3, wheel.p4, wheel.p5, wheel.p6, wheel.p7, wheel.p8, wheel.p9, wheel.p10);
            listeners('add');
        }

        private final function listeners(action:String):void
        {
            if(action == 'add')
            {
                stage.addEventListener(MouseEvent.MOUSE_DOWN, startDraw);
                stage.addEventListener(MouseEvent.MOUSE_UP, spinWheel);
            }
            else
            {
                stage.removeEventListener(MouseEvent.MOUSE_DOWN, startDraw);
                stage.removeEventListener(MouseEvent.MOUSE_UP, spinWheel);
            }
        }

        private final function startDraw(e:MouseEvent):void
        {
            line = new Shape();
            addChild(line);

            line.graphics.moveTo(mouseX, mouseY);
            line.graphics.lineStyle(8, 0x000000, 0.3);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, drawLine);
        }

        private final function drawLine(e:MouseEvent):void
        {
            line.graphics.lineTo(mouseX, mouseY);
        }

        private final function spinWheel(e:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, drawLine);
            listeners('rm');

            speed = line.height * 0.1;
            removeChild(line);
            line = null;

            stage.addEventListener(Event.ENTER_FRAME, spin);
        }

        private final function spin(e:Event):void
        {
            /* Rotate Wheel */

            wheel.rotationZ += speed;

            /* Detect Value */

            for(var i:int = 0; i < 10; i++)
            {
                if(indicator.hArea.hitTestObject(paddles[i]))
                {
                    lastPaddle = paddles[i].name;
                }
            }

            /* Decrease speed */

            speed -= 0.1;

            /* Remove lIstener and reset speed when wheel stops */

            if(speed <= 0)
            {
                stage.removeEventListener(Event.ENTER_FRAME, spin);
                speed = 10;
                run(lastPaddle);
                listeners('add');
            }
        }

        function run(action:String):void
        {
            switch(action)
            {
                case 'p1':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0xF15D5D, tintAmount:1}});
                    break;
                case 'p2':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0xC06CA8, tintAmount:1}});
                    break;
                case 'p3':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x644D9B, tintAmount:1}});
                    break;
                case 'p4':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x5E98C6, tintAmount:1}});
                    break;
                case 'p5':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x4789C2, tintAmount:1}});
                    break;
                case 'p6':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x55C4CB, tintAmount:1}});
                    break;
                case 'p7':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x57BC80, tintAmount:1}});
                    break;
                case 'p8':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0x90CC6C, tintAmount:1}});
                break;
                case 'p9':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0xEBE666, tintAmount:1}});
                break;
                case 'p10':
                    TweenMax.to(colorMC, 0.5, {colorTransform:{tint:0xF29C69, tintAmount:1}});
                    break;
            }
        }
    }
}

0 个答案:

没有答案