Does the code I’ve written to automatically generate URLs work?
I am creating a duel-language website and I am trying to create flash buttons which switch between the Korean and English pages.
The Korean pages all end with “_kr.html”
The English pages end with “_en.html”
Below is the code I’ve come up with. Can you tell me if it will work? And, if not, how would you recommend I fix it?
import flash.external.*;
var currentUrl:String = String( ExternalInterface.call(" function(){ return document.location.href.toString();}"));
//function uses java script to get current url from browser
var englishUrl:String = currentUrl;
var englishReplace:RegExp = /_kr/gi;
trace(englishUrl.replace(englishReplace, "_en"));
//replaces "kr" in current url with "en"
var koreanUrl:String = currentUrl;
var koreanReplace:RegExp = /_en/gi;
trance(koreanUrl.replace(koreanReplace, "_kr"));
//replaces "en" in current url with "kr"
engSwitch.addEventListener(MouseEvent.MOUSE_DOWN, mouseEngHandler);
function mouseEngHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(englishUrl));
}
//navigates to English version of current page
koreanSwitch.addEventListener(MouseEvent.MOUSE_DOWN, mouseKoreanHandler);
function mouseKoreanHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(koreanUrl));
}
//navigates to Korean version of current page
I am totally new to ActionScript 3.0 and this is basically a cut-and-past job from posts from three different sources: Flashthusiast.com, [URL=“http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000076.html”]AdobeLiveDocs, and [URL=“http://www.actionscript.org/forums/showthread.php3?t=150218”]ActionScript.org. I would greatly appreciate any help you can provide a struggling novice.
Thank you in advance.