我一直收到此错误:ArgumentError:错误#1063:代码:: SimonPad()上的参数计数不匹配。预计2,得0。 我不知道发生了什么,特别是对于uint。任何帮助将不胜感激。 我在下面显示了两个代码块。它们基于Actionscript 3.0 当我试图运行这些代码时,我没有在舞台上得到任何代码。这些代码应该显示四个不同颜色的盒子,但它根本不起作用。求助。
package code
{
import flash.display.MovieClip;
import flash.events.Event;
public class Main extends MovieClip
{
private var pads:Array = new Array();
public function Main()
{
var pad:SimonPad;
pad = new SimonPad(0xAA0000, 0xFF0000);
pad.x = 5;
pad.y = 5;
addChild(pad)
pads.push(pad)
pad = new SimonPad(0x0000AA, 0x6666FF);
pad.x = 205;
pad.y = 205;
addChild(pad)
pads.push(pad)
pad = new SimonPad(0xAAAA00, 0xFFFF00);
pad.x = 5;
pad.y = 205;
addChild(pad)
pads.push(pad)
pad = new SimonPad(0x00AA00, 0x00FF00);
pad.x = 205;
pad.y = 205;
addChild(pad)
pads.push(pad)
addEventListener(Event.ENTER_FRAME, theFrame);
}
private function theFrame(e:Event):void
{
for (var i:int = 0; i < pads.length; i++)
{
(pads[i] as SimonPad).update();
}
}
}
}
package code
{
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.MouseEvent;
public class SimonPad extends Sprite
{
private var dark:Shape;
private var light:Shape;
public function SimonPad(darkColor:uint, lightColor:uint)
{
dark = new Shape();
dark.graphics.beginFill(darkColor, 1);
dark.graphics.drawRect(0,0,190,190);
dark.graphics.endFill();
addChild(dark);
light = new Shape();
light.graphics.beginFill(lightColor, 1);
light.graphics.drawRect(0,0,190,190);
light.graphics.endFill();
addChild(light);
light.alpha = 0;
mouseChildren = false;
addEventListener(MouseEvent.CLICK, downClicked);
}
private function downClicked (e:MouseEvent):void
{
flash();
}
public function flash():void
{
light.alpha = 2;
}
public function update():void
{
if (light.alpha > 0)
{
light.alpha *= 0.85;
if (light.alpha < 0.0125)
{
light.alpha = 0;
}
}
}
}
}
答案 0 :(得分:2)
在设计时,您的舞台上看起来确实有一个手动放置的SimonPad
实例。跟踪手动放置SimonPad
实例的Flash项目。另外,为了获得帧,您可以尝试这个技巧:在SimonPad()
函数中,除了为构造函数参数提供默认值之外,还可以添加以下行:
var e:Error=new Error();
trace(e.getStackTrace());
这将为您提供包含at MainTimeline.frameXXX
行内容的内容的跟踪,其中包含一个帧编号或at Sprite.constructChildren() at Sprite() at SomeClass()
,它会提示您哪个类的库原型具有SimonPad
引用。