- 浏览: 159298 次
- 性别:
- 来自: 长沙
最新评论
-
Fis:
赞一个,文章帮助我们解决问题了,我们要在用swf生成一个动画配 ...
获取MovieClip跳帧后的子元件 -
恋曲2000:
lz,肯定看过孙颖的《Flash.ActionScript3. ...
AS3与XML -
woyaowenzi:
very good
Flex 模块化应用程序开发 -
wenqihui2008:
不错,好东西,正需要。谢谢。只是以标记的文字不能选了。我想要就 ...
Flex中对文本实现高亮显示 -
ibio:
好东西。我搜藏啦!~
[as3]使用声音
将文本编辑器内容保存到本地的一个地址,转自http://space.actionscript3.cn/html/43/t-3643.html
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
backgroundColor="0x0000FF"
backgroundImage=""
backgroundAlpha="0.75"
title="Text Editor"
applicationComplete="appCompleteHandler()">
<mx:Script>
<![CDATA[
import flash.filesystem.*;
import mx.events.*;
import mx.controls.Alert;
private var currentFile:File; // The currentFile opened (and saved) by the application
private var stream:FileStream = new FileStream(); // The FileStream object used for reading and writing the currentFile
private var defaultDirectory:File; // The default directory
[Bindable] public var dataChanged:Boolean = false; // Whether the text data has changed (and should be saved)
/**
* Called as the event handler for the applicationComplete event of the Application. This method
* sets the position and size of the main window.
*/
private function appCompleteHandler():void
{
defaultDirectory = File.documentsDirectory;
stage.nativeWindow.width = Math.min(800, Capabilities.screenResolutionX - 60);
stage.nativeWindow.height = Capabilities.screenResolutionY - 60;
stage.nativeWindow.visible = true;
}
/**
* Called when the user clicks the Open button. Opens a file chooser dialog box, in which the
* user selects a currentFile.
*/
private function openFile():void
{
var fileChooser:File;
if (currentFile)
{
fileChooser = currentFile;
}
else
{
fileChooser = defaultDirectory;
}
fileChooser.browseForOpen("Open");
fileChooser.addEventListener(Event.SELECT, fileOpenSelected);
}
/**
* Called when the user selects the currentFile in the FileOpenPanel control. The method passes
* File object pointing to the selected currentFile, and opens a FileStream object in read mode (with a FileMode
* setting of READ), and modify's the title of the application window based on the filename.
*/
private function fileOpenSelected(event:Event):void
{
currentFile = event.target as File;
stream = new FileStream();
stream.openAsync(currentFile, FileMode.READ);
stream.addEventListener(Event.COMPLETE, fileReadHandler);
stream.addEventListener(IOErrorEvent.IO_ERROR, readIOErrorHandler);
dataChanged = false;
title = "Text Editor - " + currentFile.name;
currentFile.removeEventListener(Event.SELECT, fileOpenSelected);
}
/**
* Called when the stream object has finished reading the data from the currentFile (in the openFile()
* method). This method reads the data as UTF data, converts the system-specific line ending characters
* in the data to the "\n" character, and displays the data in the mainTextField Text component.
*/
private function fileReadHandler(event:Event):void
{
var str:String = stream.readUTFBytes(stream.bytesAvailable);
stream.close();
var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g");
str = str.replace(lineEndPattern, "\n");
mainTextField.text = str;
stream.close();
}
**
* Called when the user clicks the "Save" button. The method sets up the stream object to point to
* the currentFile specified by the currentFile object, with save access. This method converts the "\r" and "\n" characters
* in the mainTextField.text data to the system-specific line ending character, and writes the data to the currentFile.
*/
private function saveFile():void
{
if (currentFile) {
if (stream != null)
{
stream.close();
}
stream = new FileStream();
stream.openAsync(currentFile, FileMode.WRITE);
stream.addEventListener(IOErrorEvent.IO_ERROR, writeIOErrorHandler);
var str:String = mainTextField.text;
str = str.replace(/\r/g, "\n");
str = str.replace(/\n/g, File.lineEnding);
stream.writeUTFBytes(str);
stream.close();
dataChanged = false;
}
else
{
saveAs();
}
}
/**
* Called when the user clicks the "Save As" button. Opens a Save As dialog box, in which the
* user selects a currentFile path. See the FileSavePanel.mxml currentFile.
*/
private function saveAs():void
{
var fileChooser:File;
if (currentFile)
{
fileChooser = currentFile;
}
else
{
fileChooser = defaultDirectory;
}
fileChooser.browseForSave("Save As");
fileChooser.addEventListener(Event.SELECT, saveAsFileSelected);
}
/**
* Called when the user selects the file path in the Save As dialog box. The method passes the selected
* currentFile to the File object and calls the saveFile() method, which saves the currentFile.
*/
private function saveAsFileSelected(event:Event):void
{
currentFile = event.target as File;
title = "Text Editor - " + currentFile.name;
saveFile();
dataChanged = false;
currentFile.removeEventListener(Event.SELECT, saveAsFileSelected);
}
/**
* Called when the user clicks the "New" button. Initializes the state, with an undefined File object and a
* blank text entry field.
*/
private function newFile():void
{
currentFile = undefined;
dataChanged = false;
mainTextField.text = "";
}
/**
* Handles I/O errors that may come about when opening the currentFile.
*/
private function readIOErrorHandler(event:Event):void
{
Alert.show("The specified currentFile cannot be opened.", "Error", Alert.OK, this);
}
/**
* Handles I/O errors that may come about when writing the currentFile.
*/
private function writeIOErrorHandler(event:Event):void
{
Alert.show("The specified currentFile cannot be saved.", "Error", Alert.OK, this);
}
]]>
</mx:Script>
<mx:HBox width="100%">
<mx:Button label="New" id="newBtn" click="newFile()"/>
<mx:Button label="Open" id="openBtn" click="openFile()"/>
<mx:Button label="Save" id="saveBtn" click="saveFile()" enabled="{dataChanged}"/>
<mx:Button label="Save As" id="saveAsBtn" click="saveAs()"/>
</mx:HBox>
<mx:TextArea id="mainTextField" width="100%" height="100%" fontFamily="Courier, _typewriter" change="dataChanged = true;"/>
</mx:WindowedApplication>
尚未测试~~~~~~~~~~~~~~
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
backgroundColor="0x0000FF"
backgroundImage=""
backgroundAlpha="0.75"
title="Text Editor"
applicationComplete="appCompleteHandler()">
<mx:Script>
<![CDATA[
import flash.filesystem.*;
import mx.events.*;
import mx.controls.Alert;
private var currentFile:File; // The currentFile opened (and saved) by the application
private var stream:FileStream = new FileStream(); // The FileStream object used for reading and writing the currentFile
private var defaultDirectory:File; // The default directory
[Bindable] public var dataChanged:Boolean = false; // Whether the text data has changed (and should be saved)
/**
* Called as the event handler for the applicationComplete event of the Application. This method
* sets the position and size of the main window.
*/
private function appCompleteHandler():void
{
defaultDirectory = File.documentsDirectory;
stage.nativeWindow.width = Math.min(800, Capabilities.screenResolutionX - 60);
stage.nativeWindow.height = Capabilities.screenResolutionY - 60;
stage.nativeWindow.visible = true;
}
/**
* Called when the user clicks the Open button. Opens a file chooser dialog box, in which the
* user selects a currentFile.
*/
private function openFile():void
{
var fileChooser:File;
if (currentFile)
{
fileChooser = currentFile;
}
else
{
fileChooser = defaultDirectory;
}
fileChooser.browseForOpen("Open");
fileChooser.addEventListener(Event.SELECT, fileOpenSelected);
}
/**
* Called when the user selects the currentFile in the FileOpenPanel control. The method passes
* File object pointing to the selected currentFile, and opens a FileStream object in read mode (with a FileMode
* setting of READ), and modify's the title of the application window based on the filename.
*/
private function fileOpenSelected(event:Event):void
{
currentFile = event.target as File;
stream = new FileStream();
stream.openAsync(currentFile, FileMode.READ);
stream.addEventListener(Event.COMPLETE, fileReadHandler);
stream.addEventListener(IOErrorEvent.IO_ERROR, readIOErrorHandler);
dataChanged = false;
title = "Text Editor - " + currentFile.name;
currentFile.removeEventListener(Event.SELECT, fileOpenSelected);
}
/**
* Called when the stream object has finished reading the data from the currentFile (in the openFile()
* method). This method reads the data as UTF data, converts the system-specific line ending characters
* in the data to the "\n" character, and displays the data in the mainTextField Text component.
*/
private function fileReadHandler(event:Event):void
{
var str:String = stream.readUTFBytes(stream.bytesAvailable);
stream.close();
var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g");
str = str.replace(lineEndPattern, "\n");
mainTextField.text = str;
stream.close();
}
**
* Called when the user clicks the "Save" button. The method sets up the stream object to point to
* the currentFile specified by the currentFile object, with save access. This method converts the "\r" and "\n" characters
* in the mainTextField.text data to the system-specific line ending character, and writes the data to the currentFile.
*/
private function saveFile():void
{
if (currentFile) {
if (stream != null)
{
stream.close();
}
stream = new FileStream();
stream.openAsync(currentFile, FileMode.WRITE);
stream.addEventListener(IOErrorEvent.IO_ERROR, writeIOErrorHandler);
var str:String = mainTextField.text;
str = str.replace(/\r/g, "\n");
str = str.replace(/\n/g, File.lineEnding);
stream.writeUTFBytes(str);
stream.close();
dataChanged = false;
}
else
{
saveAs();
}
}
/**
* Called when the user clicks the "Save As" button. Opens a Save As dialog box, in which the
* user selects a currentFile path. See the FileSavePanel.mxml currentFile.
*/
private function saveAs():void
{
var fileChooser:File;
if (currentFile)
{
fileChooser = currentFile;
}
else
{
fileChooser = defaultDirectory;
}
fileChooser.browseForSave("Save As");
fileChooser.addEventListener(Event.SELECT, saveAsFileSelected);
}
/**
* Called when the user selects the file path in the Save As dialog box. The method passes the selected
* currentFile to the File object and calls the saveFile() method, which saves the currentFile.
*/
private function saveAsFileSelected(event:Event):void
{
currentFile = event.target as File;
title = "Text Editor - " + currentFile.name;
saveFile();
dataChanged = false;
currentFile.removeEventListener(Event.SELECT, saveAsFileSelected);
}
/**
* Called when the user clicks the "New" button. Initializes the state, with an undefined File object and a
* blank text entry field.
*/
private function newFile():void
{
currentFile = undefined;
dataChanged = false;
mainTextField.text = "";
}
/**
* Handles I/O errors that may come about when opening the currentFile.
*/
private function readIOErrorHandler(event:Event):void
{
Alert.show("The specified currentFile cannot be opened.", "Error", Alert.OK, this);
}
/**
* Handles I/O errors that may come about when writing the currentFile.
*/
private function writeIOErrorHandler(event:Event):void
{
Alert.show("The specified currentFile cannot be saved.", "Error", Alert.OK, this);
}
]]>
</mx:Script>
<mx:HBox width="100%">
<mx:Button label="New" id="newBtn" click="newFile()"/>
<mx:Button label="Open" id="openBtn" click="openFile()"/>
<mx:Button label="Save" id="saveBtn" click="saveFile()" enabled="{dataChanged}"/>
<mx:Button label="Save As" id="saveAsBtn" click="saveAs()"/>
</mx:HBox>
<mx:TextArea id="mainTextField" width="100%" height="100%" fontFamily="Courier, _typewriter" change="dataChanged = true;"/>
</mx:WindowedApplication>
尚未测试~~~~~~~~~~~~~~
发表评论
-
在Flex中使用CSS
2008-12-31 11:05 1188转自:http://www.scriptlover.com/p ... -
数据筛选
2008-12-10 13:50 1006<?xml version="1.0" ... -
判断VideoDisplay组件当前的播放状态。播放|缓冲。
2008-12-08 18:08 3511转自:http://www.cnblogs.com/xxcai ... -
Flex动画效果与变换(三)
2008-12-08 18:01 1451转自:http://xinsync.xju.edu.cn/in ... -
Flex动画效果与变换(二)
2008-12-08 18:00 5457转自:http://xinsync.xju.edu ... -
Flex动画效果与变换
2008-12-08 17:59 3696本文来源于 冰山上的播客 http://xinsync.xju ... -
Flex中将字符串数组转化为对象数组的例子
2008-12-05 09:56 2650转自:http://elanso.com/ArticleMod ... -
Adobe AIR右键菜单和系统托盘(Tray)功能以及实现方法
2008-12-02 10:56 1659转自:阿贤 右键菜单: var mainMenu:Nat ... -
开发AIR桌面应用程序
2008-12-02 10:55 3772好久没碰FLEX了,也好久 ... -
关于Style和CSS
2008-10-28 19:45 1364CSSStyleDeclaration 类表示一组 CSS 样 ... -
如何创建简单的Flex模块(module)的例子
2008-08-25 11:08 1138转自:http://blog.minidx.com/2008/ ... -
关于MenuBar
2008-08-23 19:49 1308~~~~~~~~~~~~~~~~~~~~~~~~写给 ... -
AIR打开本地文件
2008-08-23 11:05 3836示例: <?xml version="1.0& ... -
Flex中对文本实现高亮显示
2008-08-22 10:03 2862转自http://blog.minidx.com/20 ... -
关于XMLListCollection
2008-08-21 19:33 1829public var de:XMLList= <&g ... -
RichTextEditor
2008-08-18 21:44 1188前几天做一个练习的时候,发现一个奇怪的问题,使用PopUpMa ... -
Flex的RichTextEditor控件中如何利用textAreaStyleName和letter
2008-08-16 21:11 1236转自http://blog.minidx.com/2008/0 ... -
运行时加裁FLEXSKIN
2008-08-16 20:48 912本文来源于 冰山上的播客 http://xinsync.xju ... -
关于Canvas 的疑问
2008-08-16 19:05 903自定义的组件:CustomRichTextEditor.mxm ... -
自己做的一个关于Module的例子
2008-08-15 22:09 968主程序customModule.mxml <?xml ...
相关推荐
标题"网页一拖就保存文本内容"所暗示的技术实现,主要是通过浏览器扩展或者特定软件工具来实现的。这种技术允许用户通过简单的操作,如鼠标拖拽,快速抓取网页上的文本并进行存储。 首先,我们来理解一下这个过程的...
1. **分类管理**:用户可以根据内容类型或项目创建不同的文件夹或标签,将文本信息进行分类存储,便于日后快速定位所需内容。 2. **全文搜索**:内置的搜索功能使得用户可以通过关键词快速找到保存的文本,节省了...
如果你需要追加文本而不是覆盖原有内容,可以使用`StreamWriter`的另一个构造函数,传入`true`作为第二个参数,表示以追加模式打开文件: ```csharp StreamWriter writer = new StreamWriter(filePath, true); ``` ...
### Java文本区内容保存为文件的知识点解析 #### 一、概述 在Java开发中,经常需要处理用户界面(UI)中的数据操作,如读取文本框中的内容并将其保存到文件中。本案例展示了如何使用Swing库创建一个简单的应用程序,...
在IT行业中,文本内容的管理和保存是一项基础但至关重要的任务。尤其在大数据时代,高效地组织和分类文本信息能够极大地提升工作效率。"分类保存文本内容"这个主题涉及到软件技术的应用,它强调了如何通过特定的工具...
- **定义保存逻辑**:在事件处理函数中调用`fileRef.save`方法,传递需要保存的文本内容作为参数。 ### 五、注意事项 - 在实际应用中,还需要考虑权限问题。默认情况下,Flash Player可能不允许应用程序访问用户的...
1. 创建一个Blob对象,传入需要保存的内容和指定的内容类型(如果是要保存文本文件,则内容类型为"text/plain")。 2. 使用URL.createObjectURL方法创建一个指向该Blob对象的URL,这个URL可以用来指定元素的href...
3. **图片的获取与保存**:当富文本编辑器中包含来自网络的图片时,为了确保最终生成的内容能够正常显示这些图片,通常需要将这些网络图片下载并保存到服务器的本地文件系统上,并更新 HTML 中的图片源地址。...
values.put("content", "文本内容"); SQLiteDatabase db = openOrCreateDatabase("TextDB", MODE_PRIVATE, null); db.insert("TextTable", null, values); ``` 4. **ContentProvider**: 对于跨应用数据共享,...
长文本是指一段较长的文本内容,通常用于存储大段的文字信息。 读取长文本的方法是通过调用函数模块“READ_TEXT”来实现的。该函数模块将长文本数据读取到内存中,以便进行后续处理。读取长文本的过程可以分为以下...
在这个过程中,我们经常需要将网页上的文本内容保存下来,以便后续查看或分析。以下是一些关于如何有效保存网页文本的知识点: 1. **浏览器内置功能**:大多数现代浏览器(如Chrome、Firefox、Safari)都提供了内置...
在C# Winform开发中,有时我们需要处理一些与文件操作相关的任务,比如发票信息的修改、文本内容的替换、文件名的更改以及文件的另存和保存。这些功能在日常的业务系统中非常常见,特别是在财务软件或者文档管理软件...
它有一个`Text`属性,可以读取或设置文本框内的文本内容。例如,如果你有一个名为`txtInput`的文本框,你可以通过`txtInput.Text`获取用户输入的内容。 2. **保存到TXT文件**: 要将文本框的内容保存到TXT文件,首先...
python实现文本内容按行转换成excel # 读取文件内容 def read(file): list=[] fo = open(file, "r") for line in fo: strinfo=re.compile(reStr) line = strinfo.sub('',line) # print(line) # 将字符串中=用...
5. **遍历ListBox并写入数据**:通过`for`循环遍历`ListBox.Items`集合,将每一项的文本内容写入到文本文件中。`WriteLine`方法会在每行末尾添加换行符。 ```csharp int iCount = lst.Items.Count - 1; for (int i ...
2、可以支持文本替换,就是说,只要匹配其中的内容,就可以实现一键将原本的文本内容或者节点的内容,替换成需要替换的内容 可扩展的功能: 1、可以修改代码,将XML文件,替换成txt文件,或者其余类型的文件,都可以...
根据给定文件信息,我们将详细介绍基于串口屏LUA脚本的文本保存功能V1.0。本文档涵盖了在设备掉电状态下如何保存数据的技术细节,以及如何通过用户界面输入和操作数据,确保数据在设备断电后仍能被保存和重新读取。 ...
该程序的核心功能可能是通过读取用户输入的行号或者指定条件,从文本文件中定位到相应的行,并将其内容展示或保存。这涉及到文件流的读取、字符串的分割、行号的计算等技术。例如,程序可能会先打开文本文件,然后...
`saveWordAsText.m` 是一个MATLAB函数,它的功能是读取Word文档并将其内容保存为文本文件。这个功能通常由`docx2txt`或者`comms`工具箱中的COM接口来实现。MATLAB通过这些接口与Word应用程序进行交互,读取文档内容...
保存wireshark抓包的数据为txt文本,然后更改cpp文件中的文件路劲并运行