<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 495,comments - 227,trackbacks - 0
    http://hi.baidu.com/gacmotor/blog/item/cdabd417a5485a5af2de320b.html

    If you've ever tried to load a FlashPaper document in Flex 2, then you know it's not as straightforward as it was with Flex 1.5.

    Sure, you can just use an <mx:SWFLoader /> tag. But, if you've tried this, you know it's pretty limited. You can't talk to the FlashPaper document, and the loaded document gets stuck at a fixed size or scales incorrectly when resized. If you try fiddling with the various scaleContent and maintainAspectRatio settings, you'll quickly get frustrated trying to achieve the perfect resize behavior.

    I've run into this problem in the Flex 2 application I'm currently building. We're using ColdFusion to generate dynamic reports via the <cfreport> tag, capturing the report output as FlashPaper, and then loading the report output .swf directly into the Flex 2 application. I'm happy to say that I've solved the resize and communication issues, and I've been given permission to post these on my weblog from the client that I've written the code for.

    You can download my Flex 2 FlashPaperLoader here. (.zip archive) - MIT License

    There's a lot of interesting things going on the .zip file. In the archive you'll find the following files:

    • flash
      • FlashPaperLoader.fla
      • FlashPaperLoader_code.as
    • flex
      • com/darronschall/controls/FlashPaperLoader.as
      • FlashPaperLoaderExample.mxml

    Note that the code is mostly complete but it is not a compile-ready working example. You will need a few tweaks get it working: You'll need to create a new Flex project named "FlashPaperLoaderExample" out of the code in the flex subdirectory, copy the flash/FlashPaperLoader.swf file to the Flex project's bin directory so it lives along side of the Flex 2 output .swf, change the "flashPaperURL" in the FlashPaperLoaderExample.mxml to point to a valid FlashPaper document... and then you should be good to go.

    The example file contains an indeterminate progress bar that loads a FlashPaper document full screen. The progress bar goes away when the FlashPaper is fully loaded. Try resizing your browser window to see how the loaded FlashPaper document resizes to fill the available space.

    The best way to understand what is going on is to just dive in and take a look at the code. Start in FlashPaperLoaderExample.mxml, then FlashPaperLoader.as, then look in FlashPaperLoader_code.as. Basically, the concept is this:

    The FlashPaperLoader Flex control is used to load a Flash 8 ActionScript 2 FlashPaperLoader.swf file, generated from the FlashPaperLoader.fla file. The FlashPaperLoader.swf file is passed the URL of the FlashPaper document, as well as a unique identifier (fpProxyId) and the object/embed name of the Flex client (swfDomId) - "FlashPaperLoaderExample" in this case. The latter two parameters are necessary for the communication mechanism between Flex and FlashPaper. The loaded FlashPaperLoader.swf handles loading the FlashPaper document and fosters communication between Flex 2 and FlashPaper.

    Communication is done through ExternalInterface. By leveraging JavaScript, the ActionScript 3 code running inside of AVM2 can communicate with the ActionScript 2 code running inside of AVM1. There is no way for the two different VMs to talk directly, so JavaScript acts as the middle man.

    So, if the Flex client needs to resize the FlashPaper document, it calls a JavaScript method such as "APP.setSize82" where "82" is the fpProxyId unique identifier and "APP" is the object/embed id/name attribute of the Flex client embedded in the HTML page. The FlashPaperLoader.swf file registers a handler for the JavaScript method setSize82 with its own internal setSize method, so when the Flex client invokes the JavaScript method, the FlashPaperLoader.swf file picks it up. Then, in turn, the loader .swf just invokes the setSize method on the loaded FlashPaper document passing in the appropriate width and height. A similar process is used for going from FlashPaper to Flex 2.

    The reason the fpProxyId is needed is for when the Flex client loads multiple FlashPaper documents. The Flex client needs to know that it's calling a method on the appropriate FlashPaper target, so the id is used to differentiate the different loaded loader .swf files.

    I know it sounds a little confusing, but everything is explained inside of the source code.

    There are a few improvements that can be made to this code. One of them is that I'm only exposing the "setSize" and "printTheDocument" methods from the IFlashPaper interface. Obviously, there are a lot more methods than that (but that was all I've needed so far). Additionally, it might be a little cleaner to use FlashInterface for the communication between AVM1 and AVM2, but I wrote my code some two months ago and didn't feel the need to change the basics of it since it's been working flawlessly for me. Also, you might want to have the FlashPaperLoader.swf proxy the percentage complete when loading a FlashPaper document so the Flex 2 client can update the loaded progress correctly.

    I hope that helps! I know a few people have been asking about this, so hopefully my code will get things working for you as well. As I said, I've been using this technique for awhile nowâ ¦ Good luck!


    posted on 2010-04-03 23:42 SIMONE 閱讀(493) 評論(0)  編輯  收藏 所屬分類: flash
    主站蜘蛛池模板: 亚洲Av永久无码精品一区二区| 99在线视频免费观看| 极品色天使在线婷婷天堂亚洲 | 8x8×在线永久免费视频| 美腿丝袜亚洲综合| 国产V片在线播放免费无码| 国产成人综合亚洲亚洲国产第一页| 一级特黄a大片免费| 欧美三级在线电影免费| 亚洲av无码一区二区三区天堂古代 | 亚洲影院在线观看| 久久亚洲色WWW成人欧美| 国产国产人免费人成免费视频 | 四虎免费久久影院| 亚洲妓女综合网99| 国产va精品免费观看| 亚洲国产成人手机在线观看| 国产午夜鲁丝片AV无码免费| 日本高清不卡中文字幕免费| 国产精品亚洲片在线观看不卡 | 日韩免费电影在线观看| 亚洲无圣光一区二区| 午夜网站免费版在线观看| 免费人成动漫在线播放r18 | 亚洲天堂电影在线观看| 浮力影院第一页小视频国产在线观看免费 | 在线观看免费亚洲| av片在线观看永久免费| 亚洲精品在线观看视频| 九九免费精品视频在这里| 亚洲va无码手机在线电影| 麻豆va在线精品免费播放| 亚洲日韩精品无码专区网址 | 午夜性色一区二区三区免费不卡视频 | 亚洲成在人天堂在线| 久久久久国产精品免费看| 亚洲精品第一国产综合境外资源 | 亚洲AV无码国产剧情| 亚洲国产精品无码成人片久久| 国产特黄一级一片免费| 亚洲六月丁香六月婷婷色伊人|