好的,所以我要做的就是将我的主机链接到我的主菜单。但我一直遇到错误。这是错误。
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main_Menu_fla::MainTimeline/frame1()[Main_Menu_fla.MainTimeline::frame1:11]
现在我明白它说它试图找到一些尚未存在的东西,但我确实没有太多的代码。我将首先提出我的主机代码,然后是我的主菜单代码。
主框架
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
import flash.events.Event;
var loader:Loader = new Loader();
loader.load(new URLRequest('Main_Menu.swf'));
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loopProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadScene);
function loopProgress(event:ProgressEvent):void{
var percentLoad:Number = event.bytesLoaded/event.bytesTotal;
var percentString:String = Math.ceil(percentLoad * 100).toString() + '%';
percent_txt.text = percentString;
bar_mc.scaleX = percentLoad;
}
function loadScene(event:Event):void{
removeChild(percent_txt);
removeChild(loading_txt);
removeChild(bar_mc);
stage.addChild(loader);
}
function loadExternalSWF(screen:String):void{
loader.unloadAndStop();
loader.load(new URLRequest(screen));
addChild(loading_txt);
addChild(bar_mc);
addChild(percent_txt);
}
主菜单
import flash.net.URLLoader;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.events.TransformGestureEvent;
Multitouch.inputMode = MultitouchInputMode.GESTURE;
//Side Menu Swipe
smenu_mc.stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe);
//Top Menu Swipe
tmenu_mc.stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, downSwipe);
function onSwipe (e:TransformGestureEvent):void{
if (e.offsetX == 1){
//swipe to the right
smenu_mc.x += 258;
}
if (e.offsetX == -1){
smenu_mc.x -= 258;
}
}
function downSwipe (e:TransformGestureEvent):void{
if (e.offsetY == 1){
//Menu can only swipe down
tmenu_mc.y += 56;
}
if (e.offsetY == -1){
tmenu_mc.y -= 56;
}
}
如果有人能帮助我弄清楚这里发生了什么,我们将不胜感激。