Asi quedo todo, a mi parecer bastante bien
Código ActionScript :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="758" height="500" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FAFAFA, #626060]">
<mx:Form width="418.5" height="264" x="30.5" y="24">
<mx:FormHeading label="Encryption Application" color="#06BFE7" width="375"/>
<mx:FormItem label="Algorithm" width="346" height="106">
<mx:RadioButton id="caesarBtn" label="Caesar Shift" selected="true"/>
<mx:RadioButton id="railBtn" label="Rail Fence" />
<mx:NumericStepper value="3" id="key" minimum="0" maximum="50"/>
</mx:FormItem>
<mx:FormItem label="Plain Text">
<mx:TextInput id="plaintext" width="272"/>
</mx:FormItem>
<mx:Button icon="@Embed(source='CANDADO.JPG')" click="myText.text=algorithm(railBtn.selected)" fillAlphas="[1.0, 1.0]" fillColors="[#F8F3F3, #E0DBDB]"/>
<mx:FormItem label="encryption">
<mx:TextArea id="myText" text="" width="272" height="22"/>
</mx:FormItem>
</mx:Form>
<mx:Script>
<![CDATA[
//SHIFT CIPHER
private function getString(sentence:String, shift:Number):String{
var s1:String = sentence;
//var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
var alphabet:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (var i:int = 0; i< s1.length; i++) {
var c:Array=new Array();
c[0]=s1.charAt(i);
var c1:String;
if(c[0]!=" "){
var x:int= alphabet.indexOf(c[0]);
x=(x+shift)%26;
c1=alphabet.charAt(x);}
else
c1=" ";
s1 = s1.substring(0,i)+new String(c1)+ s1.substring(i+1);
}
return s1;
}
//RAIL FENCE
private function railCipher(word:String, rows:Number, b:Boolean):String{
var s2:String="";
for (var y:int=0; y<word.length; y++)
{
if (word.charAt(y)!=" ")
s2 += word.charAt(y);
//now i have a String without spaces
}
var matrix:Array=new Array()
for (var k:int=0;k<s2.length;k++){
var j:int=k/rows;
var i:int=k%rows;
if (matrix[i]==null){
matrix[i]=new Array()
}
matrix[i][j]=s2.charAt(k);
}
var text:String="";
for (i=0;i<matrix.length;i++){
text+=matrix[i].join(" ")+"\n";
}
var text2:String="";
for (i=0;i<matrix.length;i++){
text2+=matrix[i].join("");
}
if(b!=false)
return text2;
else
return text;
}
//call depend the algorithm selected
private function algorithm(Caesar:Boolean):String
{
var encryption:String;
if (caesarBtn.selected)
encryption=getString(plaintext.text, key.value);
else
encryption=railCipher(plaintext.text, key.value, true);
return encryption;
}
//Information about Algorithm
private function inforText(Caesar:Boolean):String
{
var textC:String;
if(caesarBtn.selected){
schema.visible=false;
texto.visible=false;
textC="The action of a Caesar cipher is to replace each plaintext letter with one a fixed number of places down the alphabet. This example is with a shift of three, so that a B in the plaintext becomes E in the ciphertext.";
}
else{
texto.visible=true;
schema.visible=true;
textC="In the rail fence cipher, the plaintext is written downwards on successive rails of an imaginary fence, starting a new column when the bottom is reached. The message is then read off in rows.";
}return textC;
}
]]>
</mx:Script>
<mx:TextArea x="30" y="312" width="364.5" height="111" text="{inforText(caesarBtn.selected)}" editable="false"/>
<mx:Text x="30" y="296" width="109" text="Information:"/>
<mx:TextArea width="106.5" height="93" id="schema" visible="false" text="{railCipher(plaintext.text, key.value, false)}" editable="false" x="476" y="178"/>
<mx:Label x="476" y="162" text="Schema Rail Fence" id="texto" visible="false" width="118.5"/>
</mx:Application>