使用AS3/Flash CS4运行时加载的swf中的调用函数
好的感谢所有阅读此内容的人。我的问题具体是我正在设计一个带有控件的用户界面。 5个按钮向左旋转,向右旋转,放大,缩小和自动旋转。界面本身工作正常,我可以跟踪按钮点击,切换自动旋转按钮等...
我的程序读取一个XML文件。加载一些图像,为每个图像填充一个包含链接的数组,并在点击图像时,加载程序从URL加载swf并将其显示在屏幕上。没问题。
现在我原来在runtime_loaded.fla库中有缩放控件用户界面,鼠标侦听器在同一个链接文档类中。当它在相同的代码中时,该接口与runtime_loaded.swf中的movieClip协同工作。
现在为了实践良好的编码,我决定从runtime_loaded.fla中删除UI并将其添加到Main.fla中。这是非常重要的,因为主要处理可能的100个图像/对象,每个图像/对象都有自己独特的swf链接。如果我决定改变界面的外观,但让函数调用保持不变,我可以根据自己的需要添加尽可能多的main.fla来代替runtime_loaded.fla,这对于每一个对象都是必须的。
文件结构
Main.fla <- interface in the library. 5 mouse event functions. Inside each function calls
a property of loaded_swf (loaded_swf.rotateLeft, loaded_swf.rotateRight) etc...
Runtime_loaded.fla <- links specificObject.as in properties (AS3/CS4)
specificObject.as <- has 5 public static functions{ rotateRight, rotateLeft, zoomIn, zoomOut, toggleAutoRotate }
守则
//showFlashBox
function showFlashBox(temp_string:String):void {
if(!flash_box_on){
var temp_top:uint = numChildren;
addChildAt(FlashBoxContainer,temp_top);
newXButton.addEventListener(MouseEvent.CLICK, flashBoxXClick);
1. addChild(new_loader);
2. var url:URLRequest = new URLRequest(temp_string);
new_loader.x = 0;
new_loader.y = 0;
new_loader.load(url);
3. new_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, gotSwf);
flash_box_on = true;
}
}
function gotSwf(e:Event){
4. //loaded_swf = e.target.content;
trace(e.target.content);
5. new_zoom_controls.button_minus.addEventListener(MouseEvent.CLICK, zoomOutFunction);
new_zoom_controls.button_plus.addEventListener(MouseEvent.CLICK, zoomInFunction);
new_zoom_controls.button_left.addEventListener(MouseEvent.CLICK, rotateLeftFunction);
new_zoom_controls.button_right.addEventListener(MouseEvent.CLICK, rotateRightFunction);
new_zoom_controls.button_rotate.addEventListener(MouseEvent.CLICK, toggleRotateFunction);
function rotateRightFunction(e:MouseEvent){
6. //loaded_swf.rotateRight();
}
function rotateLeftFunction(e:MouseEvent){
//loaded_swf.rotateLeft();
}
function zoomInFunction(e:MouseEvent){
//loaded_swf.zoomIn();
}
function zoomOutFunction(e:MouseEvent){
//loaded_swf.zoomOut();
}
function toggleRotateFunction(e:MouseEvent){
//loaded_swf.toggleAutoRotate();
if(new_zoom_controls.button_rotate.currentFrame == 1){
new_zoom_controls.button_rotate.gotoAndStop(2);
}
else new_zoom_controls.button_rotate.gotoAndStop(1);
}
new_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, gotSwf);
}
如果按照步骤1-6你看我加载瑞士法郎,鼠标事件侦听器的步骤,然后单击处理程序,然后调用var loaded_swf:Object;
public static function rotateLeft():void
{
object.yaw(animation_turning_speed);
}
public static function rotateRight():void
{
object.yaw(-animation_turning_speed);
}
如果我运行main.fla并尝试单击按钮。有时候是这样的。
ReferenceError: Error #1069: Property rotateRight not found on ThreedsKU39web and there is no default value. at MethodInfo-82() ReferenceError: Error #1069: Property rotateLeft not found on ThreedsKU39web and there is no default value. at MethodInfo-83()