The swf file will be stored in my folder with my main site files - not on the internet.
??? I assume you are only working offline, locally. If you were to go online, your SWFs would have to be on your server along with your main SWF, preferably in the same folder/location. The Loader() class and the UILoader Component can be used to load JPG, GIF, PNG images and SWF files. Data and text files use URLLoader() class. (1) create instance of Loader() class; (2) create instance of URLRequest() class (with path to file); (3) use loader instance load method to load URLRequest path to file; (4) addChild() to display list.
The named button instances trigger and are the target of .addEventListener(Event.TYPE, function); The argument of that specified function(evt:Event) references kind of event used as argument in Listener.
The following is not my code. I snitched it from a professor's cache. See screen shot. The opening file background is target_mc. The frame labels are prefixed with $; the buttons have same name without $ prefix. Then function loadWeb(evt:MouseEvent) concatenates string ("$" + evt.currentTarget.name); target of event (button name) -- to create full frame label.
Code:
Actions for Frame 1
var myURL:URLRequest = new URLRequest("swfs/intro.swf");
var myLoader:Loader = new Loader();
myLoader.load(myURL);
target_mc.addChild(myLoader);
Actions for Frame 2
stop();
home_btn.addEventListener(MouseEvent.CLICK, goHome);
function goHome(evt:MouseEvent):void
{
gotoAndStop("$home");
myURL = new URLRequest("swfs/intro.swf");
myLoader.load(myURL);
}
web_btn.addEventListener(MouseEvent.CLICK, goWeb);
function goWeb(evt:MouseEvent):void
{
gotoAndStop("$w1");
myURL = new URLRequest("swfs/w1.swf");
myLoader.load(myURL);
}
print_btn.addEventListener(MouseEvent.CLICK, goPrint);
function goPrint(evt:MouseEvent):void
{
gotoAndStop("$p1");
myURL = new URLRequest("swfs/p1.swf");
myLoader.load(myURL);
}
Actions for Frame 5
w1.addEventListener(MouseEvent.CLICK, loadWeb);
w2.addEventListener(MouseEvent.CLICK, loadWeb);
w3.addEventListener(MouseEvent.CLICK, loadWeb);
function loadWeb(evt:MouseEvent):void
{
gotoAndStop("$" + evt.currentTarget.name);
myURL = new URLRequest("swfs/" + evt.currentTarget.name + ".swf");
myLoader.load(myURL);
}
Actions for Frame 20
p1.addEventListener(MouseEvent.CLICK, loadPrint);
p2.addEventListener(MouseEvent.CLICK, loadPrint);
function loadPrint(evt:MouseEvent):void
{
gotoAndStop("$" + evt.currentTarget.name);
myURL = new URLRequest("swfs/" + evt.currentTarget.name+".swf");
myLoader.load(myURL);
}
Assets/Buttons
painting, ‹web_btn›
home, ‹home_btn›
design, ‹print_btn›
1, ‹w1›
2, ‹w2›
3, ‹w3›
1, ‹p1›
2, ‹p2›
inv, ‹target_mc>
Bookmarks