现在的位置: 首页 > 综合 > 正文

再谈Flex App的deep link~

2012年05月09日 ⁄ 综合 ⁄ 共 3223字 ⁄ 字号 评论关闭
此篇主要谈flex2、flex3应用中deeplink的解决方案,urlkit的更新使用,flex3中内置的deeplink方案。参考前文转述。

先说一下flex app中history management及deeplink的关系,首先,在flex2 framework应用是没有deeplink内置实现的解决方案的(当然,我们可以用前文所述的解决方案之一解决,如urlkit),仅仅有history management,也就是实现对浏览器的forward、back按钮命令的支持,如此有限的功能(肯定很少人会去使用)仅仅是deep link的功能子集,deep link要求web应用支持url与应用程序状态相互通信(相当于双向binding)、浏览器back、forward的支持(如此当然bookmark自然就支持了)。如此,我们可以看出我们的应用当然要实现的是deep link,无论是在flex2或是flex3应用中。

说说flex2和flex3应用中的deep link解决方案,在flex2中,我们通常选择swfaddress或是urlkit等开源解决方法,而flex3中有了内置了deeplink的支持(具体介绍见Flex3 Help beta3),无论是在flex2或3中,抑或是使用哪一种解决方法,基本上可以(严格来讲是一定)把flex app的history management支持关闭,其和deep link在实现功能的过程是相冲突的,而且deep link已经包含了前者的功能,所以也就没必要不关闭了。另一种在flex2应用中实现deep link的解决方法,是挖取flex3中deep link的实现编译成独立的swc供使用,flex3中此块的现实相对较为独立,不依赖与其余部分,具体步骤见using flex3 deep link in flex2

    * create a new Flex Library project based on the Flex 2.0.1 SDK
    
* copy the following files into it from the Flex 3 SDK source:
            mx
/core/Version.as (note: this is included by the other files, but not compiled itself)
            mx
/events/BrowserChangeEvent.as
            mx
/managers/IBrowserManager.as
            mx
/managers/BrowserManager.as
            mx
/managers/BrowserManagerImpl.as
    
* comment out the line in BrowserManagerImpl.init() which sets the historyManagementEnabled flag
         — 
this does not exist in Flex 2.
   
* compile the above files (excluding Version.as) into a SWC
    
* in your Flex 2 application, drop in an HTML template generated by Flex Builder 3 for a Flex 3
        deep
-linking app. This template will include a history/ subdirectory with
        JavaScript and CSS files 
in it, and the HTML page loading the app will refer to those files.
    
* Add the following line to your application startup, prior to calling BrowserManager.getInstance()

      Singleton.registerClass(
"mx.managers::IBrowserManager",
          Class(getDefinitionByName(
"mx.managers::BrowserManagerImpl")));


说说urlkit,这里主要推荐使用urlkit,主要原因:
1、其使用方便,声明式应用
2、flex3中的deep link的实现来源于urlkit
3、urlkit又有了最新更新(刚刚~~,很及时啊),对ie7,safari的支持及flex2、flex3的统一
4、flex3中的deep-link支持只是flex发展过程中的临时版本,adobe会在以后实现更加自动的一体解决方案(看其flex3 deep-link implementation节),在这之前还是用urlkit的好

抱歉!评论已关闭.