I have one input text box one dynamic textbox and two button in my flash movie. What I want is Is there any way any code such that I enter text in my input box and i select a part of it I click the transfer button and the selected should be copied to the dynamic text box that is whatever i have selected in the text box should be copied to the dynamic text box using the button. \r\rSecond thing in the Input box i enter text and I select some text and on clicking the second button the selected should be bolded/underlined as it happens in word or any text editing tool. Is there any way around to do these. \r\rPlease help solve this issue. I am getting mad working around this. \r\rregards \rshankar
yes.
huh? thoriphes, now that must’ve been helpfull, lol!
vshankar,\r\rthis gave me more trouble than i anticipated. make a movie somewhere and put this in it:\r\ronClipEvent(keyDown){\r        if (Key.getCode() == Key.ENTER) {\r                _root.outputtext = _root.inputtext.slice(Selection.getBeginIndex(),Selection.getEndIndex());\r                trace(_root.inputtext);\r        }\r}\r\r\rnow it will work when you press enter.\r\rthe problem i was having with the button is that when i clicked the button it defocused and deselected the text, so all of the Selection references were useless.\r\rlet me know if you find a way around it.\r\rre: the second thing. i don’t see an easy way to do this.\ryou might split it into an array based on the selection points.\rso you have:\r\r array[0]=before selected text\r array[1]=selected text\r array[2]=after selected text\r\rand then put them together like this:\r\rnewText=array[0]+"***"+array[1]+"***"+array[2];\r\rthere’ll probably be a pause when this is executed … just flash’s unbelievably poor text handling characteristics.\r\rgood luck.
hey, i found a way around it.\r\rif you run this code continously:\r\rif(Selection.getBeginIndex()!=-1){\r        _root.startselect = Selection.getBeginIndex();\r        _root.endselect = Selection.getEndIndex();\r}\r\rthen use the variables you set instead of the Selection object, you can have the button trigger the text actions. since it won’t set them once they equal -1 (ie. if nothing is selected) they’ll represent whatever was selected immediately before hitting the button, which is just what we want.\r\rthe button code would be:\r\ron(release){\r        outputtext = inputtext.slice(startselect,endselect);\r}\r\ri also wrote a function for highlighting text. bold and italic tags result in the surrounded text disappearing (not the fault of this function) but using a font colour instead works fine:\r\rfunction highlight(string,startpoint,endpoint){\r        var a = new Array();\r        a[0] = string.slice(0,startpoint);\r        a[1] = string.slice(startpoint,endpoint);\r        a[2] = string.slice(endpoint,string.length);\r        return(a[0]+"<font color="#ff0000">"+a[1]+"</font>"+a[2]);\r}\r\rthen call it (in conjunction with the method of preserving the start and end selects as above):\r\routputtext = highlight(inputtext,startselect,endselect);\r\rlovely.