문제

디지털 북 응용 프로그램으로 작업하고 있습니다. PDF에서 생성 된 SWF 페이지를로드하려면 SWF 로더를 사용합니다. TextSnapsot를 사용하여 페이지에 인라인 텍스트 강조 표시를 그립니다. 하이라이트는 세션 전체에서 각 페이지에 철저히 유지되며 나중에 문제없이 업데이트 / 삭제 될 수 있습니다. 페이지 캐싱을 활성화하기 위해 SWF로드 방식에서 다음과 같은 변경을 할 때까지 모든 것이 잘 작동했습니다.

이제 SWF 로더 객체를 응용 프로그램 메모리에로드하고 한 페이지에서 다른 페이지에서 다른 페이지로 점프하는 동안 다음 페이지의 내용을 사용자에게 디스플레이에있는 현재 SWF 로더에 복사하는 것입니다. 두 세트의 SWF 로더가 있습니다. 다음 / 이전 페이지를 캐시 할 수 있도록 페이지를 표시하는 데 필요한 것입니다. 캐싱 측면에서 SWF를 응용 프로그램 메모리에로드하고로드 된 후에는로드 된 SWF 페이지 (MAVIE CLIP의 어린이)의 모든 내용을 배열 컬렉션으로 선택합니다. 페이지를 변경하는 동안 캐시 된 콘텐츠를 페이지를 표시하는 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)

코드는 수동으로 강조 표시를 해제하는 데 사용됩니다 (페이지에서 마우스 드래그 사용).

    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();

            }                

        }            

    }
.

코드가 이전에 그려진 하이라이트를 다시 실행하는 데 사용합니다.

    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);

    }
.

이 문제를 해결하기 위해 지원을 기다리고 있습니다.

감사합니다.

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