사용자 지정 클래스를 만들었습니다 (.as는 아래 :). 내 메인 타임 라인에서 세 개의 인스턴스 (panel1, panel2 및 panel3)에 존재하며 현재 하나의 키 프레임 만 있습니다.커스텀 클래스의 생성자 함수가 여러 번 호출되는 이유는 무엇입니까?
파일을 디버깅 할 때 프레임 1에서 각 인스턴스에 대해 생성자 함수가 호출됩니다. 시원한. 그러나 조금 후에 생성자 함수를 각 인스턴스에 대해 다시 호출하여 변경 한 내용을 지 웁니다.
인스턴스는 모두 라이브러리에서 스테이지를 드래그하여 스테이지에 배치됩니다. 내 스크립트에는 "= 새 Scorepanel() 라인이 없습니다.
이 트리거 무엇 나는 것을 방지 할 수있는 방법?
--Ken (믿을 수 없을만큼 좌절) 프랭클린
{
import flash.display.MovieClip;
import fl.text.TLFTextField;
public class scoreunit extends MovieClip
{
private var team:String = "WHOAMI";
private var points:Number = 0;
private var scorevalue:String;
private var teamname:String;
private var inited:Boolean = false;
function scoreunit()
{
if (! inited)
{
this.teamname = team;
this.scorevalue = String(points);
var teamnamebox=new TLFTextField();
teamnamebox.x = 2.25;
teamnamebox.y = 295.25;
teamnamebox.width = 295.25;
teamnamebox.height = 70;
teamnamebox.text = team;
var scorevaluebox=new TLFTextField();
scorevaluebox.x = 2.25;
scorevaluebox.y = 95.80;
scorevaluebox.width = 295;
scorevaluebox.height = 97.5;
scorevaluebox.text = scorevalue;
trace("I set the starting values");
trace("teamnamebox = ",teamnamebox.text);
trace("scorevalue = ",scorevaluebox.text);
inited = true;
}
}
public function score():Number
{
return points;
}
public function winpoints(n:Number)
{
points += n;
scorevalue = String(points);
scorevaluebox.text = scorevalue;
}
public function losepoints(n:Number)
{
points -= n;
scorevalue = String(points);
scorevaluebox.text = scorevalue;
}
public function setname(s:String)
{
team = s;
teamname = team;
teamnamebox.text = s;
trace("I changed the name to ",teamnamebox.text);
}
public function buzzin()
{
this.gotoAndStop("buzzedin");
}
public function makeddselect()
{
this.gotoAndStop("ddtarget");
}
public function makeyay(y:Number)
{
switch (y)
{
case 1 :
this.gotoAndStop("yay1");
break;
case 2 :
this.gotoAndStop("yay2");
break;
case 3 :
this.gotoAndStop("yay3");
break;
case 4 :
this.gotoAndStop("yay4");
break;
case 5 :
this.gotoAndStop("yay5");
break;
case 6 :
this.gotoAndStop("yay6");
break;
default :
trace("CRASH! "+y+" IS NOT A VALID YAY!");
}
}
public function makeboo(b:Number)
{
switch (b)
{
case 1 :
this.gotoAndStop("boo1");
break;
case 2 :
this.gotoAndStop("boo2");
break;
case 3 :
this.gotoAndStop("boo3");
break;
case 4 :
this.gotoAndStop("boo4");
break;
case 5 :
this.gotoAndStop("boo5");
break;
case 6 :
this.gotoAndStop("boo6");
break;
default :
trace("CRASH! "+b+" IS NOT A VALID BOO!");
}
}
public function makescrewing()
{
this.gotoAndStop("evilface");
}
public function makescrewed()
{
this.gotoAndStop("screwed");
}
public function makesplat()
{
this.gotoAndStop("eekface");
}
public function makefreeze()
{
this.gotoAndStop("frozen");
}
public function makehome()
{
this.gotoAndStop("inactive");
}
}
}
디버깅하려면 다음을 사용하십시오.'var s : String = ''; var mc = this; do {s + = mc.toString(); mc = mc.parent; } while (mc! = null); 추적 (들); ' – scibuff
처음 세 번이나 받았습니다 : [object scoreunit] [object MainTimeline]. 내가 20 번 프레임 세 번 받았다 : [object scoreunit] [object MainTimeline] [object Stage] –
키보드 청취자를 무대에 추가 한 직후였습니다. 흠. –