I trying to build a simple application in flex in which I render a swf in the application. I want to enable user to search text using a textbox (id="SearchInpt") and button (id="SearchBtn").
I used this following command to convert the pdf to swf pdf2swf -f file.pdf -o file.swf (thanks Matthias) I am able to load the swf file into the application, but search always fails. Below is the code I am using (source: http://wiki.swftools.org/index.php/How_do_I_highlight_text_in_the_SWF%3F). Am I missing something in the code. I will be grateful for any help or pointers to resources. Thanks! <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" > <mx:Script> <![CDATA[ import mx.controls.SWFLoader; import mx.controls.Label; import flash.text.TextSnapshot; public var snapText:TextSnapshot; private function doSearch() : void { snapText = img.textSnapshot; if (SearchInpt.text != '' && SearchInpt.text.length > 1) { var textPos:int = snapText.findText(0, SearchInpt.text, false); snapText.setSelected( 0, snapText.charCount, false ); if (textPos > 0) { do { snapText.setSelectColor( 0xFFEF00 ); snapText.setSelected( textPos, textPos + SearchInpt.text.length, true ); textPos = snapText.findText(textPos + SearchInpt.text.length, SearchInpt.text, false); } while (textPos > 0) } else { Alert.show( "Not found.", "Information" ); } } else { snapText.setSelected( 0, snapText.charCount, false ); } } ]]> </mx:Script> <mx:Panel title="SWF Player" y = "50" width="100%" height="100%"> <mx:Canvas id="canvas" width="100%" height="100%"> <mx:TextInput x="10" y="21" width="80" id="SearchInpt"/> <mx:Button x="98" y="21" label="Search" id="SearchBtn" click = "doSearch()"/> <mx:SWFLoader id ="img" source="C:/file.swf" y="50" /> </mx:Canvas> </mx:Panel> </mx:Application>
