当我调试项目时,我收到了222个警告,它只包含两个警告:
Warning: 1082: Migration issue: Method %s will behave differently in ActionScript 3.0 due to the change in scoping for the this keyword. See the entry for warning 1083 for additional information.
另一个:
Warning: 1008: return value for function '%s' has no type declaration
然后,我提供screenshot of warnings。我找到了esp Warning: 1082: Migration issue
的解决方案,但遗憾的是,我什么也没找到。我读到了Warning: 1082: Migration issue
,它说代码从AS2导入到AS3,但在我的情况下,我从不使用AS2。是的,我从另一个文件导入代码,但是在AS3中。我该如何解决这些错误?关于如何解决它的任何想法?任何建议或帮助将不胜感激。谢谢!
编辑:
这是我的AS文件中的代码:
package {
import flash.display.*;
import flash.text.*;
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip {
public var mainmenu: MainMenu = new MainMenu();
public var scrollinstructwin: ScrollInstructWin = new ScrollInstructWin();
public var startopt: StartOpt = new StartOpt();
public var learnopt: LearnOpt = new LearnOpt();
public var newload: NewLoad = new NewLoad();
public var propocon: PropoCon = new PropoCon();
public var setcon: SetCon = new SetCon();
public var relationcon: RelationCon = new RelationCon();
public var scrollstorywin: ScrollStoryWin = new ScrollStoryWin();
public function Main() {
super();
addChild(mainmenu);
mainmenu.x = 350;
mainmenu.y = 290;
mainmenu.btnStart.addEventListener(MouseEvent.CLICK, start);//warning 1082
mainmenu.btnInstruct.addEventListener(MouseEvent.CLICK, instruct);
}
public function start(event: MouseEvent) {//warning 1008
removeChild(mainmenu);
addChild(startopt);
startopt.x = 350;
startopt.y = 290;
startopt.btnLearn.addEventListener(MouseEvent.CLICK, learn);
startopt.btnPlay.addEventListener(MouseEvent.CLICK, laro);
startopt.btnBack.addEventListener(MouseEvent.CLICK, back);
}
public function instruct(event: MouseEvent) {
removeChild(mainmenu);
addChild(scrollinstructwin);
scrollinstructwin.x = 36.20;
scrollinstructwin.y = 21.50;
scrollinstructwin.btnGi.addEventListener(MouseEvent.CLICK, gi);
}
public function gi(event: MouseEvent) {
removeChild(scrollinstructwin);
addChild(mainmenu);
}
public function back(event: MouseEvent) {
removeChild(startopt);
addChild(mainmenu);
}
public function learn(event: MouseEvent) {
removeChild(startopt);
addChild(learnopt);
learnopt.x = 350;
learnopt.y = 290;
learnopt.btnPropo.addEventListener(MouseEvent.CLICK, propo);
learnopt.btnSets.addEventListener(MouseEvent.CLICK, sets);
learnopt.btnRelations.addEventListener(MouseEvent.CLICK, relations);
learnopt.btnBack3.addEventListener(MouseEvent.CLICK, backo);
}
public function laro(event: MouseEvent) {
removeChild(startopt);
addChild(newload);
newload.x = 350;
newload.y = 290;
newload.btnNew.addEventListener(MouseEvent.CLICK, neww);
newload.btnBack2.addEventListener(MouseEvent.CLICK, backu);
}
public function backo(event: MouseEvent) {
removeChild(learnopt);
addChild(startopt);
}
public function neww(event: MouseEvent) {
removeChild(learnopt);
addChild(scrollstorywin);
scrollstorywin.x = 51.15;
scrollstorywin.y = 30.05;
}
public function backu(event: MouseEvent) {
removeChild(newload);
addChild(startopt);
}
public function propo(event: MouseEvent) {
removeChild(learnopt);
propocon.gotoAndStop(1);
addChild(propocon);
propocon.x = 414.80;
propocon.y = 218.60;
propocon.btnExit.addEventListener(MouseEvent.CLICK, byeol);
}
public function byeol(event: MouseEvent) {
removeChild(propocon);
addChild(learnopt);
}
/*propocon.btnBtm.addEventListener(MouseEvent.CLICK, byl);
public function byl(event: MouseEvent) {
removeChild(propocon);
addChild(learnopt);
}*/
public function sets(event: MouseEvent) {
removeChild(learnopt);
addChild(setcon);
setcon.x = 412.45;
setcon.y = 225.00;
}
public function relations(event: MouseEvent) {
removeChild(learnopt);
addChild(relationcon);
relationcon.x = 400.00;
relationcon.y = 225.00;
}
}
}
我已经评论了1082和1008中的一个警告。您认为这些警告的原因是什么?谢谢!
答案 0 :(得分:1)
警告1008足够清楚;您的函数定义不包含返回类型声明。你的所有功能都没有返回任何东西,所以这是无害的。不过,要消除警告,您可以这样做:
public function start(event: MouseEvent):void {
取代
public function start(event: MouseEvent) {