如何导入文档类文件到另外一个flash文件? [英] How to import a document class file into another flash file?
本文介绍了如何导入文档类文件到另外一个flash文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2的.fla文件,并将它们中的一个被称为用一DocumentMain类文件相关联,它是一个游戏。当我点击它带我到游戏的SWF文件的第一个FLA文件STAT我想是。
I have 2 .fla files and one of them is associated with a class file called DocumentMain, it is a game. and what I want is when I click "stat" on the first .fla file it takes me to the game swf file.
我的myLoad功能,它是这样的:
I did the myLoad function and it look like this :
btnstart.addEventListener(MouseEvent.CLICK,gamecontent);
function gamecontent(myevent:MouseEvent):void
{
var myLoader:Loader = new Loader ();
var myURL:URLRequest = new URLRequest("game.swf");
myLoader.load(myURL);
addChild(myLoader);
}
但我得到一个错误是:
but I get an Error which is :
类型错误:错误#1009:无法访问空对象引用的属性或方法。 在DocumentMain()
TypeError: Error #1009: Cannot access a property or method of a null object reference. at DocumentMain()
推荐答案
而不是的addChild(myLoader);
补充:
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
然后建立这个功能:
then create this function:
function onCompleteHandler(loadEvent:Event):void{
addChild(loadEvent.currentTarget.content);
}
或inisde DocumentMain添加这个()
类:
public function DocumentMain():void{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void{...
这篇关于如何导入文档类文件到另外一个flash文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文