我是AS3的新手,试图将包含结果框的VectorFile添加到as文件中(sresultnologin)。但它显示错误1136参数数量不正确。尝试addChild时,期望1在此行var s3:SearchVectorTest= new SearchVectorTest();
上。
想知道这个错误是什么,我该如何解决它。谢谢你的时间。
AS3(sresultnologin)
package com.clark
{
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Stage;
import fl.controls.Button;
public class sresultnologin extends MovieClip {
public var s1:Searchreult = new Searchreult ();
public function sresultnologin(){
// init
addEventListener(Event.ADDED_TO_STAGE, onadded);
function onadded (event:Event):void{
s1.x=-10;
s1.y=10;
addChild(s1);
}
var s3:SearchVectorTest= new SearchVectorTest();
addChild (s3);
s1.SRhome.addEventListener(MouseEvent.CLICK, fl_ClickToGoTol);
s1.ARsearch.addEventListener(MouseEvent.CLICK, fl_ClickToGosearch);
}
// private methods
private function fl_ClickToGoTol(event:MouseEvent):void
{
var s9:Account = new Account ();
removeChild(s1);
addChild(s9);
}
private function fl_ClickToGosearch(event:MouseEvent):void
{
var s9:searchVO1 = new searchVO1 ();
removeChild(s1);
addChild(s9);
}
}
}
SearchVectorTest
package com.clark
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.display.Sprite;
public class SearchVectorTest extends MovieClip
{
public function SearchVectorTest(test:Vector.<searchVO1>)
{
super();
for (var j:int = 0; j < test.length; j++)
{
trace(test[j].nobed);
trace(test[j].zip);
trace(test[j].Location);
trace(test[j].price);
}
var currentY:int = 270;
for (var k:int = 0; k < test.length; k++)
{
var Bolder:Listing5 = new Listing5();
Bolder.x=80;
var bf:TextField = new TextField();
var bf1:TextField = new TextField();
var bf2:TextField = new TextField();
var bf3:TextField = new TextField();
bf3.width = 100;
bf.defaultTextFormat = new TextFormat("Arial", 12, 0, null, null, null, null, null, TextFormatAlign.CENTER);
bf.width = 100;
bf.autoSize = TextFieldAutoSize.CENTER;
bf1.width = 100;
bf1.autoSize = TextFieldAutoSize.CENTER;
bf2.autoSize = TextFieldAutoSize.CENTER;
bf3.autoSize = TextFieldAutoSize.CENTER;
bf3.width = 100;
bf1.y= bf.height+5;
bf.text = test[k].nobed;
bf1.text = test[k].zip;
bf2.text = test[k].Location;
bf3.text = test[k].price;
bf1.x = (Bolder.height-bf.height)*.5
bf3.x = (Bolder.height-bf.height)*.5
bf.x = (Bolder.height-bf.height)*.5
bf.y = (Bolder.height-bf.height)*.15
Bolder.addChild(bf);
Bolder.addChild(bf1);
Bolder.addChild(bf2);
Bolder.addChild(bf3);
Bolder.y = currentY;
addChild(Bolder);
currentY += Bolder.height + 35;
}
}
}
}
答案 0 :(得分:1)
您的SearchVectorTest
构造函数需要一个参数,如行public function SearchVectorTest(test:Vector.<searchVO1>)
中所述,并且您试图将0个参数传递给该构造函数。此外,您不能在那里传递null,因为您在构造函数中请求向量的长度。您需要立即为其提供有效的向量,或者调用new SearchVectorTest(new Vector.<searchVO1>())
。
答案 1 :(得分:1)
通过查看代码, SearchVectorTest 类的构造函数具有Vector类型的参数。因此,在创建实例时,您需要将类型为vector的参数传递给该构造函数,例如
var s3:SearchVectorTest= new SearchVectorTest(anyVectorObject);
否则将该参数设为默认参数,例如将构造函数代码更改为
public function SearchVectorTest(test:Vector.<searchVO1> = null)
希望有所帮助