2012-01-12 28 views
0

我從這個樣子的服務器得到的字符串:格式鏈接到瀏覽器中打開它在Flex移動項目

This is normal text followed by a link; 
http://www.google.com 
Links might also look like this; 
http://google.com/whatever 

這個字符串被設置爲在火花文本區域的文本值。我想要實現的是 A.文本被突出顯示,並且 B.用戶可以點擊它並在系統瀏覽器中打開。

任何幫助將不勝感激!

編輯:使用StyleableTextField在Flex 4.6上引發typerror。 我嘗試了這樣最簡單的HTML文本;

StyleableTextField(newsStoryArea.textDisplay).htmlText = "TextArea <b>bold</b><i>italic</i>." 

哪扔;

TypeError: Error #1034: Type Coercion failed: cannot convert 
spark.components.supportClasses::[email protected] to 
spark.components.supportClasses.StyleableTextField. 

編輯: 不錯的一個Adobe! 「htmlText in mobile skins

您不能在移動應用程序中使用htmlText屬性。」

在同一頁上(http://help.adobe.com/en_US/flex/mobileapps/WS19f279b149e7481c698e85712b3011fe73-7fff.html#WS19f279b149e7481c7c94ce7c12b30152f48-7ffc),他們說不要在移動皮膚使用TLF,所以沒有按的htmlText」 t工作,不應使用TLF。 基本上只有兩個選項(除非有第三個選項我不知道)才能正確格式化鏈接,不能在移動設備上使用。大!

有什麼建議嗎?

+0

你的意思是你想產生'thetext'或類似的東西? – fge 2012-01-12 09:38:26

+0

這將是第一步,我將使用正則表達式來解決這個問題。然而,爲移動設備開發我是最快的解決方案。第二步是在設備的瀏覽器中打開這些鏈接,我不確定它是否會在TextArea中自動支持。 – AlBirdie 2012-01-12 09:43:17

+0

我知道你可以使用StyleableTextField添加一個支持鏈接的eventListener,但是在Flex 4.6中似乎存在一個bug,因爲從textArea到StyleableTextField的強制轉換不起作用。 – AlBirdie 2012-01-12 09:46:14

回答

1

如果拋出

TypeError: Error #1034: Type Coercion failed: cannot convert 
spark.components.supportClasses::[email protected] to 
spark.components.supportClasses.StyleableTextField. 

那麼你的組件使用默認其使用StyleableStageText皮膚。它不支持htmlText屬性。

根據組件的名稱「newsStoryArea」,我可以假設這是spark.components.TextArea。 spark.components.TextArea有兩個移動皮膚 - 默認(我不記得它的全名)和spark.skins.mobile.TextAreaSkin。類spark.skins.mobile.TextAreaSkin使用具有htmlText屬性的StyleableTextField。所以你可以指定你的文本區域組件使用這個皮膚。結果你可以使用htmlText。

此外,如果textDisplay將不可選,那麼textDisplay將不會調用TextEvent.LINK(如果需要的話)。

1

您可以使用TextFlow

textArea.textFlow = TextConverter.importToFlow("<a href='http://www.google.com'>This is normal text followed by a link;<br/>http://www.google.com</a>", TextConverter.TEXT_FIELD_HTML_FORMAT); 
+0

乾杯隊友,不幸的是我不能從這個函數中得到任何東西,但是一個空字符串。我使用Flex 4.6 btw。 – AlBirdie 2012-01-12 09:29:43

相關問題