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!
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.