SWF text query and highlight display-Step 3: highlight text query and solve the problem that keywords cannot be highlighted during movieclip frame Switching

Source: Internet
Author: User

SWF keyword highlighted display effect:

In the previous article, I have introduced the basic idea and reprinted the key of keyword query display.Code. These are not repeated! I will release the source code at the end. I want to write about the problems and solutions I encountered during implementation -- solve the problem that keywords cannot be highlighted during movieclip frame switching.

 

Problem description/description:

1. after the text search and highlight display function is added, the query keywords can be properly highlighted on the first page, but other frames (pages) cannot display keywords. Switch to other pages and return to the first page, the keywords on the first page cannot be displayed, and the status of other pages that are not retrieved or highlighted by keywords is not saved.

Switch the movieclip frame in the control bar on the left side of the page.

2. If it is the first frame, click previouspage. The keyword shows that the effect disappears. If the last page is displayed, clicking nextpage will also lead to a loss of keyword highlighting.

 

Cause analysis:

According to my code tests, I found that the keyword search indeed Retrieves all frames of movieclip and has obtained all locations, only after frame switching, other movieclip frames do not display keywords. They can only be displayed on the current frame during the first query and displayed on the second query.ProgramAfter the code is executed normally and the retrieval location is obtained, it still cannot be displayed normally. After multiple tests, we found that the problem lies in the textsnapshot object.

The textsnapshot object must be defined outside the function and global. (This program also needs to set the page to public for other classes to call)

Textsnapshot objects cannot be defined multiple. They must exist only one. The textsnapshot object appears to be blocked during frame switching and cannot be displayed normally.

 

Solution:

Problem 1: During frame switching, the original textsnapshot object is overwritten, that is, the textsnapshot object is null. Then, the new textsnapshot object is generated and the textsnapshot object is operated. Enable keyword highlighting. Add the following to the frame switching function:

This. snaptext = NULL;
Dosearch ();

Problem 2: If the first frame is determined, the previouspage is hidden. If the last frame is determined, the nextpage is hidden. To hide the corresponding linkbutton, enabled = false of the linkbutton; it does not seem to work.

Add the following in the nextpage () function:

Btnprevious. Visible = true;
If (_ currentpage = _ pages-1)
{
Btnnext. Visible = false;
}

In the previouspage () function, add:

Btnnext. Visible = true;
If (_ currentpage = 1)
{
Btnprevious. Visible = false;
}

Note: The PDF document converted to SwF must be in text format, not an image. Otherwise, it cannot be retrieved or highlighted.

Source codeDownload: keyword highlighted demo (only the basic demo Source Code. For more information, seeArticleStep by step improvement)

Content to be resolved in the next step: 1. Capture every frame of movieclip as an image (Still a problem......) 2. Solve the moviecip printing problem (Note: it has been resolved. Please refer to the following post)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.