库类的使用再次让我感到困惑。我有以下情况:
package com.op_pad.pages
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
/**
* ...
* @author Martino Wullems
*/
public class Page extends MovieClip
{
public var currentPage:String = ""; //help page label
public var testvar:int = 0;
var helpPage:HelpPage;
public function Page(PAGENAME:String = null):void {
//tweening etc
addEventListener(Event.ADDED_TO_STAGE, onStage);
trace("currentPage: " + currentPage);
trace("testvar: " + testvar);
}
private function onStage(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, onStage);
trace("on stgae called");
try { terug.addEventListener(MouseEvent.CLICK, goback, false, null, true) } catch (e) { };
try{homebutton.addEventListener(MouseEvent.CLICK, goHome, false, 0, true)}catch (e) { };
try { stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true) } catch (e) { trace("back button fail"); };
try { help.addEventListener(MouseEvent.CLICK, showHelpPage, false, 0, true) } catch (e) { trace("help not found") };
}
public function addListeners():void {
//try{terug.addEventListener(MouseEvent.CLICK, goback, false, null, true)}catch(e){};
//try{homebutton.addEventListener(MouseEvent.CLICK, goHome, false, 0, true)}catch (e) { };
//try{stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true)}catch (e) {trace("back button fail"); };
}
public function goback(e:MouseEvent):void
{
try { MovieClip(parent).loading = false } catch (e) { trace("loading boolean not existent");}
MovieClip(parent).removeChild(this);
}
private function goHome(e:MouseEvent):void
{
try { MovieClip(parent).loading = false } catch (e) { trace("loading boolean not existent");}
MovieClip(parent).removeChild(this);
}
private function showHelpPage(e:MouseEvent):void
{
helpPage = new HelpPage();
addChild(helpPage);
helpPage.gotoAndStop(currentPage);
trace("help page called, currentPage: " + currentPage);
}
private function onKeyDown(e:KeyboardEvent):void
{
//when keyboard back is pressed
if (e.keyCode == Keyboard.BACK) {
e.preventDefault();
e.stopImmediatePropagation();
goback(null);
}
}
}
}
草率的代码,仍然需要清理。
继承 Page 类的子类
package
{
import com.op_pad.pages.Page;
/**
* ...
* @author Martino Wullems
*/
public class FavorietenPage extends Page
{
public function FavorietenPage():void
{
trace("favorietenpage called");
super();
currentPage = "favorieten";
}
}
}
“FavorietenPage”也是我想添加到舞台的图书馆项目。我尝试了几种设置,但无法使其正常工作。
对我来说最合乎逻辑的似乎是以下 [图书馆项目属性]: Class: com.op_pad.pages.FavorietenPage BaseClass: com.op_pad.pages.Page;
使用类时我不能放入任何基类,所以我不得不删除基类。仅使用该类时,我得到一大堆错误根本没有任何意义,即使我注释掉 Page 类中的所有代码,仍然会出现。
com\op_pad\pages\FavorietenPage.as:7: 1152: A conflict exists with inherited definition com.op_pad.pages:Page.help in namespace public.
com\op_pad\pages\FavorietenPage.as:12: 1152: A conflict exists with inherited definition com.op_pad.pages:Page.terug in namespace public.
com\op_pad\pages\FavorietenPage.as:21: 1152: A conflict exists with inherited definition com.op_pad.pages:Page.home in namespace public.
这对我来说根本没有任何意义。知道应该如何使用这种情况吗?在此先感谢