我似乎找不到这个问题的答案。我无法使以下工作:
public class Callbattle extends MovieClip
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.InteractiveObject;
import flash.events.MouseEvent;
import global.Globalvar;
public var battlegraphics:Array = new Array();
public function Battle()
{
var battlewindow:MovieClip = new Battlewindow() as MovieClip;
battlegraphics.push(addChild(battlewindow));
battlewindow.x = 4;
battlewindow.y = 248;
var attackbutton:MovieClip = new Battlebutton() as MovieClip;
battlegraphics.push(addChild(attackbutton));
attackbutton.x = 192;
attackbutton.y = 255;
attackbutton.addEventListener(MouseEvent.CLICK, Attackclicked);
}
public function Attackclicked(event:MouseEvent):void{
battlegraphics[attackbutton].y = 248;
}
}
我收到错误
Battlegraphics[攻击按钮].y = 248;
在尝试这种将影片剪辑添加到数组的方法之前,我这样做了,结果相同:
public class Callbattle extends MovieClip
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.InteractiveObject;
import flash.events.MouseEvent;
import global.Globalvar;
public function Battle()
{
var battlewindow:MovieClip = new Battlewindow() as MovieClip;
this.addChild(battlewindow);
battlewindow.x = 4;
battlewindow.y = 248;
var attackbutton:MovieClip = new Battlebutton() as MovieClip;
this.addChild(attackbutton);
attackbutton.x = 192;
attackbutton.y = 255;
attackbutton.addEventListener(MouseEvent.CLICK, Attackclicked);
while (Globalvar.battle == true){
if (hero1turn == true){
}
}
}
public function Attackclicked(event:MouseEvent):void{
attackbutton.y = 248;
}
}
我基本上只是希望能够从另一个函数访问一个影片剪辑。
谢谢大家,任何帮助都会很棒-马克