2009-07-03 52 views
0

好吧我不使用actionscript,並試圖幫助我的朋友編輯一個flash網站,其中的layout從現在defun的weatherroom.com的xml提要改變,開發這個網站也離開了我的朋友(他的客戶)。這是當前代碼波紋管,反正是有,我可以簡單地換了臺服務,而不必僱傭一個人做的動作都overagainWeatherRoom服務下來需要一個網站的替代

updateWeatherData() { 
//record old settings 
var oldCondition = _root.currentCondition; 
var oldWeather = _root.currentWeather; 
var oldTimeset = _root.currentTimeset; 
//get new settings 
var newTimeObj = _root.getCurNYTime(); 
_root.currentTimeset = newTimeObj.timeSet /*'night'*/; 
var myURL:String = 'http://www.weatherroom.com/xml/zip/12545'; 
var myXMLweatherData:XML = new XML(); 
myXMLweatherData.load(myURL); 
myXMLweatherData.onLoad = function(success) { 
    if (success) { 
     _root.XMLWeatherFeed = this; 
     //extract current condition (string) 
     _root.currentCondition = _root.getCurrentCondition(_root.XMLWeatherFeed); 
     //get current weather number 
     _root.currentWeather = _root.getCurrentWeather(_root.currentCondition) /*2*/; 
     //display 
     _root.displayAllWeatherInfo(_root.XMLWeatherFeed); 
     if (_root.initWeatherDone == true) { 
      //compare if weather has changed 
      if (oldCondition != _root.currentCondition or oldWeather != _root.currentWeather or oldTimeset != _root.currentTimeset) { 
       if (_root.currentCondition != undefined and _root.currentWeather != undefined and _root.currentTimeset != undefined) { 
        console.text += ('-> ' + oldCondition + ' :: ' + _root.currentCondition + '\n'); 
        console.text += ('-> ' + oldWeather + ' :: ' + _root.currentWeather + '\n'); 
        console.text += ('-> ' + oldTimeset + ' :: ' + _root.currentTimeset + '\n'); 
        //if it has, launch weather update 
        _root.updateWeatherBackground(); 
       } else { 
        console.text += ('--! weather server returned uncomplete data !--'); 
        //restore data 
        _root.currentCondition = oldCondition; 
        _root.currentWeather = oldWeather; 
        _root.currentTimeset = oldTimeset; 
       } 
      } else { 
       console.text += ('--! no necessary update !--'); 
      } 
     } else { 
      //tell app init has been done 
      _root.initWeatherDone = true; 
     } 
    } else { 
     //-- server is down 
     //-- return partly cloudy no rain 
     trace('*** SERVER IS DOWN ***'); 
     _root.currentWeather = 3; 
     _root.initWeatherDone = true; 
    } 
} 

}

回答

1

你可能會需要對僱用別人。我之所以這樣說,是因爲你使用的任何其他服務都必須具有與你的代碼完全相同的XML佈局才能「插入」它。例如,_root.getCurrentCondition()可能是一種在XML內查找特定節點並以特定格式返回值的方法。除非屬性和文本完全相同(名稱,模式等),否則它不會起作用。

祝你好運。