解决PDFToFlex源程序的小BUG——页面控制的最后两页无法正常切换问题

 在解析Igor Costa(http://www.igorcosta.org/)源程序(详看我的http://www.cnblogs.com/wuhenke/archive/2009/11/12/1601535.html)的基础上,解决了左边页面控制中,MovieClip最后两帧无法正常互切换的问题。饮水思源,下面是我对他的反馈交流:

“Hi Igor,

Thank you for your great work of solve loading the pdf's swf file. After learning and running your programn,I find a small bug exists in face control. The bug is that you can't switch the last two frames from each other correctly.The currentFrame property of MovieClip can't equal with this MovieClip.totalFrames forever. Of course maybe it's Flash bug。I spent much time in removing this bug.Last i used a skill avoiding the bug.

what you need do is add "Application.application.libMC.gotoAndStop(e.currentTarget.pageNumber-2);" into the first line of function dispatchPage of Pages.mxml . Such as:

private function dispatchPage(e:MouseEvent):void {

//此处用到小技巧,解决最后两页切换的无法转换的问题

Application.application.libMC.gotoAndStop(e.currentTarget.pageNumber-2);

Application.application.libMC.gotoAndStop(e.currentTarget.pageNumber);

}

Maybe you can make your work more perfect!Thank you for you prework!

出现上面的原因:

MovieClip的currentFrame属性最大值只能为totalFrames-1即倒数第二帧,无法为totalFrames。但是从倒数第二帧到最后一帧用gotoAndStop切换可以的,但是反过来切换就失效了。我查了很多资料,也没有相关的问题的解决方案。我感觉是MovieClip自身的Bug。

解决方法:

只需要修改 Pages.mxml中的dispatchPage函数,添加 Application.application.libMC.gotoAndStop(e.currentTarget.pageNumber-2);这里是小技巧,是解决最后两帧不能正常切换的问题。技巧思路是:先切换到目标帧的后面的两帧,然后再跳转到目标帧。