Flash 如何调用从加载的.as脚本声明到主SWF中的函数?
我在.fla的时间线上声明了两个函数;xmlLoader1和randomNumber 现在,我需要执行这个命令:xmloader1.loadnew-URLRequesthttp://67.23.233.236/~champate/djsoftlayer/reporte/estado.php?playa=489&nocache=+randomNumber;从加载的.as脚本,但作为逻辑,编译器给了我一个错误,因为这些函数在.as上不存在Flash 如何调用从加载的.as脚本声明到主SWF中的函数?,flash,actionscript-3,Flash,Actionscript 3,我在.fla的时间线上声明了两个函数;xmlLoader1和randomNumber 现在,我需要执行这个命令:xmloader1.loadnew-URLRequesthttp://67.23.233.236/~champate/djsoftlayer/reporte/estado.php?playa=489&nocache=+randomNumber;从加载的.as脚本,但作为逻辑,编译器给了我一个错误,因为这些函数在.as上不存在 那么,我如何修改命令来告诉.as脚本谁需要在.fla上搜索这
那么,我如何修改命令来告诉.as脚本谁需要在.fla上搜索这些函数呢???谢谢 好吧,如果您将xmlLoader1声明为一个函数,它将不起作用!它应该是一个正确的加载程序类型URLLoader/loader[用于SWF或图像JPG、PNG或GIF]的变量 你的randomNumber函数应该返回一个字符串而不是一个数字
希望这有帮助。在加载第二个SWF的SWF文件中的一个类中,您可以有如下内容:
private var loader:Loader;
private var secondSWF:DisplayObject;
private function loadSecondSWF():void
{
loader = new Loader();
// You should also handle error events...
loader.loaderInfo.addEventListener(Event.COMPLETE, loader_completeHandler);
loader.load(new URLRequest('path/to/second/file.swf');
}
private function loader_completeHandler(event:Event):void
{
secondSWF = loader.content;
if (secondSWF.hasOwnProperty('xmlLoader1')
{
var xmlLoader:Loader = secondSWF[xmlLoader1];
// Call the methods you need on xmlLoader if it is not null
}
}
为了在不需要额外步骤的情况下工作,两个SWF文件必须来自同一个域
如果它们位于不同的域中,则需要将crossdomain.xml文件添加到第二个SWF文件所在域的根目录中,以授权从第一个SWF文件所在域进行访问。您还必须调用flash.system.Security.allowDomain'domain.where.first.swf.is.locate';来自第二个SWF。如果没有这些额外的步骤,您将获得安全沙盒冲突错误 在加载程序的Event.COMPLETE处理程序中,尝试访问加载程序,例如函数onCompleteevent:Event:void{MovieClipevent.target.content.xmlLoader1.loadnew URLRequest'youReq.here';}…两个swf文件应位于同一个域上,否则,您需要在加载播放器swf的服务器上安装一个crossdomain.xml,使用xmlLoader1的服务器允许加载程序swf访问加载程序内容。嗯