A kind ofly edit rich text and reduce by FLASH the method that shows
Technical field
The present invention relates to software technology field, more particularly, relate to and a kind ofly edit rich text and reduce by FLASH the method that shows.
Background technology
FLASH is a kind of 2 D animation design software.SWF (shock wave flash) is the professional format of the animation software FLASH of Macromedia company, it is the animation file form of a kind of support vector and dot pattern, be widely used in webpage design, the fields such as cartoon making, the SWF file is also referred to as the FLASH file usually.
Yet when FLASH software showed graph-text content at the assemblies such as TextField by itself, Image Display easily misplaced, the effect that presents in the time of can't obtaining editing.Therefore, be necessary to provide a kind of method that can edit and show by FLASH in the mode that both pictures and texts are excellent.
Summary of the invention
The technical problem to be solved in the present invention is, can not show for existing FLASH software the defective that graph-text content easily misplaces, and provides a kind of and edits rich text and reduce by FLASH the method that shows.
The technical solution adopted for the present invention to solve the technical problems is: construct and a kind ofly edit rich text and reduce by FLASH the method that shows, comprise the following steps:
S1, by editing machine, graph text information is carried out visual edit, and save as the RTF document;
S2, the RTF document is changed into HTML code and data resource;
S3, the above-mentioned HTML code of use and data resource reduce in FLASH and show graph text information.
In method of the present invention, described step S2 further comprises:
S21, obtain in the RTF document that all ole object elements change into picture and attribute information is saved in a sequential chained list;
S22, obtain all the character object element property information of paragraph in the RTF document, merge together with above-mentioned ole object attribute of an element information and be saved in described sequential chained list;
The element node attribute information of S23, the above-mentioned sequential chained list of analysis resolves into text filed regional with hyperlink;
S24, the text filed element node attribute information of analysis generate corresponding code;
S25, the regional element node of analysis hyperlink attribute information generate corresponding code.
In method of the present invention, described step S24 further comprises:
S241, the text filed element node attribute information of analysis, the text or the ole object that resolve into like attribute are regional;
The text element node attribute information of S242, analysis like attribute generates corresponding code;
S243, analyze the element node attribute information in ole object zone, generate corresponding code.
In method of the present invention, described step S25 further comprises:
S251, the regional element node of analysis hyperlink attribute information obtain the hyperlink part and show textual portions;
S252, obtain the URL of hyperlink;
S253, described demonstration textual portions is changed, generated corresponding code;
The URL of S254, the above-mentioned hyperlink of assembling and demonstration text codes.
In method of the present invention, described step S3 further comprises:
S31, load the HTML code file with text mode in Flash, and it is changed into XML class data structure preserve;
S32, analyzing XML class data are distinguished resource data and resource organizations's data;
S33, according to the picture resource address and the ID that record in XML, the resource that Loads Image is also preserved, and carries out simultaneously the ID judgement, and the resource that loaded is shared;
S34, resolving resource organising data resolve into textual portions with it and picture partly is the array of first primitive unit cell, resolve simultaneously segment data;
S35, parse the sign of each text element in pairing picture and text array;
S36, hide sample text and show test;
S37, circulation shows the element in the picture and text array one by one, and carries out segmentation according to segment data, until shown all elements;
S38, the element after showing is carried out an arrangement optimization complete picture and text and show.
In method of the present invention, described step S35 is specially: show text and picture according to the restriction of width, with the hidden text frame, text is shown in advance, adjust width and line feed; Determine whether being connected on according to the width of remaining width and picture and show after text or line feed shows.
Implement editor's rich text of the present invention and reduce by FLASH the method that shows, have following beneficial effect: the present invention can carry out visual edit to graph text information simply and easily by editing machine, and can reduce the effect that presents when video text editing in FLASH, solved the FLASH software problem that picture misplaces fully when picture and text show.
Description of drawings
The invention will be further described below in conjunction with drawings and Examples, in accompanying drawing:
Fig. 1 is the method flow diagram in the preferred embodiment of the present invention;
Fig. 2 is with the particular flow sheet of RTF document converting to HTML code and data resource in the preferred embodiment of the present invention;
Fig. 3 analyzes the particular flow sheet of the corresponding code of text filed generation in the preferred embodiment of the present invention;
Fig. 4 is the particular flow sheet of analyzing the corresponding code of hyperlink zone generation in the preferred embodiment of the present invention;
Fig. 5 be in the preferred embodiment of the present invention in FLASH reduction show the process flow diagram of graph text information.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.
The present invention mainly provides a kind of and has edited rich text and reduce by FLASH the method that shows, it is mainly to provide a video text editing device in client, allow user's content of edit, and content is saved as the rich text format file, when needs issue this document content, can convert the RTF document that both pictures and texts are excellent to associated data files and resource file, and load data reduction graph-text content in FLASH.By this technology, make the user can be as in using board when content of edit, What You See Is What You Get editor graph-text content generates the FLASH format file at last.The RTF that adopts in this process is a kind of rich text format file, and Chinese translation claims again rich text format or rich text form etc.It is also the WordPad accepted standard form of Microsoft simultaneously.The RTF file is a kind of file of similar DOC form, and good compatibility is arranged, and uses " board " in Windows " annex " just can open the edlin of going forward side by side.The RTF document can be used for carrying out the transmission of formatted text document between different application.
The below is described specific implementation process of the present invention.
See also Fig. 1, be the method flow diagram in the preferred embodiment of the present invention.As shown in Figure 1, method provided by the invention mainly comprises the following steps:
At first in step S1, by editing machine, graph text information is carried out visual edit, and save as the RTF document.For example at RichEdit control inediting graph text information, and save as the RTF file.
In step S2, the RTF document is changed into HTML code and data resource subsequently.
At last, in step S3, use above-mentioned HTML code and data resource to reduce in FLASH and show graph text information.
See also Fig. 2, for the present invention is with the particular flow sheet of RTF document converting to HTML code and data resource in the preferred embodiment of the present invention.As shown in Figure 2, above-mentioned steps S2 further realizes by following scheme:
In step S21, obtain in the RTF document that all ole object elements change into picture and attribute information is saved in a sequential chained list.For example, analyze the ole object element in MSFTEdit.dll, it is changed into corresponding picture and attribute information, be saved in and form OLEObjects in sequential chained list.In this step, can also carry out CRC32 to the pictorial information resource and calculate, optimize identical resource and only preserve portion, to reduce the overall data amount.
In step S22, obtain all character object element property information of paragraph in the RTF document, merge to be saved in described sequential chained list together with above-mentioned ole object attribute of an element information and form MSFTObjects.
In step S23, analyze the element node attribute information of above-mentioned sequential chained list, resolve into text filed (Txt2Html) and hyperlink zone (HyperLink2Html).
In step S24, analyze text filed element node attribute information, generate corresponding code.
In step S25, analyze the regional element node of hyperlink attribute information, generate corresponding code.
See also Fig. 3, for analyzing the particular flow sheet of the corresponding code of text filed generation in the preferred embodiment of the present invention.As shown in Figure 3, in above-mentioned steps S2, step S24 can further realize by the following method: in step S241, analyze text filed element node attribute information, the text or the ole object that resolve into like attribute are regional.In step S242, analyze the text fragments element node attribute information of like attribute, generate corresponding code (as Words2Html).In step S243, analyze the element node attribute information in ole object zone, generate corresponding code (as OLE2Html).
See also Fig. 4, for analyzing the particular flow sheet of the corresponding code of hyperlink zone generation in the preferred embodiment of the present invention.As shown in Figure 4, in above-mentioned steps S2, step S25 can further realize by the following method: in step S251, analyze the regional element node of hyperlink attribute information, obtain the hyperlink part and show textual portions.In step S252, obtain the URL of hyperlink.In step S253, described demonstration textual portions is changed, generate corresponding code (as Txt2Html).In step S254, the URL of the above-mentioned hyperlink of assembling and demonstration text codes.Step S25 can carry out simultaneously with step S24.
See also Fig. 5, for reduce the process flow diagram that shows graph text information in the preferred embodiment of the present invention in FLASH.As shown in Figure 5, in said method of the present invention, step S3 further can realize by following steps:
In step S31, load the HTML code file with text mode in Flash, and it is changed into the preservation of XML class data structure.
In step S32, analyzing XML class data are distinguished resource data and resource organizations's data.
In step S33, according to the picture resource address and the ID that record in XML, the resource that Loads Image is also preserved, and carries out simultaneously the ID judgement, and the resource that loaded is shared.
In step S34, the resolving resource organising data resolves into textual portions with it and picture partly is the array of first primitive unit cell, resolves simultaneously segment data.
In step S35, parse the sign of each text element in pairing picture and text array, so that follow-up demonstration one by one.
In step S36, hide sample text and show test.Mainly the restriction according to width shows text and picture, with the hidden text frame, text is shown in advance, adjusts width and line feed; Determine whether being connected on according to the width of remaining width and picture and show after text or line feed shows.
In step S37, circulation shows the element in the picture and text array one by one, and carries out segmentation according to segment data, until shown all elements.
In step S38, the element after showing is carried out arrangement optimization one time, and calculate width and the height of viewing area, show thereby complete picture and text all reduction work of completing.
In sum, the present invention can carry out visual edit to graph text information simply and easily by editing machine, and can reduce the effect that presents when video text editing in FLASH, has solved the FLASH software problem that picture misplaces fully when picture and text show.
The present invention is described according to specific embodiment, but it will be understood by those skilled in the art that when not breaking away from the scope of the invention, can carry out various variations and be equal to replacement.In addition, for adapting to specific occasion or the material of the technology of the present invention, can carry out many modifications and not break away from its protection domain the present invention.Therefore, the present invention is not limited to specific embodiment disclosed herein, and comprises that all drop into the embodiment of claim protection domain.