Posted on

Encode & Decode on CS4 AS3

This is an example showing how to use the module Base64 to encode and decode text strings under CS4 flash 10.

4 things need to do:

1. set preference for loading external class files by clicking <edit><reference><actionscript><actionscript 3.0> select the chosen on class folder to start with.

2. open a fla file. In this program you will to prepare a “textfield” and 2 “Movieclips” as buttons.

coding:

import com.dynamicflash.util.Base64;

var sample = new Textfield();

sample.width = 500;

sample.height = 200;

addChild(sample);

sample.text = “This tutorial will allow you to learn to create custom Flash Components using Actionscript 3.0. I have opted an image gallery component where we would show thumbnails of various images and user could see respective enlarged image by clicking any of the thumbnail. I have used FlickR image search to show various images using this component.”;
var teststring:String
function en(e:MouseEvent){
teststring:String = Base64.encode(sample.text);
sample.text = teststring
}
function de(e:MouseEvent){
teststring = Base64.decode(sample.text);
sample.text = teststring;
}
t1.addEventListener(MouseEvent.MOUSE_UP,en);
t2.addEventListener(MouseEvent.MOUSE_UP,de);
Advertisements

About Kemo

I am just an ordinary person in the garden.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s