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
Answered

2/15/2010 2:54:31 AM

Title: undo operation in flex application


I want to create a notepad,I want to do undo operation as that in notepad.how to get that.
HELP ME PLEASE



Taylor
Points: 0
Posts:0
2/15/2010 3:06:56 AM



To create a Undo and Redo operation in flex application similar to notepad you have to create an array in which you can store a snapshot of current data. On pressing an Undo button you can restore the old data from previous position of array and on Redo you can move forward in the array until finished. By this method you can create any number of Undo / Redo operations.

Joginder
Points: 0
Posts:0
Accepted Answer
2/15/2010 3:34:40 AM



Hi rani , see this code for Undo redo in flash like notepad.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768">
	<mx:Script>
		<![CDATA[
			private var dataArray:Array= new Array();
			
			private var currentData:int;
			private function saveData():void{
				if(dataArray.length<10){
					dataArray.push(txtArea.text);
				}else{
					dataArray.splice(0,1);
					dataArray.push(txtArea.text);
				}
				currentData= dataArray.length-1;
			}
			
			private function undo():void{
				if(currentData>0){
					txtArea.text=dataArray[currentData-1]
					currentData=currentData-1;
				}
			}
			private function redo():void{
				if(currentData<dataArray.length-1){
					txtArea.text=dataArray[currentData+1]
					currentData=currentData+1
				}
			}
		]]>
	</mx:Script>
	<mx:TextArea id="txtArea" x="21" y="10" width="325" height="104" change="saveData()"/>
	<mx:Button x="21" y="137" label="Undo" click="undo()"/>
	<mx:Button x="231" y="137" label="Redo" click="redo()"/>
	</mx:Application>


rani
Points: 0
Posts:0
2/15/2010 4:48:42 AM



thanks a ton


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+1 



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