EZFLAR/网络摄像头的 unloadAndStop 问题

发布于 2024-11-04 09:35:34 字数 1002 浏览 0 评论 0原文

我正在使用 EZFLAR 和 Flash 制作一本书/杂志,但我需要很多标记(并且它们越多,FLARToolkit 就无法区分它们),所以现在我正在尝试一种不同的方法:只需三个标记和然后,加载不同的 SWF,为每个标记触发不同的操作。

为此,我制作了一个 loader.swf,它将负责根据用户单击的内容加载任何特定的 swf。我从第一个按钮开始,它加载得很好,只是有两个问题。

第一个问题,但不是那么重要,是我似乎无法在网络摄像头流上添加任何内容,甚至无法将其放在 EZLFAR.fla 上,网络摄像头总是覆盖所有内容。然后,我决定添加一点边距,以便放置 UI(可能是后退按钮或其他 swf 加载器)。

第二个问题发生了,我无法让 unload() 或 unloadAndStop() 工作。我在函数内部放置了一条跟踪,以查看它是否在单击时进入,并且确实如此,但它只是不卸载网络摄像头 swf。另外,如果我将侦听器添加到网络摄像头 swf,它不会检测到对其的点击。

这是我的代码:

import flash.display.Loader
import flash.net.URLRequest
import flash.events.Event

var myLoader:Loader = new Loader(); 

rptr.addEventListener (MouseEvent.CLICK, raptorLoad);

function raptorLoad (e:MouseEvent):void 
{
    var url:URLRequest = new URLRequest("rptr.swf"); 
    myLoader.load(url); 
    addChild(myLoader);
}

myLoader.addEventListener(MouseEvent.CLICK, unLoad);

function unLoad (event:MouseEvent):void 
{
    trace("click!");
    myLoader.unloadAndStop();
}

非常感谢任何帮助,谢谢!

I'm making a book/magazine with EZFLAR and Flash, but I was going to need a lot of markers (and they become indistinguishable by FLARToolkit the more they are), so now I'm trying a different approach: just three markers and then, load a different SWF that triggers different actions for each marker.

To do so, I made a loader.swf that will be in charge of loading any of the specific swf depending on what the user clicks. I started with my first button and it loads fine, just it has two problems.

First problem, and not so important, is that I can't seem to add anything over the webcam stream, not even placing it on the EZLFAR.fla, the webcam always covers everything. I decided, then, to add a little margin where I can place a UI (maybe a back button or the other swf loaders).

Second problem happened, I can't get either unload() nor unloadAndStop() working. I've put a trace inside the function to see if it enters on click, and it does, but it just doesn't unload the webcam swf. Also, if I add the listener to the webcam swf it doesn't detect clicks on it.

This is my code:

import flash.display.Loader
import flash.net.URLRequest
import flash.events.Event

var myLoader:Loader = new Loader(); 

rptr.addEventListener (MouseEvent.CLICK, raptorLoad);

function raptorLoad (e:MouseEvent):void 
{
    var url:URLRequest = new URLRequest("rptr.swf"); 
    myLoader.load(url); 
    addChild(myLoader);
}

myLoader.addEventListener(MouseEvent.CLICK, unLoad);

function unLoad (event:MouseEvent):void 
{
    trace("click!");
    myLoader.unloadAndStop();
}

Any help is greatly appreciated, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

○愚か者の日 2024-11-11 09:35:34

Loader.unload() 不会销毁加载的内容,它只是将其从 Loader 实例的显示列表中删除。您需要手动销毁内容。查看Loader.unload 文档 了解更多信息。

您在相机上方加载内容的另一个问题......没有看到更多的代码,很难判断问题可能是什么。我建议也许向您的加载器添加一个事件侦听器。等到加载完成后再添加。

Loader.unload() doesn't destroy the loaded content, it just removes it from the Loader instance's display list. You'll need to destroy the content manually. Check out the Loader.unload documentation for more info.

Your other issue of loading content above the camera...without seeing more of that code, it's hard to tell what the issue might be. I would suggest maybe adding an event listener to your loader. Wait until the load is complete before adding it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文