header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
rani
Points:0
Posts:0

2/12/2010 3:01:22 AM

Title: cut copy paste code


I need to do cut ,copy and paste in a textarea .what code i should write?
HELP PLEASE



1
darla
Points: 0
Posts:0
2/12/2010 11:20:06 PM



try this



<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Panel title="TextArea Control Example" height="75%" width="75%" 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
        
        <mx:TextArea width="400" height="100">
            <mx:text>
                This is a multiline, editable TextArea control. If you need 
                a non-editable multiline control, use the Text control.
            </mx:text>
        </mx:TextArea>
    </mx:Panel>
</mx:Application>

2
Xeon
Points: 0
Posts:0
2/13/2010 11:16:30 AM



HI you can always cut , copy paste in textbox , make clear what exact functionality do you require?

3
rani
Points: 0
Posts:0
2/14/2010 9:33:28 PM



I need to cut, copy and paste from textarea or textbox on button click event

4
rani
Points: 0
Posts:0
2/15/2010 12:15:40 AM



finally i wrtten following code to do the cut copy and paste in a textarea and it is working


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mxeffects="com.adobe.ac.mxeffects.*"  creationComplete="onCreationComplete()"  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:TextArea id="txtedit" width="361" height="196"/>	
<mx:Button id="btnpaste" label="PASTE" x="177.5" y="247" click="fnpaste()"/>
<mx:Button id="btncut" label="CUT" x="57" y="247" click="fncut()"/>
<mx:Button id="btncopy" label="COPY" x="112" y="247" click="fncopy()"/>

<mx:Script>
	<![CDATA[
		import mx.controls.Alert;
	public var txtfld:TextField;
	 import mx.core.mx_internal; 
	 public var aa:int;
	public	var bb:int;
	[Bindable] 
            private var insertionPointIndex:int; 
            
	public var a:String=new String();
            use namespace mx_internal; 
		public function fncut():void
		{	
			
			
			a=txtfld.selectedText;
			txtfld.replaceText(aa,bb,"");
            mx.controls.Alert.show(a);
            btnpaste.enabled=true;
			
		}
		public function fncopy():void
		{	
			
			
			a=txtfld.selectedText;
			//txtfld.replaceText(aa,bb,"");
            mx.controls.Alert.show(a);
            btnpaste.enabled=true;
			
		}
		public function fnpaste():void
		{
			 txtfld.replaceText(insertionPointIndex,insertionPointIndex,a);
            
		}
		   private function onCreationComplete():void 
            { 
                txtfld = TextField(txtedit.getTextField()); 
                txtfld.addEventListener(MouseEvent.CLICK,onTextFieldClick); 
                txtedit.addEventListener(TextEvent.TEXT_INPUT,onTextAreaTextInput); 
                txtedit.addEventListener(Event.CHANGE,onTextAreaChange); 
                btnpaste.enabled=false;
            } 
            
            private function onTextFieldClick(event:Event):void 
            { 
                update(); 
            } 
            
            private function onTextAreaTextInput(event:Event):void 
            { 
                update(); 
            } 
            
            private function onTextAreaChange(event:Event):void 
            { 
                update(); 
            } 
            
            private function update():void 
            { 
               insertionPointIndex = txtfld.caretIndex;
               	aa=txtedit.selectionBeginIndex;
				bb=txtedit.selectionEndIndex;

                 
            } 
	]]>
</mx:Script>
</mx:WindowedApplication>

5
Milaan
Points: 0
Posts:0
2/15/2010 2:13:33 AM



thanks rani, for the copy paste code


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+2 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions