質問

デジタルブックアプリケーションで作業しています。 PDFから作成されたSWFページをロードするためにSWFローダーを使用します。 TextSnapsotを使用してページ上でインラインテキストのハイライトを描画します。ハイライトはセッション全体でそれぞれのページに徹底的に保持され、後で問題なく更新/削除することができます。 PAGE CACHINGを有効にするためのSWFロードアプローチの変更を下すまで、すべてが機能していました:

現在、SWFローダオブジェクトをアプリケーションメモリにロードしていて、あるページから他のページへジャンプしている間に、次のページの内容をユーザーに表示されている現在のSWFローダーにコピーするだけです。 SWFローダの2セットがあります - ページを表示するためのものとその他のページを表示して、次の/前のページをキャッシュします。キャッシング側では、SWFをアプリケーションメモリにロードし、ロードされた後、ロードされたSWFページ(ITのムービークリップの子)のすべての内容を配列コレクションに選択します。ページを変更している間、キャッシュされたコンテンツを、ページを表示しているSWFローダーのムービークリップにコピーします。

表示上のページ上で表示され、ページから戻って戻って戻って再度カウントバックしているページに戻ってください:それは私がしたハイライトを示しています。しかし、そのページに別のハイライトを描きようとするとすぐに、前のハイライトは即座にページから消えます。

私は(ターゲット表示ページへ)ナビゲート中にハイライトを描画するTextSnapshotオブジェクトが、次に同じページ上のハイライトを再描画/更新するものとは異なります。両方のオブジェクトのTextSnapshotオブジェクトIDは同じですが。

これはいくつかのコードスニペットです: アプリケーションメモリにキャッシュされたSWFローダオブジェクトからコンテンツをコピーするための

    private function copyPageContent():void

    {

        var contentCollection:ArrayCollection = new ArrayCollection();

        _pageContentVO = new PageContentVO();

        _pageContentVO.contentHeight = MovieClip(_swfPageLoader.content).height;

        _pageContentVO.contentWidth = MovieClip(_swfPageLoader.content).width;



        var count:int = MovieClip(_swfPageLoader.content).numChildren;                

        for(var i:int=0;i<count;i++)

        {

            var dispObject:DisplayObject = MovieClip(_swfPageLoader.content).removeChildAt(0);                

            contentCollection.addItem(dispObject);

        }



        _pageContentVO.pageContentCollection = contentCollection;

        _swfPageLoader = null;

    }
. ページを表示しているSWFローダにコンテンツをコピーするための

    private function copyContent(pageContentVo:PageContentVO):void

    {

        for(var i:int = 0;i<pageContentVo.pageContentCollection.length;i++)

        {

            var dispObject:DisplayObject = pageContentVo.pageContentCollection.getItemAt(i) as DisplayObject;

            MovieClip(this.content).addChild(dispObject);

        }

        this.content.height = this.height;

        this.content.width = this.width;

    }
.

この後、SWFローダを手動でディスパッチし、そのイベントのハンドラにテキストスナップショットオブジェクトを取ります。(HighlightManager.as)

コードiを使用します(ページ上のマウスドラッグを使用)。

    public function setHighlight():void

    {

        removeAll();

        if(_textSnapShot!=null && _textSnapShot.getText(0,_textSnapShot.charCount)!="")

        {                

            if(_isCoveredTextSelectedAtAnyInstance)

            {

                _textSnapShot.setSelected(_beginIndex,_endIndex+1,false); //this is the global variable to the class

            }

            else

            {

                _textSnapShot.setSelectColor(0xfff100);

                _textSnapShot.setSelected(_beginIndex,_endIndex+1,true);

            }

            if(saveHighlight)

            {

                countHighlightedSegments();

            }                

        }            

    }
.

コードI Pageに戻ると、以前に描かれたハイライトを再描画するためのコード:

    public function showHighlights(textSnapShot:TextSnapshot,currentPageNum:int):void

    {            

        if(currentPageNum >= 0)

        {

            textSnapShot.setSelected(0,textSnapShot.charCount,false);

            var pageVO:PageVO = _model.eBookVO.eBookPagesVO.getItemAt(currentPageNum) as PageVO;

            var objColl:ArrayCollection = new ArrayCollection();

            objColl.source = pageVO.highLightSelection;

            for(var i:int=0;i<objColl.length;i++)

            {

                var highlightVO:HighlightVO = new HighlightVO();

                highlightVO.beginIndex = objColl.getItemAt(i).beginIndex;

                highlightVO.endIndex = objColl.getItemAt(i).endIndex;

                setHighlightedSegment(textSnapShot,highlightVO.beginIndex,highlightVO.endIndex);

            }

        }

    }



    private function setHighlightedSegment(textSnapShot:TextSnapshot,beginIndex:int,endIndex:int):void

    {

        textSnapShot.setSelectColor(0xfff100);

        textSnapShot.setSelected(beginIndex,endIndex,true);

    }
.

この問題を解決するためのあなたのサポートを楽しみにしています。

wantes、

js

役に立ちましたか?

解決

What you're doing is not 'caching', it's preloading previous/next pages. Also, what you're doing is really bad practice. I'm not even sure why you're casting these things into MovieClips unless the SWFs are that; if they're Flex SWFs, they'll be UIComponents. I would recommend you rethink your approach. I wouldn't even bother copying the children or anything over. Once the browser loads a SWF, it is now part of the browser cache, meaning the next time it's requested, it won't actually download it.

If you want to 'cache' your SWFs for a quicker next/previous page flipping, I would recommend you use something like SWFLoader to just load the other SWFs without actually adding it to the display, then removing it from memory. That will cache the SWFs for you in the browser. Then when the user click previous/next, just change the url of the main swfloader of the currently displayed page and it will load it up really quickly. No downloading since it's already cached, it will just need to instantiate.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top