Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:17:51+00:00 2026-05-30T18:17:51+00:00

I am working with a digital book application. I make use of swf loader

  • 0

I am working with a digital book application. I make use of swf loader to load swf pages created from pdf. I use TextSnapsot to draw inline text highlight on the pages. The highlight is thoroughly retained on the respective pages throughout the session and later it can be updated/deleted without any problem. Everything was working great till I made the following changes in the swf loading approach to enable page caching:

I am now loading swf loader object into application memory and while doing jumping from one page to other page I am just copying the content of the next page to the current swf loader which is on the display to the user. There are two sets of swf loaders – one for displaying the page and other to cache the next/previous page(s). On the caching side, I load the swf into application memory and after getting it loaded I pick all the contents of the loaded swf page (the children of it’s movie clip) into an array collection. While changing the page I copy the cached content into the swf loader’s movie clip which is displaying the page.

Now when I highlight on the page on display and navigate back/forth from the page and comeback again to the page where I did the highlighting: It shows the highlight I did. But as soon as I try to draw another highlight on that page, the previous highlight is instantly disappears from the page.

I suspect that the Textsnapshot object which draws highlight while navigating (to the target display page) is different from the one which redraws/update the highlight on the same page next time. Although the Textsnapshot object id for both the objects is same.

Here are some code snippet:

For copying the content from the swf loader object cached in application memory:

    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;

    }

For copying the content to the swf loader which is displaying the page:

    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;

    }

after this I dispatch swf loader’s complete manually and in the handler of that event I take the text snap shot object.(highlightManager.as)

Code I use to draw highlight manually(using mouse drag on the page).

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

            }                

        }            

    }

Code I use to redraw previously drawn highlight when I return to the 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);

    }

Looking forward to your support to resolve this issue.

Regards,

JS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:17:53+00:00Added an answer on May 30, 2026 at 6:17 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Cocoa application which will be used for a digital-signage/kiosk style
Using Visual Studio 2008 (C#) I have to make a working clock (digital) with
I am working on a browser-based application that is essentially a Digital Audio Workstation.
I am working on a project to implement digital signatures of outgoing messages and
I'm working on a site that allows users to purchase digital content and have
One of my friend is working on issue related to updating expired digital certificates.
Working on a rather small, and simple layout, I decided to use Meyer's CSS
I am working on a digital asset management product where users can upload images
I am working on a website of digital signage , My boss want the
I have the exe for the project im working on signed by a digital

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.