2007
03.26


Flex2裡面如果要去使用一些進階的功能,尤其是Flash Data Service的功能,那一定逃不了去設定 services-config.xml這類的檔案,而 service-config.xml 是全部設定檔的起頭,不會搞這個,那別說什麼 Proxy Services, Message Service, Remoting Service 那都是白搭的,當然在 service-config.xml 檔中有這許多的類似 {context.root}這樣的東西,我承認我也曾經被這個東西卡過幾個小時,那是因為我要啟用一段自己設定的 services,結果在 Flex Complier 加上參數以後就死給我看,所以解決之後把這段寫下來,或許也有人發生同樣的問題,那就別再卡啦。

flex builder

舉個例子,如果要在 Flex2 中使用 Flash Remoting 那個就必須用到這段設定:
 <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
    <endpoint uri="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
  class="flex.messaging.endpoints.AMFEndpoint"/>
    <properties>
        <polling-enabled>false</polling-enabled>
    </properties>
 </channel-definition>

相信其中的 {server.name} 和 {server.port} 應該都不難理解,不過 {context.root} 又是什麼,context.root 指的就是服務的主目錄,好,結果今天程式開發到一半,自己加了一些項目以後,居然出現了這段 problem 的訊息:

Severity Description Resource In Folder Location Creation Time Id
2 The services configuration includes a channel-definition ‘my-amf’ that has an endpoint with a context.root token but a context root has not been defined. Please specify a context-root compiler argument. phpRemoting   2007年3月15日 下午 06:18:10 283

這是啥鬼東西,我又沒有用 my-amf 這個 channel ,從錯誤訊息來看是 context.root 未被定義,好吧,如果未定義,那就乾脆把所有的 {context.root} 改成根目錄算了,例如改成 flex (我知道你可能會絕得我再開玩笑,沒有,我是認真的),的確如果你把所有的 {context.root} 都改掉,就可以正常的運作,也不會有錯誤訊息,不過這樣實在讓我覺得勝之不武,好,那怎麼辦,乖乖回到 Flex Bulider 中看看有沒有什麼可以用的吧。果然,其實在 Flex Builder 中,只要在專案上選擇 [properties > flex server] 就可以設定 context.root如下圖,所以其實從這邊設定就好了

flex server 但是問題又來了,如果您當初在開 Flex 專案時,若是沒有選擇用 Flex Data Service 來配合開發,那麼 flex server 的選項是不會出來的,如下圖:

flex server

讚啊,讓我看到差點沒昏倒,好,這樣也不行,那換條路走好了,不過今天時間有限,下次再繼續補完。 待續…


相關文章:
  • Facebook 的ActionScript API 更新到 3.3版
  • 用ActionScript讀取相片中的exif資訊
  • 現場直擊Flash/Flex特效瘋-8/26活動內容預告
  • Bitmap與BitmapData
  • Flex/Flash/AIR 如何開啟bmp圖檔
  • 本文引用:
    文章內容由宋志峰[ANISTAR]撰寫,引用分享請以鏈結形式註明出處與原始作者。

    No Comment.

    Add Your Comment