Importing exteranl SWF's onto stage

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Importing exteranl SWF's onto stage

KieranD
This post has NOT been accepted by the mailing list yet.
Hey, I am working on a museum project. I have a skybox as the museum room and clickable planes on the walls as picture frames. When I click on a picture frame I want it to load an external SWF of a Colladea DAE model. But instead what happens is I can trace out to know when the picture is clicked, but also get an error saying

 " TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at LookatModel()

LookatModel been the name of the external SWF that I am trying to load. The function of loading in an external SWF does work as I can load in simple SWF's but none which contain a DAE model.
Does anyone have a solution to this? Thanks in advance.

Kieran
Reply | Threaded
Open this post in threaded view
|

Re: Importing exteranl SWF's onto stage

KieranD
Sorted this out. common error aparntly.

public function ExternalSWF()
                {
               
                    this.addEventListener(Event.ADDED_TO_STAGE, onStage);
                }
               
                private function onStage(e:Event):void
                {
                    this.removeEventListener(Event.ADDED_TO_STAGE, onStage);
       
                }

Hope this helps others.

Kieran
Reply | Threaded
Open this post in threaded view
|

Re: Importing exteranl SWF's onto stage

KieranD
Now All I have to do is unload the swf. Anyone have any ideas?
Thanks

Kieran
Reply | Threaded
Open this post in threaded view
|

Re: Importing exteranl SWF's onto stage

KieranD
Got this sorted this too!

Put this in your external file:

private function exit(event:MouseEvent):void
                {
                        dispatchEvent(new Event("UnloadMe", true));
               
                }


And this in your Main:

private function clickme (e:InteractiveScene3DEvent):void
                {
                        var loader:Loader = new Loader();
                        var urlRequest:URLRequest;
                         
                        urlRequest = new URLRequest("external.swf");
                        loader.load (urlRequest);
                        addChild(loader);
                       
                        //shoe unloader part 2 0f 2 (exit external swf)
                        loader.addEventListener("UnloadMe", unloadFunction)
                       
                }
               
                private function unloadFunction(event:Event):void
                {
                        Loader(event.currentTarget).unload();
                }

Hope this helps others. As a guy that's just getting the hand of as3, I know what its like looking for help!

Kieran