Follow @BPSPro

Linking Multiple Websites In A Flash Movie | AS3 Flash Code to Create URL Links

6 Comments RSS Site Feed Author: AITpro Admin
Published: June 28, 2010
Updated: September 29, 2010

The original question was regarding how to link multiple websites (domains and subdomains) from a single Flash movie.  The question was not completely clear so the answer includes general and specific information about website domains and subdomains and the specific AS3 Flash code you would use to create website URL links in Flash.

I think what you are saying is that you have a website domain that has a .swf (Shockwave Flash Movie) either embedded in your website or you have a Full Flash website, meaning the entire website is a SWF. Not 100% sure from your question. In any case it appears you have one current website domain and you want to know how to create some subdomains and link them from the main Flash movie.

5 Individual website domains explanation

If you want 5 individual websites you would of course buy the domain names, setup the folders for each individual website domain from your web hosting account and then add the necessary website files for each individual website domain. To simplify this explanation let’s just say you already own domain0.com and you want to add domain1.com and domain 2.com. In your web host you should see your root directory for domain0. Now to add new website domains to your domain0.com web hosting account you just create folders for example called domain1.com and domain2.com and put the necessary individual website files in each folder for each individual website domain. For simplicity sake let’s say you just add 1 page = index.htm to each individual website domain. So when someone types in www.domain1.com the index.htm file will load / open for that domain.

5 website subdomains explanation

A subdomain is exactly what it sounds like. A sub domain (just a folder) off of the root website domain. In your scenario using domain0.com as the example. A subdomain example would be sub1.domain0.com or domain0.com/sub1. These are both considered subdomains. The only difference is in your root website domain you would either have a folder named sub1.domain0.com or just sub1 directly off of your root website domain.

Since you said the Flash website is only one file I am assuming that you have an SWF that you want to add links to the other websites or maybe actually just 5 web pages. I’m going to assume that you have the actual Flash program with an .fla file so that you can create an SWF file from the .fla Flash file and not just have an SWF that has already been created from a Flash .fla file.

This is the AS3 Flash code you would use to create URL links:

function gotoquoteform(event:MouseEvent):void {
var targetURL:URLRequest = new URLRequest("http://www.ait-pro.com/flash-mss-movie/");
navigateToURL(targetURL, "_self");
}
clickMeBTN.addEventListener(MouseEvent.CLICK, gotoquoteform);

Old school method:  You need to create a button in your Flash movie and then within the button Timeline frame you would add the Actionscript code (AS3 code) above to add your URL link.  For multiple links you would just duplicate the AS3 code for each individual button and URL that you wanted to add to the Flash movie.

New school method:  Use Sprites and Loader to create the button dynamically.

Good luck!

Question was asked again with additional infomation:

I answered your other question that was very similar to this one regarding linking 5 different flash websites together. The way you phrased this question now makes me think that you are trying to create something like a footer link for these 5 Flash websites so that they will all be linked back to your main website. Something like a Website Design by…. link back to your website???

This is the AS3 code for CS4 that you use to create links from a Flash button or any symbol (a symbol in Flash is just the name for a graphic that Flash recognizes and can be further customized into a Flash Movie Clip) within Flash. The AS3 code would go in the Actions Frame (you just open the Actions panel and add the code into that frame, which then creates an Actions Frame) of the beginning frame of whatever symbol, text or button within your Flash movie.

function gotoquoteform(event:MouseEvent):void {
var targetURL:URLRequest = new URLRequest("http://www.ait-pro.com/flash-mss-movie/");
navigateToURL(targetURL, "_self");
}
clickMeBTN.addEventListener(MouseEvent.CLICK, gotoquoteform);

On importing a PSD or other jpg, gifs, pngs, etc etc from Photoshop to the Flash library of your particular Flash movie you have probably already noticed that only the images are imported and no link code. That is because the linking code used in Photoshop is HTML. Flash uses AS3 so the link code is totally useless and is stripped out in the import. And you probably already know this, but for anyone who doesn’t when you import graphics into Flash they are limited bitmap graphic files. When you convert those imported graphics into Flash Symbols they then become graphic files that are in essence converted to a format Flash can “work” with in more advanced ways. A graphic within Flash must be a Symbol before it can me made into a Movie Clip. This is in laymans terms, but it shows the basic steps of how to work with imported graphic files within Flash.

So anyway the hard part for you would be figuring out the code I have added above. The rest of the Flash steps you may need to figure out are simple and you should have no problem searching for Flash tutorials for each step that you may need to figure out.

Good luck!

Skip to toolbar