read the xml by relative path to flash
CMS 網站的flash 總會要求可以edited by cms
所以寫flash時都要support load 一d xml
但是flash 在 local 行同在 server 又是兩回事
因為flash 個path 係根據個webpage 的path
所以在寫as 時就要加返d 心思
function getAbsoluteUrl(urlInput) {
var strResult = "";
if(urlInput.indexOf("http://") > -1) //only convert when online
{
if(urlInput.indexOf(".swf") > -1) // only convert when an actual .swf file is used
{
strResult = urlInput.substring(0, urlInput.lastIndexOf("/")+1); // find absolut path minus filename of .swf
}
}
return strResult;
}
// load xml
images_xml = new XML();
images_xml.ignoreWhite=true;
images_xml.load(getAbsoluteUrl(_root._url) + "images.xml");
Labels: Action Script, Flash

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home