This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks
          試了半天沒出來原來是flex的bug,汗啊!
          Steps?to?reproduce:
          1.?Create?an?application?which?loads?a?module.
          2.?Pass?url-encoded?variables?along?the?query?string?while?loading?the?module.?For?example:
          [code]
          <mx:ModuleLoader?url="modules/modules/Module2.swf?name=jerry&amp;flavor=chunky%20monkey"?/>
          [
          /code]

          3.?Try?and?get?the?"name"?and?"flavor"?parameters?from?the?loaded?module.


          Actual?Results:
          From?within?the?module,?the?
          "this.loaderInfo.parameters"?object?is?empty,?even?though?you?passed?values?along?the?query?string.?you?can?get?the?values,?but?it?involves?a?weird?mix?of?RegEx?class,?URLUtil?or?URLVariables?classe,?or?writing?all?your?own?parsing?logic.


          Expected?Results:
          this.loaderInfo.parameters?should?parse?the?"url"?variable?for?you?and?create?all?the?variables.


          Workaround?(
          if?any):
          Parse?the?URL?from?within?the?module?and?use?regular?expressions?to?remove?everything?up?to?(and?including)?the?question?mark.?Next,?parse?the?url
          -encoded?name/value?pairs?using?the?URLUtil?class?or?the?URLVariables?class,?like?so:

          [code]
          private?function?init():void?{
          //?discard?everything?up?to,?and?including,?the?question?mark?(?)?in?the?URL.
          var?re:RegExp?=?/.*\?/;
          var?urlStr:String?
          =?(this.loaderInfo.url).replace(re,?"");

          //?Use?the?URLUtil.stringToObject()?method?to?parse?the?query-string.
          var?str2:Object?=?URLUtil.stringToObject(urlStr,?"&");
          nameLbl.text?
          =?"name="?+?str2.name;

          //?Use?the?URLVariables?class?to?parse?the?query-string.
          var?urlV:URLVariables?=?new?URLVariables(urlStr);
          flavorLbl.text?
          +=?"flavor="?+?urlV.flavor;
          }
          [
          /code]


          The?Flex?documentation?uses?
          for?loops?and?String.split()?and?rewrites?most?of?the?logic?themselves,?but?that?solution?is?a?bit?overkill?considering?the?two?solutions?above?work?(and?with?a?lot?less?code)?

          posted on 2009-01-04 16:30 Peter Pan 閱讀(2433) 評論(1)  編輯  收藏 所屬分類: FLEX

          評論

          # re: flex 中module之間參數(shù)傳遞 2012-05-25 16:39 ss
          ddddd  回復(fù)  更多評論
            

          主站蜘蛛池模板: 毕节市| 板桥市| 汤阴县| 泸西县| 微山县| 绥阳县| 博客| 启东市| 三原县| 洛隆县| 钦州市| 安西县| 疏附县| 都安| 岳阳县| 阳山县| 都昌县| 隆化县| 蓬溪县| 麻城市| 武威市| 长丰县| 沽源县| 武清区| 五原县| 阳朔县| 深泽县| 吴江市| 丰都县| 望谟县| 阜平县| 镶黄旗| 东乡县| 阳新县| 梓潼县| 达州市| 永修县| 庆安县| 侯马市| 时尚| 洛扎县|