private function calcDistance(nX1:Number, nY1:Number, nX2:Number, nY2:Number):Number {
var dist:Number;
var dx:Number;
var dy:Number;
dx = nX2-nX1;
dy = nY2-nY1;
dist = Math.sqrt(dx*dx + dy*dy);
return dist;
}

private function calcDistance(nX1:Number, nY1:Number, nX2:Number, nY2:Number):Number {
var dist:Number;
var dx:Number;
var dy:Number;
dx = nX2-nX1;
dy = nY2-nY1;
dist = Math.sqrt(dx*dx + dy*dy);
return dist;
}
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
public class ImageLoader extends Sprite {
private var _imageLoader:Loader;
private var _iWidth:int;
private var _iHeight:int;
private var _nPercentLoaded:Number; // a value of 0~100
public function ImageLoader( sUrl:String, width:int, height:int ) {
_imageLoader = new Loader();
_imageLoader.load(new URLRequest( sUrl )); _iWidth = width; _iHeight = height;
_imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
_imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
_imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, catch_function);
}
private function onLoadProgress(e:ProgressEvent):void {
_nPercentLoaded = e.bytesLoaded / e.bytesTotal;
_nPercentLoaded = Math.round(_nPercentLoaded * 100);
}
private function onLoadComplete(e:Event):void {
addChild( _imageLoader );
_imageLoader.width = _iWidth;
_imageLoader.height = _iHeight;
}
private function catch_function(e:IOErrorEvent):void {
// couldn’t find the file
}
}
}
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class Scrubbar extends MovieClip {
private static const PAUSE_STATE:int = 1;
private static const PLAY_STATE:int = 2;
private var _mcPlay:MovieClip;
private var _mcScroller:MovieClip;
private var _mcScrollArea:MovieClip;
private var _rScrollTrack:Rectangle; // the scroller track (limits the movement)
private var _mySwf:SwfLoader;
public function Scrubbar() {
init();
initListeners();
}
/* GETTERS ***********************************************************/
public function getScrollLocation():Number { // returns a value 0~1
return _mcScroller.x / (_mcScrollArea.width-_mcScroller.width);
}
/* SETTERS ***********************************************************/
public function setScrollerLocation(nLocation:Number):void { // nLocation is a value 0~1
_mcScroller.x = nLocation * (_mcScrollArea.width – _mcScroller.width);
}
/* INIT **************************************************************/
private function init():void {
_mcPlay = getChildByName(“mcPlay”) as MovieClip;
_mcScroller = getChildByName(“mcScroller”) as MovieClip;
_mcScrollArea = getChildByName(“mcScrollArea”) as MovieClip;
_rScrollTrack = new Rectangle(0, 0, _mcScrollArea.width-_mcScroller.width, 0); // scroll track
_mcPlay.buttonMode = true;
_mcScroller.buttonMode = true;
_mcPlay.gotoAndStop(PAUSE_STATE);
}
private function initListeners():void {
_mcPlay.addEventListener(MouseEvent.CLICK, onPlay);
_mcScroller.addEventListener(MouseEvent.MOUSE_DOWN, onScroll);
_mcScrollArea.addEventListener(MouseEvent.MOUSE_DOWN, onScrollAreaClick);
}
/* CONTROL ***********************************************************/
private function onPlay(e:MouseEvent=null):void {
if (_mcPlay.currentFrame == PAUSE_STATE) {
_mcPlay.gotoAndStop(PLAY_STATE); // play
}
else if (_mcPlay.currentFrame == PLAY_STATE) {
_mcPlay.gotoAndStop(PAUSE_STATE); // pause
}
}
private function onScroll(e:MouseEvent=null):void {
_mcScroller.startDrag(false, _rScrollTrack); // move the scrollbar
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);
}
private function onMouseMoveHandler(e:MouseEvent):void {
trace( “getScrollLocation(): “+getScrollLocation() );
}
private function onMouseUpHandler(e:MouseEvent):void {
_mcScroller.stopDrag();
trace( “getScrollLocation(): “+getScrollLocation() );
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUpHandler);
}
private function onScrollAreaClick(e:MouseEvent):void {
_mcScroller.x = getScrollAreaClickLocation();
trace( “getScrollLocation(): “+getScrollLocation() );
onScroll();
}
private function getScrollAreaClickLocation():Number { // returns a value 0~1
return mouseX – (_mcScroller.width / 2);
}
}
}
private function updateWidthHeight():void {
var nMaxAreaWidth:Number = 800;
var nMaxAreaHeight:Number = 490;
var nMaxAreaRatio:Number = nMaxAreaWidth / nMaxAreaHeight;
var nW:Number;
var nH:Number;
nW = _player.getEpisodeWidth(); //_loader.stage.stageWidth; //_loader.content.width; // _mcSwf.width;
nH = _player.getEpisodeHeight(); //_loader.stage.stageHeight; //_loader.content.height; // _mcSwf.height;
var nWHRatio:Number = nW / nH;
// trace(“nW: ” + nW + “, nH: ” + nH);
// trace(“nMaxAreaRatio: “+nMaxAreaRatio+”, nWHRatio: “+nWHRatio);
/*
if (nMaxAreaRatio > nWHRatio) {
_mcSwf.height = nMaxAreaHeight;
_mcSwf.width = (nW*nMaxAreaHeight)/nH;
_mcSwf.x = (nMaxAreaWidth-_mcSwf.width)/2;
}
else if (nMaxAreaRatio < nWHRatio) {
_mcSwf.width = nMaxAreaWidth;
_mcSwf.height = (nH*nMaxAreaWidth)/nW;
_mcSwf.y = (nMaxAreaHeight-_mcSwf.height)/2;
}
/**/
if (_bGame) {
_mcSwf.x = (nMaxAreaWidth – nW) / 2;
_mcSwf.y = 0; // (nMaxAreaHeight – nH) / 2;
}
else {
_mcSwf.x = (nMaxAreaWidth-_mcSwf.width)/2;
_mcSwf.y = (nMaxAreaHeight-_mcSwf.height)/2;
}
/*
trace(“_mcSwf.width: “+_mcSwf.width+”, _mcSwf.height: “+_mcSwf.height);
/**/
}
function shuffle(a:Array):Array {
var len:int = a.length;
var temp:*;
for (var i:int = len-1; i>0; i–) {
var rand:int = Math.floor(Math.random() * len);
temp = a[i];
a[i] = a[rand];
a[rand] = temp;
}
return a;
}
usage:
var testArray:Array = new Array(“a”, “b”, “c”, “d”, “e”);
trace (shuffle(testArray));
package Classes {
import flash.events.EventDispatcher;
import flash.events.Event;
public class EventDispatcherExtension extends EventDispatcher {
private static var _instance:EventDispatcherExtension;
public static const PORTFOLIO:String = “portfolio”;
public static const CONTACT:String = “contact”;
public static const BOOKMARKS:String = “bookmarks”;
public var _aPortfolio:Array = new Array();
public var _aContact:Array = new Array();
public var _aBookmarks:Array = new Array();
public function EventDispatcherExtension() {
if (_instance) {
throw new Error( “Singleton pattern can only be accessed through Singleton.getInstance()” );
}
}
public static function getInstance():EventDispatcherExtension {
if(!_instance) _instance = new EventDispatcherExtension();
return _instance;
}
}
}
// usage
EventDispatcherExtension.getInstance().addEventListener(EventDispatcherExtension.PORTFOLIO, savePortfolio);
EventDispatcherExtension.getInstance().addEventListener(EventDispatcherExtension.CONTACT, saveContact);
EventDispatcherExtension.getInstance().addEventListener(EventDispatcherExtension.BOOKMARKS, saveBookmarks);
EventDispatcherExtension.getInstance()._aPortfolio = this.aLinkList;
EventDispatcherExtension.getInstance().dispatchEvent(new Event(EventDispatcherExtension.PORTFOLIO));
trace( EventDispatcherExtension.getInstance()._aPortfolio );
function removeDuplicate(a:Array):void {
for (var i:uint = 0; i < a.length – 1; i++) {
for (var j:uint = i + 1; j < a.length; j++) {
if (a[i] === a[j]) {
a.splice(j, 1);
j–;
}
}
}
}
function searchArray(a:Array, v:int):int {
for (var i:int=0; i<a.length; i++) {
if (v == a[i]) {
return i;
}
}
return -1;
};
<?php
$host = “localhost”; //hostname is usually localhost by default
$user = “”; //insert the name of the user here
$pass = “”; //insert the password here
$database = “”; //insert name of database wherein table was exported
$table = “”; //insert the name of the table
// Connects to the database server
// outputs an error message is it was unsuccessful
$dbcnx = @mysql_connect($host,$user, $pass);
if (!$dbcnx) {
echo( “<P>Unable to connect to the database server at this time.</P>” );
exit();
}
// Selects the specified database
if (! @mysql_select_db($database) ) {
echo( “Unable to find database” );
exit();
}
echo(“The following is the top 3 rows from the table: <p>”);
// Request data from the table
$result = mysql_query(“SELECT * FROM {$table}”);
if (!$result) {
echo(“<P>Error performing query: mysql_error() </P>”);
exit();
}
// Display the first three records
for($x=0; $x<3; $x++) {
$row = mysql_fetch_array($result);
echo “id : {$row["id"]} <br>”;
echo “message : {$row["message"]} <br>”;
echo “date : {$row["date"]} <br>”;
echo “time : {$row["time"]} <br>”;
echo “ip : {$row["ip"]} <br><br>”;
}
?>
CAnchor.as
package {
import flash.display.MovieClip;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.display.Stage;
import flash.events.Event;
public class CAnchor {
private var _oRender:Object;
private var _aAnchorList:Array = new Array();
private var _aAnchorListWidth:Array = new Array();
private var _aAnchorListHeight:Array = new Array();
private var _aAnchorHorzList:Array = new Array();
private var _aAnchorVertList:Array = new Array();
private var _aAnchorHorzOffsetList:Array = new Array();
private var _aAnchorVertOffsetList:Array = new Array();
private var _aAnchorRealTimeRefresh:Array = new Array();
public function CAnchor(oRender:Object) {
_oRender = oRender;
initStage();
}
// h:horzPos, v:vertPos, ho:horzOffset, vo:vertOffset, mw:manualWidth, mh:manualHeight, r:realTimeWidth&HeightRefresh
public function add(mc:MovieClip, h:int, v:int, ho:Number=0, vo:Number=0, mw:Number=0, mh:Number=0, r:Boolean=false):void {
_aAnchorList.push(mc);
if(mw == 0) { _aAnchorListWidth.push(mc.width); } else { _aAnchorListWidth.push(mw); }
if(mh == 0) { _aAnchorListHeight.push(mc.height); } else { _aAnchorListHeight.push(mh); }
_aAnchorHorzList.push(h); // -1:left, 0:center, 1:right
_aAnchorVertList.push(v); // -1:top, 0:center, 1:bottom
_aAnchorHorzOffsetList.push(ho);
_aAnchorVertOffsetList.push(vo);
_aAnchorRealTimeRefresh.push(r);
onStageResize();
}
public function refresh():void {
onStageResize();
}
public function cleanUp():void {
_oRender.stage.removeEventListener(Event.RESIZE, onStageResize);
}
private function initStage():void {
_oRender.stage.frameRate = 60;
_oRender.stage.showDefaultContextMenu = false;
_oRender.stage.scaleMode = StageScaleMode.NO_SCALE;
_oRender.stage.align = StageAlign.TOP_LEFT;
_oRender.stage.addEventListener(Event.RESIZE, onStageResize);
}
private function onStageResize(… eventArray:Array):void {
var i:uint = 0;
for(i=0; i<_aAnchorList.length; i++) {
// real time width & height check
if(_aAnchorRealTimeRefresh[i] == true) {
_aAnchorListWidth[i] = _aAnchorList[i].width;
_aAnchorListHeight[i] = _aAnchorList[i].height;
}
// horz
if(_aAnchorHorzList[i] == -1) { // left
_aAnchorList[i].x = 0 + _aAnchorHorzOffsetList[i];
}
else if(_aAnchorHorzList[i] == 0) { // center
_aAnchorList[i].x = int(_oRender.stage.stageWidth/2 – _aAnchorListWidth[i]/2) + _aAnchorHorzOffsetList[i];
}
else if(_aAnchorHorzList[i] == 1) { // right
_aAnchorList[i].x = int(_oRender.stage.stageWidth – _aAnchorListWidth[i]) + _aAnchorHorzOffsetList[i];
}
// vert
if(_aAnchorVertList[i] == -1) { // top
_aAnchorList[i].y = 0 + _aAnchorVertOffsetList[i];
}
else if(_aAnchorVertList[i] == 0) { // center
_aAnchorList[i].y = int(_oRender.stage.stageHeight/2 – _aAnchorListHeight[i]/2) + _aAnchorVertOffsetList[i];
}
else if(_aAnchorVertList[i] == 1) { // bottom
_aAnchorList[i].y = int(_oRender.stage.stageHeight – _aAnchorListHeight[i]) + _aAnchorVertOffsetList[i];
}
}
}
}
}
// usage
import CAnchor;
var myAnchor:CAnchor = new CAnchor(this);
myAnchor.add(mc, 0, 0, 0);