var data:String = "< \"Hello World!\" />";
trace("data= "+data);
var escaped:String = escape(data);
trace("escaped= "+escaped);
var pattern:RegExp = /\+/g;
var unescaped:String = unescape(data).replace(pattern, " ");
trace("unescaped= "+unescaped);
/*
Output ++
data= < "Hello World!" />
escaped= %3C%20%22Hello%20World%21%22%20/%3E
unescaped= < "Hello World!" />
*/
AS3 Escape / Unescape Method
August 13th, 2010Call of Duty: Black Ops CountDown Timer iPhone Web Applications
August 10th, 2010Just watched the lastest COD: BlackOps multiplayer trailer, can’t wait for this looks amazing. I am going to setup a countdown timer for BlackOps like I did for MW2 was very popular and allot of people used and enjoyed it
This time around going to make an iPhone application too!
OpenSSL Install Guide for centOS 5 Linux
June 13th, 2010AS3 Loading Images Externally
May 11th, 2010
var imgPath:String="http://93.97.40.201/snapshot/snaps/19cdeb13f7c46bfafa75beeca361c916.png";
var _loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
_loader.load(new URLRequest(imgPath));
function onProgress(e:ProgressEvent):void {
var _progress:String="Loading "+e.bytesLoaded+" of "+e.bytesTotal;
var _percent:Number=Math.round(100*e.bytesLoaded/e.bytesTotal);
trace(_percent + "%");
}
function onComplete(e : Event):void {
var loaderInfo:LoaderInfo=e.target as LoaderInfo;
var displayObject:DisplayObject=loaderInfo.content;
stage.addChild(displayObject);
trace("Loading Complete!");
}
AS3 Video Code Snippets
May 6th, 2010Few handy code Snippets for when using AS3 & Video.
This can be used with FLVPlayBack Component (just remove the vars/addChilds etc):
import fl.video.*;
var myVideo:FLVPlayback = new FLVPlayback();
myVideo.source = "video.flv";
myVideo.skin = "SkinOverPlayStopSeekFullVol.swf";
myVideo.addEventListener(VideoEvent.COMPLETE, completePlay);
function completePlay(e:VideoEvent):void {
myVideo.alpha=0.2;
}
addChild(myVideo);
Net Stream Version:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("video.flv");
function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore error
}
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
stopBtn.addEventListener(MouseEvent.CLICK, stopHandler);
togglePauseBtn.addEventListener(MouseEvent.CLICK, togglePauseHandler);
function pauseHandler(event:MouseEvent):void {
ns.pause();
}
function playHandler(event:MouseEvent):void {
ns.resume();
}
function stopHandler(event:MouseEvent):void {
// Pause the stream and move the playhead back to
// the beginning of the stream.
ns.pause();
ns.seek(0);
}
function togglePauseHandler(event:MouseEvent):void {
ns.togglePause();
}
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
function statusHandler(event:NetStatusEvent):void {
trace(event.info.code);
/*
NetStream.Play.Start
NetStream.Buffer.Empty
NetStream.Buffer.Full
NetStream.Buffer.Empty
NetStream.Buffer.Full
NetStream.Buffer.Empty
NetStream.Buffer.Full
NetStream.Buffer.Flush
NetStream.Play.Stop
NetStream.Buffer.Empty
NetStream.Buffer.Flush
*/
switch (event.info.code) {
case "NetStream.Play.Start" :
trace("Start [" + ns.time.toFixed(3) + " seconds]");
break;
case "NetStream.Play.Stop" :
trace("Stop [" + ns.time.toFixed(3) + " seconds]");
break;
}
}
Python MySQLdb install guide for cPanel/centOS
April 26th, 2010Guide to getting MySQLdb installed for Python/MySQL to work on cPanel(11)/centOS(5.4). First you need to check if you need any of these installed (I didn’t).
yum install python-devel yum install MySQL-devel yum install zlib-devel yum install openssl-devel
This one I did need was, python-setuptools this basically allows to; Download, build, install, upgrade, and uninstall Python packages - as it says on the Python website.
yum install python-setuptools.noarch
Ok lets get started. run this from your cmd line/bash.
wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz && tar xzf MySQL-python-1.2.3c1.tar.gz && cd MySQL-python-1.2.3c1 && python setup.py build && sudo python setup.py install
That’s it your done!
BTW, this is what I am running environment wise.
cPanel 11.25.0-R44718 - WHM 11.25.0 - X 3.9 CENTOS 5.4 i686 standard
AS3/AS2 Dynamic Gradient Mask Effect
April 11th, 2010maskMovieClip = Instance name of your mask movie clip this is where you add the gradient/radial colour/type.
movieClip = Instance name of your movie clip you want masking.
AS3
movieClip.mask = maskMovieClip; maskMovieClip.cacheAsBitmap = true; movieClip.cacheAsBitmap = true;
AS2
movieClip.cacheAsBitmap = true;
maskMovieClip.cacheAsBitmap = true;
mask.cacheAsBitmap = true;
movieClip.setMask("maskMovieClip");
iPhone SDK 3.3 on OSX 10.5.5
March 5th, 2010Can’t get? iPhone SDK 3.3 with xCode 2.1.4 running inside Mac OSX 10.5.5, I have it running on VMware with Mac OSX 10.5.5 here’s how:
Download iPhone SDK 3.3 with xCode 2.1.4 from Apple here.
Then do the following:
Edit the version number from 10.5.5 to 10.5.7 inside the “SystemInfo.plist” file which is located here:
/System/Library/Core Services/SystemInfo.plist
Now you can install the latest iPhone SDK without any crappy messages coming up















