2010-10-26 33 views
1

我正在尝试创建一个基本示例。使用框架,我知道该怎么做,但我想知道如何可以做到这一点使用动作脚本3在动画片段中交换不同颜色的矩形

使用框架:

,其中有6架

  • 红的MovieClip矩形在第一3帧

  • 在过去的3帧蓝矩形

有人可以告诉我如何使用AS3做到这一点?

+0

为什么AS2上有标题? – cregox 2011-04-11 02:02:30

+1

这是错误的...... – user427969 2011-04-12 01:13:48

回答

2

有很多方法可以实现这一点,你可以使用Timer,Tween等......这里有一个基本的例子。

var _count:int; 
var red:Boolean = true; 
var rectangle:Sprite = new Sprite(); 
var rectWidth:int = 300; 
var rectHeight:int = 120; 

addChild(rectangle); 

addEventListener(Event.ENTER_FRAME , enterFrameListener); 

function enterFrameListener(event:Event):void 
{ 
    if(_count > 0 && _count % 3 == 0) 
     colorChange(); 

    _count++; 
} 

function colorChange():void 
{ 
    var color:uint; 

    if(red) 
     color = 0x990000; 
    else 
     color = 0xfadd00; 

    with(rectangle.graphics) 
    { 
     clear(); 
     beginFill(color); 
     drawRect(0 , 0 , rectWidth , rectHeight); 
     endFill(); 

    } 

    red = !red; 
} 
+0

嗨,非常感谢你的例子。非常感谢。问候 – user427969 2010-10-28 00:21:37