View Full Version : Easier than I think i know - SWF External Loading
raven3k
February 26th, 2009, 04:00 PM
ok here's my code
myButton.addEventListener(MouseEvent.CLICK, loadmovie);
function loadmovie(evt:MouseEvent):void {
myButton.visible = false;
this.load(new URLRequest("wall_example6.swf") );
}
What i want to do is in this sequence:
Click button > Load Movie and Close the Movie which had the button
I know i am close, but i have been searching and searching and i guess this is my last hope before i delete it all and give up!!
akiersky
February 26th, 2009, 04:32 PM
if you want to load the new movie in the same window, use the navigateToURL method and pass your URLRequest to that:
myReq = new URLRequest("wall_example6.swf")
navigateToURL(myReq, "_self")
the "_self" will open it in the window you are currently in, alternately use "_blank" to open in a new window
raven3k
February 26th, 2009, 04:56 PM
if you want to load the new movie in the same window, use the navigateToURL method and pass your URLRequest to that:
myReq = new URLRequest("wall_example6.swf")
navigateToURL(myReq, "_self")
the "_self" will open it in the window you are currently in, alternately use "_blank" to open in a new window
thanks for the quick reply, but, i was more thinking in terms of the adobe flash player ie not loading in the browser.
MurtenSaerbi
February 26th, 2009, 05:16 PM
If you want to load a swf file you need the Loader class like you already use but attach your content (in a holder clip, for instance):
// load the flash file
contentLoader = new Loader();
var contentRequest:URLRequest = new URLRequest("flash_file_name.swf");
contentLoader.contentLoaderInfo.addEventListener(E vent.COMPLETE, completeHandler);
contentLoader.load(contentRequest);
You will also need a function that handles the complete event. In my case "completeHandler":
private function completeHandler(e:Event):void {
// this loads your swf in a movieclip on stage (named holder_mc) at place 0
holder_mc.addChildAt(contentLoader.contentLoaderIn fo.content, 0);
// an example of how to adress a function (called "init" in my case) inside the loaded .swf
Object(holder_mc.getChildAt(0)).init();
}
I hope you can do something with this information, if not: don't hesitate to ask/clarify a bit more.
raven3k
February 26th, 2009, 07:50 PM
If you want to load a swf file you need the Loader class like you already use but attach your content (in a holder clip, for instance):
// load the flash file
contentLoader = new Loader();
var contentRequest:URLRequest = new URLRequest("flash_file_name.swf");
contentLoader.contentLoaderInfo.addEventListener(E vent.COMPLETE, completeHandler);
contentLoader.load(contentRequest);
You will also need a function that handles the complete event. In my case "completeHandler":
private function completeHandler(e:Event):void {
// this loads your swf in a movieclip on stage (named holder_mc) at place 0
holder_mc.addChildAt(contentLoader.contentLoaderIn fo.content, 0);
// an example of how to adress a function (called "init" in my case) inside the loaded .swf
Object(holder_mc.getChildAt(0)).init();
}
I hope you can do something with this information, if not: don't hesitate to ask/clarify a bit more.
thanx for the reply again, any chance of a example fla so i get a good clue what the hell is going on. Otherwise, i am happy to see and try and understand what you are saying.
Its been a big jump for me since i used use macromedia flash 5 long time ago and havent really touched action scripting since now!
MurtenSaerbi
February 26th, 2009, 07:57 PM
I could make you an example but I believe that Lee Brimelow already beat me to the punch.
He wrote a video tutorial about this loading type called "the cleanest method to load swf's" or something like that and it can be found over here: http://gotoandlearn.com/play?id=85 . It's a video tutorial and you can also download the example files at the top right.
raven3k
February 26th, 2009, 08:19 PM
I could make you an example but I believe that Lee Brimelow already beat me to the punch.
He wrote a video tutorial about this loading type called "the cleanest method to load swf's" or something like that and it can be found over here: http://gotoandlearn.com/play?id=85 . It's a video tutorial and you can also download the example files at the top right.
thanks, but how do i put this into like a button click?
I remember it used something like on release or something and load movie, somewhere along those lines on top of my head?
MurtenSaerbi
February 26th, 2009, 08:49 PM
It's very different now, you might want to look in to some actionscript 3 a bit more. Everything is done with listeners now. Say your button is called "button_btn":
button_btn.addEventListener(MouseEvent.CLICK, clickHandler);
button_btn.buttonMode = true;
The buttonMode turns the mouse into a handcursor. The listener "listens" to a CLICK event on the button and runs the function "clickHandler" once a click happens. The clickHandler should be defined as this:
private function clickHandler(e:Event):void {
// put the load here
}
raven3k
February 26th, 2009, 09:07 PM
It's very different now, you might want to look in to some actionscript 3 a bit more. Everything is done with listeners now. Say your button is called "button_btn":
button_btn.addEventListener(MouseEvent.CLICK, clickHandler);
button_btn.buttonMode = true;
The buttonMode turns the mouse into a handcursor. The listener "listens" to a CLICK event on the button and runs the function "clickHandler" once a click happens. The clickHandler should be defined as this:
private function clickHandler(e:Event):void {
// put the load here
}
i guess great minds think alike, was just watching this vid:
http://www.tutvid.com/tutorials/flash/tutorials/as3AndButtons.php
but i am kind of getting the jist but will post something soon.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.