2011-03-11 13 views
0

我不是Flash開發人員,但我正在調試複製/文本分配不正確的問題。爲什麼我的主要內容區域文本沒有更新?我的參考書是否錯誤?

.as文件中,標題和副標題分配和工作:

195       body.heading.htmlText = heading; 
196       body.sectionheading.htmlText = nav_name; 
197       body.subheading.htmlText = subheading; 
198       body.subheading.htmlText = 'testtt'; 

然而,主體副本不:

180       body.textholder.myText.htmlText = 'mederTest'; 

有沒有一些方法,我可以找出所有文本區域(任何具有可分配的htmlText)編程?在Flash本身,我似乎無法自己選擇標題/子標題對象,因爲它們看起來不在畫布中?他們顯得隱藏起來




編輯:我正在調試24瑞士法郎。我終於找到需要更新的實際文本。

428     var bodyClip:MovieClip = eval("bodyparts.bodycontent_"+tmpclipname.id+"_0"); 
429     ExternalInterface.call("console.log" , bodyClip) 
430     for (var p in bodyClip) { 
431      ExternalInterface.call("console.log" , p) 
432      ExternalInterface.call("console.log" , bodyClip[p]) 
433      ExternalInterface.call("console.log" , bodyClip[p]) 
434      for (var thing in bodyClip[p]) { 
435       if (thing === 'htmlText') { 
436        ExternalInterface.call("console.log" , 'OMG'); 
437        ExternalInterface.call("console.log" , bodyClip[p][thing]) 
438       } 
439       
440       if (thing === 'myText') { 
441        ExternalInterface.call("console.log" , 'SUPEROMG'); 
442        ExternalInterface.call("console.log" , bodyClip[p][thing]['htmlText']) 
443       } 
444       ExternalInterface.call("console.log" , thing) 
445      } 
446     } 

它能夠深入而當bodyClip有一個「會將myText」屬性的情況下,這就是我想要更新的東西。

這條線爲什麼不更新它?

body.textholder.myText.htmlText = 'mederTest'; 

從程序上講,它可能只是因爲我可能引用了錯誤的對象/實例,不是嗎? .as文件不包含對body的引用。

我只能假定它是在第一個.as文件或其全局對象中定義的。任何人都可以借我一隻手嗎?

回答

1

您可以步行顯示列表,尋找TextField類型的對象:

function findTextFields(container:DisplayObjectContainer):Array 
{ 
    var result:Array = []; 

    // Examine each child of the container 
    for(var i:int = 0; i < container.numChildren; i++) 
    { 
     var obj:DisplayObject = container.getChildAt(i); 

     // If the child is a TextField, add it to the result array 
     if(obj is TextField) 
      result.push(obj); 

     // If the child is a DisplayObjectContainer, recurse on it 
     var c:DisplayObjectContainer = obj as DisplayObjectContainer; 
     if(c !== null) 
      result.concat(findTextFields(c)); 
    } 
    return result; 
} 
+0

順便說一句,這是我相信的Actionscript 2。我更新了我的問題,因爲我發現我需要在以前的'.as'中更新,除非我需要從第二個'.as'更新它。幫助我的頭腦? – 2011-03-11 04:10:10

+0

啊,你說得對,那是AS2。對不起,我真的不知道有關AS2的任何信息,它看起來像你的問題是非常特定的(你在編輯中發佈的代碼在AS3中是沒有意義的)。希望有一些AS2大師可以幫助。 – Aaron 2011-03-11 04:30:13

0

除了TextField的,這裏還有靜態文本是如果我們把一個正常的文本字段向下閃存,並且被導出的對象它不是動態的。

您正在尋找的文本字段可能是這種類型,在這種情況下,您將無法設置文本。

儘管如此,如果您不能重新編輯此TextField並使其動態化,那麼一個解決方案就是動態創建一個新的TextField。複製舊的寬度,高度,字體,顏色等。將背景屬性設置爲true,或將舊的TextField的可見屬性設置爲false。現在,將您的新TextField添加爲舊TextField的父級的子級,並在其上方。編輯文本,你可以:D

0

你是否試圖修改你的if語句中的文本,當你發現它?或者別的地方?

if (thing === 'myText') { 
    bodyClip[p][thing]['htmlText'] = "mederTest" 
} 

..因爲當您試圖修改它時可能TextField不存在。如果播放頭不在包含TextField的幀上,則TextField不存在。

另一個建議是更改Textfield的_alpha以確保您正在使用正確的Textfield?

相關問題