2010-03-03 140 views
1

我正在研究一個簡單的傳送帶。Flash actionscript 2.0 XML解析適用於某些節點,而不是其他節點

當我嘗試在我的工具提示子元素中將節點值作爲文本插入時,我的問題就出現了。 這裏是我的xml:

<promotions>   
     <promotion> 
      <visuel>/papyrus/8a8b8d2e26fa35b60126faf90a4d002f-20100223141718.gif</visuel> 
      <remise>55</remise> 

      <libelle>produit 1</libelle> 
      <description>contenu test 1</description> 
      <dateDebut>22/02/2010</dateDebut> 
      <dateFin>10/03/2010</dateFin> 
     </promotion> 

     <promotion> 
      <visuel>/papyrus/8a8b8d2e26fa35b60126faf9a2f30032-20100223141750.gif</visuel> 

      <remise>15</remise> 
      <libelle>Pneus</libelle> 
      <description>Promo sur les pneus</description> 
      <dateDebut>01/03/2010</dateDebut> 
      <dateFin>01/05/2010</dateFin> 
     </promotion> 


     <promotion> 
      <visuel>/papyrus/8a8b8d2e26fa35b60126fafa1fa5003a-20100223141955.gif</visuel> 
      <remise>7</remise> 
      <libelle>produit 1</libelle> 
      <description>Test promo 1</description> 
      <dateDebut>10/01/2010</dateDebut> 
      <dateFin>10/03/2010</dateFin> 
     </promotion>   
</promotions> 

而這裏的AS 2.0在那裏的假設被加載和正確的moviclip和文本插入。

xml.onLoad = function(success:Boolean) { 
    if(success) { 
     var nodes = this.firstChild.childNodes; 
     numOfItems = nodes.length; 
     for(var i=0;i<numOfItems;i++) 
     { 
      var t = home.attachMovie("item","item"+i,i+1); 
      t.angle = i * ((Math.PI*2)/numOfItems); 
      t.onEnterFrame = mover; 
      t.icon.inner.loadMovie(nodes[i].childNodes[0].firstChild);  
      t.promo= nodes[i].childNodes[1].firstChild.nodeValue; 
      t.produit= nodes[i].childNodes[2].firstChild.nodeValue; 
      t.dateDebut= nodes[i].childNodes[4].firstChild.nodeValue; 
      t.dateFin= nodes[i].childNodes[5].firstChild.nodeValue; 
      t.icon.onRollOver = over; 
      t.icon.onRollOut = out; 
     } 
} else { 
     trace("Unable to load XML"); 
    } 
} 

function over() 
{ 
    home.tooltip.promo.text = this._parent.promo; 
    home.tooltip.produit.text = this._parent.produit; 
    home.tooltip.tipDebut.text = this._parent.dateDebut; 
    home.tooltip.tipFin.text = this._parent.dateFin; 
    home.tooltip._x = this._parent._x; 
    home.tooltip._y = this._parent._y + (this._parent._height*0.15); 
    home.tooltip.onEnterFrame = Delegate.create(this,moveTip); 
    home.tooltip._alpha = 100; 
} 

結果即時具有顯示我每個GIF圖象(至極意味着我正確指向和加載childnode),文本內容裝載右(節點[libelle]和結點[描述])BUIT含節點號碼或日期不加載。 我錯在哪裏?

回答

1

我試着運行你的代碼,它有點適合我 - 儘管我只能猜測你的元素是如何在舞臺上設置的。

有些事情我也注意到:

  1. 每個.gif文件的路徑與/這並沒有爲我工作這麼好開始,但正如你所說,它的工作對你...
  2. item0,item1,item2 movieClip被添加到工具提示剪輯的前面,所以圖像可能會遮擋您的文本? (但這可能只是我舞臺設置的方式。)
  3. 這可能是一個愚蠢的問題,但是您是否爲動態文本字段嵌入了完整的字符集?這可能解釋爲什麼字母出現,但不是數字。

此外,我不知道你的moveroutmoveTip功能在做什麼(你能也許張貼呢?)。

希望這會有所幫助...

+0

不是,問題出在您的第三個建議,即嵌入特殊字符和數字,就是這樣。昨天早些時候我得到了泰特,但是,謝謝你的幫助。 所以upvote,謝謝,你說得對。 – pixelboy 2010-03-04 09:33:38