我是AS3的新手,正在尝试将包含结果框的VectorFile添加到as文件中(sresultnologin)。但它显示错误1136参数数量不正确。尝试在此行var s3:SearchVectorTest= new SearchVectorTest();
上添加Child时应为1。想知道这个错误是什么,我该如何修复。谢谢你抽出时间。
As3(sresoultnologin)
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;
}
}
}
}
SearchVectorTest
构造函数需要一个参数,如public function SearchVectorTest(test:Vector.<searchVO1>)
行中所述,而您正试图将0个参数传递到该构造函数中。此外,您不能在那里传递null,因为您在构造函数中请求向量的长度。您需要立即给它一个有效的向量,或者调用new SearchVectorTest(new Vector.<searchVO1>())
。
通过查看您的代码,SearchVectorTest类的构造函数具有Vector类型的参数。因此,在创建实例时,需要将vector类型的参数传递给该构造函数,比如var s3:SearchVectorTest= new SearchVectorTest(anyVectorObject);
否则,将该参数作为默认参数,比如将构造函数代码更改为
public function SearchVectorTest(test:Vector.<searchVO1> = null)
希望它能帮助