Tag removal AIR application for Blog posting

I was really fed up of editing my posts all the time to add “& lt” and “& gt” instead of < and > so I thought to make an air application to do just that.
So here’s the code for the tag removal tool:

<mx:Script&gt
<![CDATA[

import mx.controls.*;
import flash.filesystem.*;
import flash.events.Event;
import flash.net.FileFilter;
import flash.events.*

public var fileToOpen:File = new File();

public var fileData:String;
public var local:String=”default”;

public function opens():void
{

fileToOpen.browseForOpen(“Open”);

fileToOpen.addEventListener(Event.SELECT, fileSelected);

}

public function fileSelected(event:Event):void
{
var stream:FileStream = new FileStream();
Alert.show(String(fileToOpen.url));
stream.open(event.target as File, FileMode.READ);

fileData= stream.readUTFBytes(stream.bytesAvailable);
stream.close();

}

private function setFocusOnStart(event:Event):void
{
stage.focus=InteractiveObject(source);
}

public function localStr():String
{
if(local==”default”)
{
return source.text
}
else
{return fileData}
}

public function convertTxt(str1:String):void
{

var reg1:RegExp=/(&gt)/g;
var reg2:RegExp=/(<)/g;

str1=str1.replace(reg1,”&gt”);
//Alert.show(str1);
str1=str1.replace(reg2,”<“);

result.enabled=true;
result.text=str1;

}

function copyText(e:MouseEvent):void{

System.setClipboard(result.text);
trace(“copied: “+result.text);
Alert.show(“Text Copied!”);
}
]]&gt
</mx:Script&gt

<mx:TextArea id=”source” selectable=”true” wordWrap=”true” editable=”true” x=”76″ y=”141″ width=”252″ height=”200″ toolTip=”Source…” addedToStage=”setFocusOnStart(event)”/&gt

<mx:Button label=”Convert” fontSize=”13″ fontWeight=”bold” x=”310″ y=”91″ click=”{convertTxt(localStr());}” color=”#00BCFA” borderColor=”#00BCFA”/&gt

<mx:TextArea id=”result” x=”374″ y=”141″ width=”252″ height=”200″ editable=”true” wordWrap=”true” selectable=”true” toolTip=”Result” enabled=”false”/&gt

<mx:Label y=”11″ text=”String Converter” fontSize=”19″ fontWeight=”bold” color=”#00BCFA” fontStyle=”normal” textAlign=”center” letterSpacing=”1″ x=”244″/&gt

<mx:VRule x=”351″ y=”141″ height=”200″/&gt

<mx:Button x=”467″ y=”102″ label=”Copy to Clipboard” width=”159″ height=”31″ click=”copyText(event)” icon=”@Embed(source=’icons/copy-doc28.png’)”/&gt

<mx:Button x=”512″ y=”61″ label=”Clear Text” borderColor=”#C00000″ color=”#C00000″ click=”{local=’default’;source.text=”;source.enabled=true;result.text=”;}” icon=”@Embed(source=’icons/minus-white28.png’)”/&gt

<mx:Button x=”76″ y=”105″ label=”Browse…” click=”{local=’1′;opens();source.text=’\n’+’FILE SELECTED’;source.enabled=false;}” icon=”@Embed(source=’icons/folder28.png’)”/&gt

Facebooktwittergoogle_pluspinterestlinkedin
linkedin
Bookmark the permalink.

One Response to Tag removal AIR application for Blog posting

  1. Thanks a lot for the post, I really learned a lot from it. Really quality content on this site. Always looking forward to new post.

Leave a Reply

Your email address will not be published. Required fields are marked *