This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            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之間參數傳遞 2012-05-25 16:39 ss
          ddddd  回復  更多評論
            

          主站蜘蛛池模板: 平和县| 日喀则市| 邯郸市| 嘉善县| 普陀区| 临潭县| 尖扎县| 孟村| 青龙| 甘洛县| 平昌县| 洱源县| 项城市| 阜南县| 博野县| 双柏县| 南召县| 黑龙江省| 彰化市| 九龙县| 南京市| 通江县| 灵寿县| 民县| 景东| 铜陵市| 荆门市| 通江县| 厦门市| 福贡县| 陇西县| 阿图什市| 芜湖市| 崇明县| 铁岭市| 襄垣县| 蒙自县| 垦利县| 河间市| 轮台县| 儋州市|