diff --git a/.actionScriptProperties b/.actionScriptProperties new file mode 100644 index 0000000..921609e --- /dev/null +++ b/.actionScriptProperties @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/.flexProperties b/.flexProperties new file mode 100644 index 0000000..eb94363 --- /dev/null +++ b/.flexProperties @@ -0,0 +1,2 @@ + + diff --git a/.project b/.project new file mode 100644 index 0000000..4400430 --- /dev/null +++ b/.project @@ -0,0 +1,24 @@ + + + AIR-TUve + + + + + + com.adobe.flexbuilder.project.flexbuilder + + + + + com.adobe.flexbuilder.apollo.apollobuilder + + + + + + com.adobe.flexbuilder.apollo.apollonature + com.adobe.flexbuilder.project.flexnature + com.adobe.flexbuilder.project.actionscriptnature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..65d1289 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Wed Dec 05 10:38:25 EST 2007 +eclipse.preferences.version=1 +encoding/=utf-8 diff --git a/src/Carousel.as b/src/Carousel.as new file mode 100644 index 0000000..7047746 --- /dev/null +++ b/src/Carousel.as @@ -0,0 +1,182 @@ +package { + import flash.geom.Point; + +// import mx.core.Application; + import mx.core.UIComponent; + import mx.effects.Move; + import mx.effects.Parallel; + import mx.effects.Resize; + import mx.controls.Alert; + import flash.events.MouseEvent; + import mx.events.EffectEvent; + import mx.events.FlexEvent; + //import mx.containers.Canvas; + + public class Carousel extends UIComponent + { + + private var picPos:Array; + private var picDimension:Array; + [Bindable] + public var gallery:Object; + public var tvMaster:Master; + + public function Carousel() { + super(); + } + + override protected function createChildren():void + { + super.createChildren(); + for (var i:int = 0; i < 7; i++) + { + addChild(new CarouselImage()); + } + } + + public function reset(selected:int):void + { + var appWidth:int = tvMaster.tuveSW.width; //Application.application.width; + var compHeight:int = 160;//(Application.application.height - 90)*.8; + + picDimension = new Array(7); + picPos = new Array(7); + + picDimension[0] = 0;//175 * 0.10; + picDimension[1] = 175 * 0.20; + picDimension[2] = 175 * 0.40; + picDimension[3] = 175; + picDimension[4] = 175 * 0.40; + picDimension[5] = 175 * 0.20; + picDimension[6] = 0;//175 * 0.10; + + picPos[0] = new Point(0, (compHeight - (175 * 0.10))/2); + picPos[1] = new Point(appWidth*.025 + 8, (compHeight - picDimension[1])/2); + picPos[2] = new Point(appWidth*.125 + 16, (compHeight - picDimension[2])/2); + picPos[3] = new Point(appWidth*.275 + 24, (compHeight - picDimension[3])/2); + picPos[4] = new Point(appWidth*.675 + 32, (compHeight - picDimension[4])/2); + picPos[5] = new Point(appWidth*.825 + 40, (compHeight - picDimension[5])/2); + picPos[6] = new Point(appWidth, (compHeight - (175 * 0.10))/2); + + for (var i:int=0; i < 7; i++) + { + var image:CarouselImage = getChildAt(i) as CarouselImage; + var pos:int = selected + i - 3; + if (pos >= 0 && pos < tvMaster.songList.length) + { + image.width = picDimension[i]; + image.height = picDimension[i]; + image.x = picPos[i].x; + image.y = picPos[i].y; + image.source = "/images/" + tvMaster.songList.getItemAt(pos).thumb; + image.visible = true; + } + else + { + image.visible = false; + } + } + } + + /** + * Add move and resize effects to the images specified. + * @param direction +1 if you're rotating right, -1 if left + * @param start where in the child list do you start playing effects (avoiding the offscreen one) + * @param end where in the child list do you stop playing effects (avoiding the offscreen one) + */ + private function playEffects(direction:int, start:int, end:int):void + { + var parallel:Parallel = new Parallel(); + + for (var i:int=start; i < end; i++) + { + + var image:CarouselImage = getChildAt(i) as CarouselImage; + if (image.visible) + { + var idx:int = i + direction; + var move:Move = new Move(); + move.target = image; + move.duration = 1000; + move.xTo = picPos[idx].x; + move.yTo = picPos[idx].y; + parallel.addChild(move); + + var resize:Resize = new Resize(); + resize.target = image; + resize.duration = 1000; + resize.widthTo = picDimension[idx]; + resize.heightTo = picDimension[idx]; + parallel.addChild(resize); + } + } + //parallel.addEventListener(EffectEvent.EFFECT_END,doNext,false,0,true); + parallel.play(); + } + + public function rotateLeft(iX:Number):void + { + playEffects(-1, 1, 7); + var offscreen:CarouselImage = getChildAt(0) as CarouselImage; + this.removeChild(offscreen); + //in an ideal world you'd re-use this image but we found + //that if click the rotate buttons fast enough the offscreen + //image will appear and fly across the screen because it was + //playing in a previous effect + //stopping the effect in the middle as soon as you know this + //image is offscreen makes the image drop offscreen and + //isn't a great visual effect + //there are probably other ways to solve this like preventing + //the rapid click of the next/prev buttons + offscreen = new CarouselImage(); + offscreen.move(picPos[6].x, picPos[6].y); + offscreen.width = picDimension[6]; + offscreen.height = picDimension[6]; + addChild(offscreen); + if (iX + 3 < tvMaster.songList.length) + { + offscreen.source = "/images/" + tvMaster.songList.getItemAt(iX + 3).thumb; + offscreen.visible = true; + } + else + { + offscreen.source = ""; + offscreen.visible = false; + } + + + } + + public function rotateRight(iX:Number):void + { + playEffects(1, 0, 6); + var offscreen:CarouselImage = getChildAt(6) as CarouselImage; + this.removeChild(offscreen); + //in an ideal world you'd re-use this image but we found + //that if click the rotate buttons fast enough the offscreen + //image will appear and fly across the screen because it was + //playing in a previous effect + //stopping the effect in the middle as soon as you know this + //image is offscreen makes the image drop offscreen and + //isn't a great visual effect + //there are probably other ways to solve this like preventing + //the rapid click of the next/prev buttons + offscreen = new CarouselImage(); + offscreen.move(picPos[0].x, picPos[0].y); + offscreen.width = picDimension[0]; + offscreen.height = picDimension[0]; + addChildAt(offscreen, 0); + + if (iX - 3 >= 0) + { + offscreen.source = "/images/" + tvMaster.songList.getItemAt(iX - 3).thumb; + offscreen.visible = true; + } + else + { + offscreen.source = ""; + offscreen.visible = false; + } + } + } +} \ No newline at end of file diff --git a/src/CarouselImage.as b/src/CarouselImage.as new file mode 100644 index 0000000..8290e49 --- /dev/null +++ b/src/CarouselImage.as @@ -0,0 +1,126 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors. +// All Rights Reserved. +// The following is Sample Code and is subject to all restrictions on such code +// as contained in the End User License Agreement accompanying this product. +// If you have received this file from a source other than Adobe, +// then your use, modification, or distribution of it requires +// the prior written permission of Adobe. +// +//////////////////////////////////////////////////////////////////////////////// +package { + + import flash.display.Graphics; + + import mx.controls.Image; + import mx.core.UIComponent; + import mx.utils.GraphicsUtil; + + /** + * The color of the frame. The default is black. + */ + [Style(name="frameColor", type="uint", format="color", inherit="no")] + + /** + * The thickness of the surrounding frame. The default is 1. + */ + [Style(name="frameThickness", type="Number", format="Length", inherit="no")] + + /** + * The size in pixels of a frame line drawn from the corner. + * The default is 5. + */ + [Style(name="frameSize", type="Number", format="Length", inherit="no")] + + + public class CarouselImage extends UIComponent + { + private var image:Image; + + public function CarouselImage() + { + super(); + image = new Image(); + image.maintainAspectRatio = true; + image.scaleContent = true; + } + + override protected function createChildren():void + { + super.createChildren(); + image.setStyle("verticalAlign", "middle"); + image.setStyle("horizontalAlign", "center"); + addChild(image); + } + + public function get source():String + { + return image.source as String; + } + + public function set source(value:String):void + { + image.source = value; + } + + override public function set width(value:Number):void + { + super.width = value; + image.width = value; + } + + override public function get width():Number + { + return super.width; + } + + override public function set height(value:Number):void + { + super.height = value; + image.height = value; + } + + override public function get height():Number + { + return super.height; + } + + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void + { + super.updateDisplayList(unscaledWidth, unscaledHeight); + var frameColor:uint = getStyle("frameColor"); + var frameThickness:Number = getStyle("frameThickness"); + var frameSize:Number = getStyle("frameSize"); + + //draw the four corners + if (frameThickness > 0) + { + var g:Graphics = graphics; + g.clear(); + g.lineStyle(frameThickness, frameColor, 1); + + //upper left corner + g.moveTo(0, frameSize); + g.lineTo(0, 0); + g.lineTo(frameSize, 0); + + //lower left corner + g.moveTo(0, unscaledHeight - frameSize); + g.lineTo(0, unscaledHeight); + g.lineTo(frameSize, unscaledHeight); + + //upper right corner + g.moveTo(unscaledWidth - frameSize, 0); + g.lineTo(unscaledWidth, 0); + g.lineTo(unscaledWidth, frameSize); + + //lower right corner + g.moveTo(unscaledWidth, unscaledHeight - frameSize); + g.lineTo(unscaledWidth, unscaledHeight); + g.lineTo(unscaledWidth - frameSize, unscaledHeight); + } + } + + } +} \ No newline at end of file diff --git a/src/Login.mxml b/src/Login.mxml new file mode 100644 index 0000000..a8174bd --- /dev/null +++ b/src/Login.mxml @@ -0,0 +1,36 @@ + + + + 0) && (tvMaster.validateNick(username.text) == true)) { + loginButton.enabled = false; + tvMaster.masterObject.selChan.selectedIndex = selChan.selectedIndex; + funcs.authUser(username.text,selChan.selectedItem.@data); + } + else + Alert.show("Please enter a valid nick before continuing."); + } + ]]> + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Master.as b/src/Master.as new file mode 100644 index 0000000..aac5039 --- /dev/null +++ b/src/Master.as @@ -0,0 +1,571 @@ +/**************************************************************** + * Master.as, by Christopher Olsen + * Copyright 2007 Christopher Olsen + * Mark Iuzzolino + * + * This is the Master class used by the TUve player + * + * $Id$ + ***************************************************************/ + +package { + + import flash.net.NetConnection; + import flash.net.NetStream; + import mx.collections.ArrayCollection; + import flash.net.Responder; + import mx.managers.PopUpManager; + import mx.controls.Alert; + import mx.controls.Image; + import flash.utils.Timer; + import flash.events.TimerEvent; + import mx.events.FlexEvent; + import flash.media.*; + import mx.core.UIComponent; + import flash.net.ObjectEncoding; + import flash.events.NetStatusEvent; + import flash.events.SecurityErrorEvent; + import tuveNetwork; + import flash.events.AsyncErrorEvent; + import flash.net.SharedObject; + import mx.formatters.NumberFormatter; + import flash.system.System; + import mx.controls.TextArea; + import mx.managers.PopUpManager; + import mx.core.Application; + import flash.filters.DropShadowFilter; + + + public class Master { + + /* Variables */ + public var gateway:NetConnection; // AMF Gateway + public var masterObject:Object; // Parent reference + [Bindable] + public var userName:String; // User Infomation + public var tvNetwork:tuveNetwork; + + /* Video Area */ + public var tvVidHolder:UIComponent = new UIComponent(); + public var tvVid:Video; + private var tvOverlay:Image; + private var ds:DropShadowFilter; + + public var tvNC:NetConnection; + + public var tvNS:NetStream; + public var tvST:SoundTransform; + public var tvStartTime:Number; + public var tvGotMeta:Boolean = false; + + public var curSong:String = "NO SONG SET"; + + public var myTimer:Timer = new Timer(1000,10); + public var myCount:Number = 0; + + [Bindable] + public var userList:XMLList; + [Bindable] + public var songList:ArrayCollection; + [Bindable] + public var topicHistory:XMLList; + + [Bindable] + public var myQueue:ArrayCollection; + + public var tvCurRating:Number; + [Bindable] + public var tvRating:XMLList = + <> + + + + + + ; + + [Bindable] + public var chanList:XMLList = + <> + + + + + + + ; + + public var tvCurClass:Number; + [Bindable] + public var tvClass:XMLList = + <> + + + + + + + + ; + + public var currentChannel:String; + + [Bindable] + public var channels:XMLList; + + [Bindable] + private var metaData:Object = {duration:0}; + + private var imWins:Array; + + public var tvSO:SharedObject; + + public var vid:Number; + + /* Pop Up Windows */ + private var tuveLW:listWindow; + public var tuveSW:searchWindow; + public var tuveIW:infoWindow; + public var tuveFW:formatWindow; + public var fwClosable:Boolean = false; + public var tuveLiveW:liveWindow; + public var login:Login; + + /* Initialization Routine */ + public function init(mO:Object):Boolean { + + /* Set Master Object */ + masterObject = mO; + + /* Initialize the AMF gateway */ + gateway = new NetConnection(); + gateway.connect("http://www.ubixonline.com/amfphp/gateway.php"); + + tvNetwork = new tuveNetwork(); + tvNetwork.tvMaster = this; + + ds = new DropShadowFilter(4,45,null,.75,4,4,1,3,false,false,false); + tvVidHolder.setActualSize(400, 300); + tvVidHolder.x = 580; + tvVidHolder.y = 5; + tvVidHolder.filters = [ds]; + + tvVid = new Video(400,300); + tvVidHolder.addChild(tvVid); + + tvOverlay = new Image(); + tvOverlay.width = 27; + tvOverlay.height = 25; + tvOverlay.source = "/images/tvOverLay.png"; + tvVidHolder.addChild(tvOverlay); + + tvNC = new NetConnection; + tvNC.addEventListener(NetStatusEvent.NET_STATUS, tvNetStatus); + tvNC.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); + tvNC.client = this; + tvNC.objectEncoding = ObjectEncoding.AMF3; + tvNC.connect("rtmp://rtmp.ubixonline.com/oflaDemo"); + + topicHistory = new XMLList(); + + tvSO = SharedObject.getLocal("TUveINFO"); + + if (tvSO.data.myID == null) + tvSO.data.myID = new Date().getTime(); + + imWins = new Array(); + + myTimer.addEventListener(TimerEvent.TIMER,doCount); + + return(true); + } /* End init */ + + private function doCount(event:TimerEvent):void { + myCount--; + + var min:Number = Math.floor((myCount/60)); + var sec:Number = (myCount%60); + var secStr:String; + + if (sec < 10) + secStr = "0" + sec.toString(); + else + secStr = sec.toString(); + + masterObject.tvTimer.text = "(" + min.toString() + ":" + secStr + ")"; + } + + public function onMetaData(info:Object):void { + if (tvGotMeta == false) { + + if (tvStartTime > 0) + tvNS.seek(tvStartTime); + + tvVid.width = info.width; + tvVid.height = info.height; + + if ((300 - info.height) > 0) { + tvVid.y = ((300 - info.height)/2); + } + else { + tvVid.y = 0; + } + tvOverlay.y = tvVid.y + (tvVid.height - 29); + if ((400 - info.width) > 0) { + tvVid.x = ((400 - info.width)/2); + } + else { + tvVid.x = 0; + } + tvOverlay.x = tvVid.x + (tvVid.width - 31); + + + tvGotMeta = true; + } + } + + public function onBWDone():void { + //Alert.show("Called BWDONE"); + } + + public function onPlayStatus(info:Object):void { + } + + public function tvNetStatus(e:NetStatusEvent):void { + if (e.info.code == "NetConnection.Connect.Success") { + if (tvNS == null) { + tvNS = new NetStream(tvNC); + tvNS.client = this; + tvVid.attachNetStream(tvNS); + tvNS.close(); + tvST = tvNS.soundTransform; + tvNS.addEventListener("netStatus", tvNetStatus); + } + } + else if (e.info.code == "NetConnection.Connect.Closed") { + tvNS.close(); + } + } + + private function securityErrorHandler(event:SecurityErrorEvent):void { + Alert.show("securityError: " + event.text); + } + + /* AMF Fault Handlers */ + public function onFault(fault:String):void { + Alert.show("Error: " + fault.toString()); + } + + public function changeChannel(chan:String):void { + tvNetwork.sendData("PART " + currentChannel + "\n"); + currentChannel = chan;//tvMaster.chanList[selChan.selectedIndex].@data; + tvNetwork.sendData("JOIN " + currentChannel + "\n"); + userList = null; + userList = new XMLList(); + } + + public function validateNick(str:String):Boolean { + var pattern:RegExp = /^[a-zA-Z0-9]*$/; + var result:Object = pattern.exec(str); + if(result == null) { + return false; + } + return true; + } + + public function parseCommand(command:String):void { + var dataArray:Array = command.split(" "); + var tmpString:String; + var i:Number; + + switch (dataArray[0]) { + case "/topic": + tmpString = dataArray[1]; + for (i=2;dataArray[i] != null;i++) + tmpString += " " + dataArray[i]; + + tvNetwork.sendData("TOPIC " + currentChannel + ":" + tmpString); + break; + case "/nick": + if (dataArray[1].length < 32) { + if (validateNick(dataArray[1]) == true) + tvNetwork.sendData("NICK " + dataArray[1]); + } + break; + case "/kick": + tmpString = dataArray[2]; + for (i=3;dataArray[i] != null;i++) + tmpString += " " + dataArray[i]; + tvNetwork.sendData("KICK " + currentChannel + ":" + dataArray[1] + ":" + tmpString + "\n"); + break; + case "/me": + case "/em": + tmpString = dataArray[1]; + for (i=2;dataArray[i] != null;i++) + tmpString += " " + dataArray[i]; + tvNetwork.sendData("EMOTE " + currentChannel + ":" + tmpString + "\n"); + masterObject.chatWindow.htmlText += "[" + new Date().toLocaleTimeString() + "] " + userName + " " + tmpString + "\n"; + break; + case "/join": + tmpString = dataArray[1]; + if (tmpString.indexOf("#") == 0) { + changeChannel(dataArray[1]); + } + else { + masterObject.chatWindow.htmlText += "Invalid Channel: " + dataArray[1] + "\n"; + } + break; + case "/status": + tvNetwork.sendData("STATUS\n"); + break; + case "/whois": + if (dataArray[1] != null) + tvNetwork.sendData("WHOIS " + dataArray[1] + "\n"); + break; + case "/ban": + if (dataArray[1] != null) + if (dataArray[2] != null) + tvNetwork.sendData("BAN " + currentChannel + ":" + dataArray[1] + ":" + dataArray[2] + "\n"); + else + tvNetwork.sendData("BAN " + currentChannel + ":" + dataArray[1] + ":300\n"); + break; + case "/unban": + if (dataArray[1] != null) + tvNetwork.sendData("UNBAN " + currentChannel + ":" + dataArray[1] + "\n"); + break; + case "/list": + tvNetwork.sendData("LIST\n"); + break; + case "/s": + case "/search": + var searchOptV:Object = new Object(); + searchOptV.sclass = Number(tvClass[masterObject.selC.selectedIndex].@data); + searchOptV.srating = Number(tvRating[masterObject.selR.selectedIndex].@data); + searchOptV.stime = masterObject.tvTime.text; + tmpString = dataArray[1]; + for (i=2;dataArray[i] != null;i++) + tmpString += " " + dataArray[i]; + + searchOptV.skey = tmpString; + gateway.call("tuve.findSongs",new Responder(masterObject.getSongs,onFault),searchOptV); + break; + case "/msg": + tmpString = dataArray[2]; + for (i=3;dataArray[i] != null;i++) + tmpString += " " + dataArray[i]; + tvNetwork.sendData("MSG " + dataArray[1] + ":" + tmpString + "\n"); + var tmpIM:imWindow; + tmpIM = findIM(dataArray[1]); + tmpIM.msgText.htmlText += "[" + new Date().toLocaleTimeString() + "] " + userName + ": " + tmpString; + break; + case "/clear": + masterObject.chatWindow.text = ""; + break; + case "/my-secret": + tuveShowLiveW(); + break; + default: + //Alert.show("Command: " + dataArray[0]); + break; + } + } + + /* This function opens up a live broadcast window */ + public function tuveShowLiveW():void { + if (tuveLiveW == null) { + tuveLiveW = new liveWindow(); + tuveLiveW.tvMaster = this; + tuveLiveW.x = ((masterObject.width - tuveLiveW.width) / 2); + tuveLiveW.y = ((masterObject.height - tuveLiveW.height) /2 ); + tuveLiveW.addEventListener("closeWindow",tuveCloseLiveW,false,0,true); + masterObject.addChild(tuveLiveW); + } + } /* End tuveShowLW() */ + + /* This function closes the channel list window */ + public function tuveCloseLiveW(event:FlexEvent):void { + if (tuveLiveW != null) { + tuveLiveW.doUnInit(); + masterObject.removeChild(tuveLiveW); + tuveLiveW = null; + } + } /* End tuveCloseLW */ + + /* This function opens up a channel list window */ + public function tuveShowLW():void { + if (tuveLW == null) { + tuveLW = new listWindow(); + tuveLW.tvMaster = this; + tuveLW.x = ((masterObject.width - tuveLW.width) / 2); + tuveLW.y = ((masterObject.height - tuveLW.height) /2 ); + tuveLW.addEventListener("closeWindow",tuveCloseLW,false,0,true); + masterObject.addChild(tuveLW); + } + } /* End tuveShowLW() */ + + /* This function closes the channel list window */ + public function tuveCloseLW(event:FlexEvent):void { + if (tuveLW != null) { + masterObject.removeChild(tuveLW); + tuveLW = null; + } + } /* End tuveCloseLW */ + + public function tuveCloseFW(event:FlexEvent):void { + if (tuveFW != null) { + if (fwClosable == true) { + masterObject.removeChild(tuveFW); + tuveFW = null; + } + } + } + + public function tuveShowIW(vid:Number):void { + if (tuveIW == null) { + tuveIW = new infoWindow(); + tuveIW.tvSizable = false; + tuveIW.tvMaster = this; + + + tuveIW.x = ((masterObject.width - tuveIW.width) / 2); + tuveIW.y = ((masterObject.height - tuveIW.height) /2 ); + tuveIW.addEventListener("closeWindow",tuveCloseIW,false,0,true); + masterObject.addChild(tuveIW); + tuveIW.getInfo(vid); + } + else { + tuveIW.getInfo(vid); + } + } /* End invShow */ + public function tuveCloseIW(event:FlexEvent):void { + if (tuveIW != null) { + masterObject.removeChild(tuveIW); + tuveIW = null; + } + } + + public function tuveShowSW():void { + if (tuveSW == null) { + tuveSW = new searchWindow(); + tuveSW.tvSizable = false; + tuveSW.tvMaster = this; + + + tuveSW.x = ((masterObject.width - tuveSW.width) / 2); + tuveSW.y = ((masterObject.height - tuveSW.height) /2 ); + tuveSW.addEventListener("closeWindow",tuveCloseSW,false,0,true); + masterObject.addChild(tuveSW); + } + else { + tuveSW.carousel.reset(0); + } + } /* End invShow */ + public function tuveCloseSW(event:FlexEvent):void { + if (tuveSW != null) { + masterObject.removeChild(tuveSW); + tuveSW = null; + } + } + + public function setClip(tW:TextArea):void { + System.setClipboard(tW.text.substring(tW.selectionBeginIndex,tW.selectionEndIndex)); + } + + public function getInfo():void { + gateway.call("tuve.getInfo",new Responder(masterObject.getInfoRes,onFault),vid); + } + /* + * + * Private Message Functions + * + */ + public function sendIM(toNick:String,msg:String):void { + var tmpIM:imWindow; + tmpIM = findIM(toNick); + tmpIM.msgText.htmlText += "[" + new Date().toLocaleTimeString() + "] " + toNick + ": " + msg; + } + + public function findIM(toNick:String):imWindow { + var i:Number; + var tmpIM:imWindow; + + /* Check to see if we have an open IM already */ + for (i=0;i + + \ No newline at end of file diff --git a/src/TUve-app.xml b/src/TUve-app.xml new file mode 100644 index 0000000..97cf00f --- /dev/null +++ b/src/TUve-app.xml @@ -0,0 +1,187 @@ + + + + + + TUve + + + + + <!-- + The description displayed in the AIR application installer. + --> + <description></description> + + <!-- + The application copyright information. + --> + <copyright></copyright> + + <!-- + The settings for the initial application window. + --> + <initialWindow> + <!-- + The title displayed in the AIR application installer. + --> + <title/> + + <!-- + The main content file of the application, which must be a SWF or HTML + file. (Required.) + + Note: In Flex Builder, the SWF reference required within this tag will + be set automatically when you launch or export this application. + --> + <content>!ApolloApplicationWizardPage.rootContentValue!</content> + + <!-- + Specifies the type of system chrome used by the window. + + standard - the application window is opened with standard operating + system window elements such as a title bar, minimize, + and close buttons. + none - the application must provide its own window controls. + (Note, that the Flex mx:WindowedApplication class supplies + its own window controls, shown only when systemChrome=none.) + + Default value: standard + --> + <systemChrome>standard</systemChrome> + + <!-- + Specifies whether the window supports transparency and alpha blending + against the desktop. + + If true, the window display is composited against the desktop. Areas of + the window not covered by a display object, or covered by display + objects with an alpha setting of zero, are effectively invisible and + will not intercept mouse events (which will be received by the desktop + object below the window). + + Setting transparent=true for a window with system chrome is not supported. + + Default value: false + --> + <transparent>false</transparent> + + <!-- + Specifies whether the window will be visible on application startup. + + If false, the main window will not be displayed until the application + changes the NativeWindow.visible property to true or calls + NativeWindow.activate(). Note that the Flex Framework will set the + initial window defined by mx:WindowedApplication to be visible + immediately prior to the applicationComplete event unless the + WindowedApplication.windowVisible property is false. + + Default value: false + --> + <visible>true</visible> + + <!-- + Other settings for the initial window. + --> + <!-- <minimizable>true</minimizable> --> + <!-- <maximizable>true</maximizable> --> + <!-- <resizable>true</resizable> --> + <!-- <width>500</width> --> + <!-- <height>500</height> --> + <!-- <x>150</x> --> + <!-- <y>150</y> --> + <!-- <minSize>300 300</minSize> --> + <!-- <maxSize>800 800</maxSize> --> + </initialWindow> + + <!-- + The subdirectory within the default application installation location in + which to install the application. + + Use forward slashes '/' to separate folders. The path cannot start with a + forward slash; end with a dot '.'; and cannot contain the characters: *":<>?\| + --> + <!-- <installFolder></installFolder> --> + + <!-- + The location within the Windows Programs menu in which to place + application shortcuts. Ignored on Mac OS X. + + Use forward slashes '/' to separate folders. The path cannot start with a + forward slash; end with a dot '.'; and cannot contain the characters: *":<>?\| + --> + <!-- <programMenuFolder>Example Company/Example Application</programMenuFolder> --> + + <!-- + One or more PNG, GIF, or JPEG graphics files to be used as application + icons. The path specified is relative to the application root directory. + If an image is specified, it must be the exact size. The image files must + be included in the AIR file. + --> + <icon> + <!-- <image16x16>icons/AIRApp_16.png</image16x16> --> + <!-- <image32x32>icons/AIRApp_32.png</image32x32> --> + <!-- <image48x48>icons/AIRApp_48.png</image48x48> --> + <!-- <image128x128>icons/AIRApp_128.png</image128x128> --> + </icon> + + <!-- + If the handleUpdates element is present in the application descriptor, + then the AIR runtime will defer version updates to this application. + --> + <!-- <handleUpdates/> --> + + <!-- + Defines the file types for which this application may register. + + Use the Shell object file registration methods at run-time to set an + application as the default application for a file type. + + Icons are optional. If used, the path specified is relative to the + application root directory. The icon files must be included in the AIR + file. + --> + <fileTypes> + <!-- + <fileType> + <name>com.example</name> + <extension>xmpl</extension> + <description>Example file</description> + <contentType>example/x-data-type</contentType> + <icon> + <image16x16>icons/AIRApp_16.png</image16x16> + <image32x32>icons/AIRApp_32.png</image32x32> + <image48x48>icons/AIRApp_48.png</image48x48> + <image128x128>icons/AIRApp_128.png</image128x128> + </icon> + </fileType> + --> + </fileTypes> +</application> diff --git a/src/TUve.mxml b/src/TUve.mxml new file mode 100644 index 0000000..5f43015 --- /dev/null +++ b/src/TUve.mxml @@ -0,0 +1,299 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp();" horizontalScrollPolicy="off" verticalScrollPolicy="off"> + <mx:backgroundImage>http://www.soulpix.com/download/desktop_pics/ab_acqua_blue.jpg</mx:backgroundImage> +<mx:Script> + <![CDATA[ + import mx.managers.SystemManager; + import mx.events.VideoEvent; + import mx.collections.ArrayCollection; + import mx.controls.Alert; + + [Bindable] + private var uM:ContextMenu; + + [Bindable] + public var videoList:ArrayCollection; + + [Bindable] + public var tvMaster:Master = new Master(); + + /* Entry Point To TUve */ + private function initApp():void { + tvMaster.init(this); + + this.addEventListener(TextEvent.LINK,doOpenInfo); + + tvMaster.tvVidHolder.y = 5; + tvMaster.tvVidHolder.x = 580; + + this.addChild(tvMaster.tvVidHolder); + + tvMaster.doLogin(); + + uM = new ContextMenu(); + uM.hideBuiltInItems(); + var cmi:ContextMenuItem = new ContextMenuItem("Whois",false); + cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,doWhois); + uM.customItems.push(cmi); + cmi = new ContextMenuItem("Kick",false); + cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,doKick); + uM.customItems.push(cmi); + } + + private function sendText():void { + var tmpString:String; + if (chatText.text.length > 0 && tvMaster.tvNetwork.tvNetCon == true) { + var myPattern:RegExp = /</g; + tmpString = chatText.text.replace(myPattern,"<"); + + if (chatText.text.indexOf("/") == 0) { + tvMaster.parseCommand(tmpString); + chatText.text = ""; + } + else { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":" + tmpString + "\n"); + var date:Date = new Date; + chatWindow.htmlText += ("[" + date.toLocaleTimeString() + "] " + tvMaster.userName + ": " + tmpString + "\n"); + chatText.text = ""; + } + } + } /* End sendText() */ + + private function doOpenInfo(event:TextEvent):void { + tvMaster.tuveShowIW(Number(event.text)); + } + + + public function updateVolume():void { + var st:SoundTransform = tvMaster.tvNS.soundTransform; + st.volume = (volume.value) * .01; + tvMaster.tvNS.soundTransform = st; + tvMaster.tvSO.data.volume = volume.value; + } /* End updateVolume */ + + public function findSong():void { + var searchOptV:Object = new Object(); + searchOptV.skey = searchBox.text; + searchOptV.sclass = Number(tvMaster.tvClass[selC.selectedIndex].@data); + searchOptV.srating = Number(tvMaster.tvRating[selR.selectedIndex].@data); + searchOptV.stime = tvTime.text; + tvMaster.gateway.call("tuve.findSongs",new Responder(getSongs,tvMaster.onFault),searchOptV); + } + + public function getSongs(result:Array):void { + if (result != null) { + tvMaster.songList = null; + tvMaster.songList = new ArrayCollection(result);; + } + else { + tvMaster.songList = null; + tvMaster.songList = new ArrayCollection; + } + + tvMaster.tuveShowSW(); + } + + private function changeChan():void { + tvMaster.tvNetwork.sendData("PART " + tvMaster.currentChannel + "\n"); + tvMaster.currentChannel = tvMaster.chanList[selChan.selectedIndex].@data; + tvMaster.tvNetwork.sendData("JOIN " + tvMaster.currentChannel + "\n"); + tvMaster.userList = null; + tvMaster.userList = new XMLList(); + } + + private function changeNick():void { + if (myNick.text.length > 32) { + myNick.text = tvMaster.userName; + } + else { + if (tvMaster.validateNick(myNick.text) == true) { + tvMaster.userName = myNick.text; + tvMaster.tvNetwork.sendData("NICK " + tvMaster.userName + "\n"); + } + } + } + private function delSong():void { + tvMaster.masterObject.chatWindow.htmlText += myQueue.selectedItem.artist + " - " + myQueue.selectedItem.title + " Has been removed from your queue.\n" + tvMaster.myQueue.removeItemAt(myQueue.selectedIndex); + } + + private function fbSend():void { + var fbData:Object = new Object(); + fbData.subject = fbSubject.text; + fbData.message = fbMessage.text; + fbData.username = tvMaster.userName; + tvMaster.gateway.call("tuve.sendFB",new Responder(null,tvMaster.onFault),fbData); + fbData = null; + + fbSubject.text = ""; + fbMessage.text = ""; + Alert.show("Feedback Has Been Sent"); + + } + + private function setTopic():void { + tvMaster.tvNetwork.sendData("TOPIC " + tvMaster.currentChannel + ":" + tvMaster.topicHistory[topicNew.selectedIndex].@label); + } + private function doRandom():void { + if (tvR.selected == true) { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +R\n"); + tvR.selected = false; + } + else { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode -R\n"); + tvR.selected = true; + } + } + private function doQueue():void { + if (tvQ.selected == true) { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +Q\n"); + tvQ.selected = false; + } + else { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode -Q\n"); + tvQ.selected = true; + } + } + private function doExclusive():void { + if (tvE.selected == true) { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +E\n"); + tvE.selected = false; + } + else { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode -E\n"); + tvE.selected = true; + } + } + private function doTime():void { + if (tvTime.text.length == 0) + tvTime.text = "300"; + if (tvT.selected == true) { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +T "+ tvTime.text + "\n"); + tvT.selected = false; + } + else { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode -T\n"); + tvT.selected = true; + } + } + private function doTimeBox():void { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +T "+ tvTime.text + "\n"); + } + + private function doTimeEnter():void { + focusManager.setFocus(chatText); + } + + private function doRating():void { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +A " + tvMaster.tvRating[selR.selectedIndex].@data + "\n"); + selR.selectedIndex = tvMaster.tvCurRating; + } + + private function doClass():void { + tvMaster.tvNetwork.sendData("MSG " + tvMaster.currentChannel + ":.tv mode +C " + tvMaster.tvClass[selC.selectedIndex].@data + "\n"); + selC.selectedIndex = tvMaster.tvCurClass; + } + public function getInfoRes(result:Array):void { + var tmpCollection:ArrayCollection; + if (result != null) { + tmpCollection = new ArrayCollection(result); + npThumb.source = "/images/" + tmpCollection[0].thumb; + npArtist.text = tmpCollection[0].artist; + npTitle.text = tmpCollection[0].title; + } + } + + private function userClick():void { + tvMaster.tvNetwork.sendData('WHOIS ' + userDispList.selectedItem.@data + '\n'); + tvMaster.findIM(userDispList.selectedItem.@data); + } + + + public function doMsg(event:MouseEvent):void { + } + public function doWhois(event:ContextMenuEvent):void { + tvMaster.tvNetwork.sendData("WHOIS " + userDispList.selectedItem.@data + "\n"); + } + public function doBan(event:MouseEvent):void { + } + public function doKick(event:ContextMenuEvent):void { + tvMaster.tvNetwork.sendData("KICK " + tvMaster.currentChannel + ":" + userDispList.selectedItem.@data + ":Bye!\n"); + } + + + /* End Of Pie Menu Functions */ + ]]> +</mx:Script> + + <mx:TextArea x="2" width="490" height="490" y="50" mouseUp="tvMaster.setClip(chatWindow)" click="focusManager.setFocus(chatText)" updateComplete="chatWindow.verticalScrollPosition = chatWindow.maxVerticalScrollPosition" editable="false" id="chatWindow" horizontalScrollPolicy="off" borderThickness="1"/> + <mx:VSlider liveDragging="true" width="22" x="990" y="45" id="volume" snapInterval="1" value="75" maximum="100" change="updateVolume()" height="220"/> + <mx:Label textAlign="center" x="575" y="315" id="songTitle" width="400" color="#ffffff"/> + <mx:List id="userDispList" itemRollOver="userDispList.selectedIndex = event.rowIndex;" contextMenu="{uM}" y="50" height="490" width="75" x="494" dataProvider="{tvMaster.userList}" labelField="@label" doubleClickEnabled="true" doubleClick="userClick()" /> + <mx:TextInput enter="sendText()" x="2" width="514" y="542" id="chatText" focusAlpha="0" height="22"/> + <mx:Button x="520" label="Send" y="542" click="sendText()" width="47"/> + <mx:TextInput x="74" y="566" width="493" enter="findSong()" id="searchBox" focusAlpha="0" /> + <mx:Button x="2" y="566" label="Search" click="findSong()" width="70"/> + <mx:Image id="loud" source="@Embed('audio-volume-high3.png')" x="990" y="5" click="volume.value = 100; updateVolume();" /> + <mx:Image id="mute" source="@Embed('audio-volume-low3.png')" x="990" y="273" click="volume.value = 0; updateVolume();" /> + + + <mx:TabNavigator x="575" y="360" width="445" height="225" id="mainNav" creationPolicy="all"> + <mx:Canvas label="My Queue" width="100%" height="100%"> + <mx:DataGrid width="100%" height="100%" id="myQueue" dataProvider="{tvMaster.myQueue}" doubleClick="delSong()" doubleClickEnabled="true"> + <mx:columns> + <mx:DataGridColumn headerText="Artist" dataField="artist"/> + <mx:DataGridColumn headerText="Title" dataField="title"/> + </mx:columns> + </mx:DataGrid> + </mx:Canvas> + <mx:Canvas id="nowplaying" label="Now Playing"> + <mx:Image id="npThumb" source="http://www.ubixonline.com/images/none.gif" width="100" height="100" scaleContent="true" horizontalAlign="center" verticalAlign="middle"/> + <mx:Label text="Artist: " x="108" y="10" fontWeight="bold" color="#000000"/> + <mx:Label id="npArtist" x="158" y="10" width="100%" text="NA" /> + <mx:Label text="Title:" x="108" y="36" color="#000000" fontWeight="bold"/> + <mx:Label id="npTitle" x="158" y="36" width="100%" text="NA"/> + <mx:Button x="108" y="62" label="Buy" click="mainNav.selectedIndex = 2;"/> + <mx:HRule x="10" y="105" width="100%"/> + <mx:Label x="10" y="108" text="Biography:"/> + <mx:LinkButton y="160" label="More Info" x="184.5" click="tvMaster.tuveShowIW(tvMaster.vid);"/> + </mx:Canvas> + <mx:Canvas id="buy" label="Buy"> + </mx:Canvas> + + <mx:Canvas id="feedback" label="FeedBack" horizontalScrollPolicy="off" verticalScrollPolicy="off"> + <mx:Form width="100%" height="100%" > + <mx:FormItem label="Subject"> + <mx:TextInput id="fbSubject" width="340"/> + </mx:FormItem> + <mx:FormItem label="Message"> + <mx:TextArea id="fbMessage" width="340" height="106"/> + </mx:FormItem> + <mx:FormItem> + <mx:Button label="Submit" id="fbSubmit" click="fbSend()" /> + </mx:FormItem> + + </mx:Form> + + </mx:Canvas> + <mx:Canvas label="Settings"> + + </mx:Canvas> + <mx:Canvas label="Help" width="100%" height="100%"> +<mx:TextArea> + +</mx:TextArea> + </mx:Canvas> + </mx:TabNavigator> + + <mx:ComboBox x="2" y="2" width="120" dataProvider="{tvMaster.chanList}" id="selChan" labelField="@label" change="changeChan()" /> + <mx:Label x="419" y="2" id="myNick" text="{tvMaster.userName}" textAlign="right" width="152" color="#ffffff" fontFamily="Georgia" fontSize="11" fontWeight="bold"/> + <mx:ComboBox x="2" y="26" width="567" id="topicNew" dataProvider="{tvMaster.topicHistory}" labelField="@label" change="setTopic()" /> + <mx:Label id="tvTimer" x="575" y="336" text="(000)" width="400" color="#ffffff" textAlign="center"/> + <mx:Button id="tvR" x="124" y="2" label="R" toggle="true" width="20" toolTip="Random Play" click="doRandom()" /> + <mx:Button id="tvQ" x="146" y="2" label="Q" toggle="true" width="20" toolTip="Queues Enabled" click="doQueue()" /> + <mx:Button id="tvT" x="190" y="2" label="T" toggle="true" width="20" toolTip="Time Limit" click="doTime()"/> + <mx:Button id="tvE" x="168" y="2" label="E" toggle="true" width="20" toolTip="Exclusive Content" click="doExclusive()"/> + <mx:TextInput x="212" y="2" maxChars="10" id="tvTime" width="50" enter="doTimeEnter()" focusOut="doTimeBox()" /> + <mx:ComboBox x="264" y="2" width="60" id="selR" dataProvider="{tvMaster.tvRating}" labelField="@label" change="doRating()" /> + <mx:ComboBox x="326" y="2" width="115" id="selC" dataProvider="{tvMaster.tvClass}" labelField="@label" change="doClass()" /> +</mx:Application> diff --git a/src/assets/closeButtonDown.gif b/src/assets/closeButtonDown.gif new file mode 100644 index 0000000..fe9228f --- /dev/null +++ b/src/assets/closeButtonDown.gif Binary files differ diff --git a/src/assets/closeButtonOver.gif b/src/assets/closeButtonOver.gif new file mode 100644 index 0000000..e57dd73 --- /dev/null +++ b/src/assets/closeButtonOver.gif Binary files differ diff --git a/src/assets/closeButtonUp.gif b/src/assets/closeButtonUp.gif new file mode 100644 index 0000000..913e4e5 --- /dev/null +++ b/src/assets/closeButtonUp.gif Binary files differ diff --git a/src/assets/horizontalSize.gif b/src/assets/horizontalSize.gif new file mode 100644 index 0000000..7611108 --- /dev/null +++ b/src/assets/horizontalSize.gif Binary files differ diff --git a/src/assets/icon_left.png b/src/assets/icon_left.png new file mode 100644 index 0000000..9de1384 --- /dev/null +++ b/src/assets/icon_left.png Binary files differ diff --git a/src/assets/icon_left_disabled.png b/src/assets/icon_left_disabled.png new file mode 100644 index 0000000..2d61333 --- /dev/null +++ b/src/assets/icon_left_disabled.png Binary files differ diff --git a/src/assets/icon_right.png b/src/assets/icon_right.png new file mode 100644 index 0000000..3f9abcc --- /dev/null +++ b/src/assets/icon_right.png Binary files differ diff --git a/src/assets/icon_right_disabled.png b/src/assets/icon_right_disabled.png new file mode 100644 index 0000000..bf787ac --- /dev/null +++ b/src/assets/icon_right_disabled.png Binary files differ diff --git a/src/assets/leftObliqueSize.gif b/src/assets/leftObliqueSize.gif new file mode 100644 index 0000000..5fdea2e --- /dev/null +++ b/src/assets/leftObliqueSize.gif Binary files differ diff --git a/src/assets/maxButtonDown.gif b/src/assets/maxButtonDown.gif new file mode 100644 index 0000000..d3f3405 --- /dev/null +++ b/src/assets/maxButtonDown.gif Binary files differ diff --git a/src/assets/maxButtonOver.gif b/src/assets/maxButtonOver.gif new file mode 100644 index 0000000..b1294ee --- /dev/null +++ b/src/assets/maxButtonOver.gif Binary files differ diff --git a/src/assets/maxButtonUp.gif b/src/assets/maxButtonUp.gif new file mode 100644 index 0000000..d835ac0 --- /dev/null +++ b/src/assets/maxButtonUp.gif Binary files differ diff --git a/src/assets/minButtonDown.gif b/src/assets/minButtonDown.gif new file mode 100644 index 0000000..2bb9f2a --- /dev/null +++ b/src/assets/minButtonDown.gif Binary files differ diff --git a/src/assets/minButtonOver.gif b/src/assets/minButtonOver.gif new file mode 100644 index 0000000..c9e2ad1 --- /dev/null +++ b/src/assets/minButtonOver.gif Binary files differ diff --git a/src/assets/minButtonUp.gif b/src/assets/minButtonUp.gif new file mode 100644 index 0000000..7a7cd4d --- /dev/null +++ b/src/assets/minButtonUp.gif Binary files differ diff --git a/src/assets/restButtonDown.gif b/src/assets/restButtonDown.gif new file mode 100644 index 0000000..2369e50 --- /dev/null +++ b/src/assets/restButtonDown.gif Binary files differ diff --git a/src/assets/restButtonOver.gif b/src/assets/restButtonOver.gif new file mode 100644 index 0000000..64ce8f2 --- /dev/null +++ b/src/assets/restButtonOver.gif Binary files differ diff --git a/src/assets/restButtonUp.gif b/src/assets/restButtonUp.gif new file mode 100644 index 0000000..916fb25 --- /dev/null +++ b/src/assets/restButtonUp.gif Binary files differ diff --git a/src/assets/rightObliqueSize.gif b/src/assets/rightObliqueSize.gif new file mode 100644 index 0000000..88ade5e --- /dev/null +++ b/src/assets/rightObliqueSize.gif Binary files differ diff --git a/src/assets/verticalSize.gif b/src/assets/verticalSize.gif new file mode 100644 index 0000000..1f0ad6e --- /dev/null +++ b/src/assets/verticalSize.gif Binary files differ diff --git a/src/audio-volume-high3.png b/src/audio-volume-high3.png new file mode 100644 index 0000000..70ae43a --- /dev/null +++ b/src/audio-volume-high3.png Binary files differ diff --git a/src/audio-volume-low3.png b/src/audio-volume-low3.png new file mode 100644 index 0000000..34546f9 --- /dev/null +++ b/src/audio-volume-low3.png Binary files differ diff --git a/src/formatWindow.mxml b/src/formatWindow.mxml new file mode 100644 index 0000000..74a35c1 --- /dev/null +++ b/src/formatWindow.mxml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" cornerRadius="7" title="Random Damage" width="550" height="300" borderAlpha="1" layout="absolute" creationComplete="doInit()"> +<mx:Script> + <![CDATA[ + import mx.controls.Alert; + public var tvMaster:Master; + public var fmTimer:Timer; + + public var pcDn:uint = 1; + + public function doInit():void { + fmTimer = new Timer(200,100); + fmTimer.addEventListener(TimerEvent.TIMER,doTmr); + fmTimer.addEventListener(TimerEvent.TIMER_COMPLETE,doEnd); + fmTimer.start(); + } + public function doTmr(event:TimerEvent):void { + fmt.setProgress(pcDn,100); + pcDn++; + } + public function doEnd(event:TimerEvent):void { + lL.text = "We're Just Joking This Time... Please Don't Do It Again"; + lL2.text = "You can now close this window"; + tvMaster.fwClosable = true; + } + + ]]> +</mx:Script> + <mx:ProgressBar x="0" y="106" id="fmt" label="Formating" direction="right" mode="manual" labelPlacement="bottom" width="100%" height="25%" minimum="0" maximum="100"/> + <mx:Label x="0" y="33" text="Please wait while we format your harddrive" fontSize="14" width="100%"/> + <mx:Label x="0" y="192" width="100%" id="lL"/> + <mx:Label x="0" y="218" width="100%" id="lL2"/> + +</tvWindow> \ No newline at end of file diff --git a/src/haloButtonTrans.as b/src/haloButtonTrans.as new file mode 100644 index 0000000..f02790c --- /dev/null +++ b/src/haloButtonTrans.as @@ -0,0 +1,27 @@ +package { + import flash.display.Graphics; + import mx.graphics.RectangularDropShadow; + import mx.skins.Border; + import flash.display.GradientType; + public class haloButtonTrans extends Border { + + private var dropShadow:RectangularDropShadow; + + public function haloButtonTrans() { + } + + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { + super.updateDisplayList(unscaledWidth, unscaledHeight); + var cornerRadius:Number = getStyle("cornerRadius"); + + drawRoundRect(0, 0, unscaledWidth, unscaledHeight, {tl: 5, tr: 5, bl: 5, br: 5}, 0, 0); + drawRoundRect( + 0, 0, unscaledWidth, unscaledHeight, 5, + [ "0xb7babc", "0xb7babc" ], 1, + verticalGradientMatrix(0, 0, unscaledWidth, unscaledHeight), + GradientType.LINEAR, null, + { x: 1, y: 1, w: unscaledWidth - 2, h: unscaledHeight - 2, r: cornerRadius - 1 }) + } + } +} + diff --git a/src/imWindow.mxml b/src/imWindow.mxml new file mode 100644 index 0000000..ff7aa6b --- /dev/null +++ b/src/imWindow.mxml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" cornerRadius="7" title="IM" width="425" height="450"> + <mx:Script> + <![CDATA[ + import mx.controls.Alert; + + public var toNick:String; + public var tvMaster:Master; + + public function sendMsg():void { + tvMaster.tvNetwork.sendData("MSG " + toNick + ":" + inputText.text + "\n"); + msgText.htmlText += "[" + new Date().toLocaleTimeString() + "] " + (tvMaster.userName + ": " + inputText.htmlText); + inputText.htmlText = ""; + } /* End sendMsg() */ + + private function checkEnter(event:KeyboardEvent):void { + if ((event.keyCode == Keyboard.ENTER) && (event.shiftKey == false)) + sendMsg(); + } + + ]]> + </mx:Script> + <mx:VBox width="100%" height="100%"> + <mx:TextArea click="focusManager.setFocus(inputText.textArea)" mouseUp="tvMaster.setClip(msgText)" updateComplete="msgText.verticalScrollPosition = msgText.maxVerticalScrollPosition" id="msgText" width="100%" height="100%" /> + <mx:RichTextEditor id="inputText" width="100%" keyDown="checkEnter(event)" height="35%" y="154" showControlBar="true" title="Text Input:" /> + </mx:VBox> +</tvWindow> \ No newline at end of file diff --git a/src/infoWindow.mxml b/src/infoWindow.mxml new file mode 100644 index 0000000..be0c068 --- /dev/null +++ b/src/infoWindow.mxml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" cornerRadius="7" title="IM" width="800" height="630" creationComplete="focusManager.setFocus(npBio);"> + <mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + + public var tvMaster:Master; + + public function getInfo(vid:Number):void { + tvMaster.gateway.call("tuve.getFullInfo",new Responder(getInfoRes,tvMaster.onFault),vid); + } + + public function getInfoRes(result:Array):void { + var tmpCollection:ArrayCollection; + if (result != null) { + tmpCollection = new ArrayCollection(result); + npThumb.source = "/images/" + tmpCollection[0].thumb; + npArtist.text = tmpCollection[0].artist; + npTitle.text = tmpCollection[0].title; + npDescription.htmlText = tmpCollection[0].description; + if (tmpCollection[0].bio != null) + npBio.htmlText = tmpCollection[0].bio; + if (tmpCollection[0].photo != null) + npImage.source = tmpCollection[0].photo; + } + } + ]]> + </mx:Script> + + <mx:Image id="npThumb" source="http://www.ubixonline.com/images/none.gif" width="100" height="100" scaleContent="true" x="10" y="10"/> + <mx:Label text="Artist: " x="118" y="10" fontWeight="bold" color="#000000"/> + <mx:Label id="npArtist" x="168" y="10" width="350" text="NA" /> + <mx:Label text="Title:" x="118" y="36" color="#000000" fontWeight="bold"/> + <mx:Label id="npTitle" x="168" y="36" width="350" text="NA"/> + <mx:Button x="118" y="62" label="Buy" click="tvMaster.masterObject.mainNav.selectedIndex = 2;"/> + <mx:HRule x="10" y="92" width="760"/> + <mx:Label x="10" y="100" text="Biography:"/> + <mx:TextArea x="10" y="120" width="505" height="220" id="npBio" focusAlpha="0" /> + <mx:Image x="525" y="120" width="245" height="220" id="npImage" scaleContent="true" source="/images/none.gif"/> + <mx:Label x="10" y="345" text="Description"/> + <mx:TextArea x="10" y="365" id="npDescription" width="760" height="220" focusAlpha="0"/> +</tvWindow> \ No newline at end of file diff --git a/src/listWindow.mxml b/src/listWindow.mxml new file mode 100644 index 0000000..92a0b38 --- /dev/null +++ b/src/listWindow.mxml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" alpha="1.0" backgroundAlpha="1.0" cornerRadius="7" title="Channel List" width="725" height="350" borderAlpha="1"> +<mx:Script> + <![CDATA[ + [Bindable] + public var tvMaster:Master; + + private function joinChan():void { + tvMaster.changeChannel(tvMaster.channels[chanGrid.selectedIndex].@channel); + } /* End joinChan() */ + ]]> +</mx:Script> + <mx:DataGrid id="chanGrid" dataProvider="{tvMaster.channels}" width="100%" height="100%" doubleClick="joinChan()" doubleClickEnabled="true"> + <mx:columns> + <mx:DataGridColumn headerText="Channel" dataField="@channel" width="75" /> + <mx:DataGridColumn headerText="Users" dataField="@users" width="50" /> + <mx:DataGridColumn headerText="Topic" dataField="@topic" width="300" /> + <mx:DataGridColumn headerText="Current Video" dataField="@cursong" width="300" /> + </mx:columns> + </mx:DataGrid> + +</tvWindow> \ No newline at end of file diff --git a/src/liveWindow.mxml b/src/liveWindow.mxml new file mode 100644 index 0000000..3225250 --- /dev/null +++ b/src/liveWindow.mxml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" cornerRadius="7" title="Live Stream" width="460" height="400" creationComplete="doInit()" xmlns:media="flash.media.*"> +<mx:Script> + <![CDATA[ + import flash.media.*; + import mx.core.UIComponent; + + + public var tvMaster:Master; + + private var ns:NetStream; + private var cam:Camera; + private var mic:Microphone; + + private var vidHolder:UIComponent = new UIComponent(); + private var vid:Video; + + private function doInit():void { + ns = new NetStream(tvMaster.tvNC); + // setup cam + cam = Camera.getCamera(); + // setting dimensions and framerate + cam.setMode(320, 240, 20); + // set to minimum of 100% quality + cam.setQuality(0,70); + + // setup mic + mic = Microphone.getMicrophone(); + mic.rate = 44; + + vidHolder.setActualSize(320, 240); + vidHolder.x = 10; + vidHolder.y = 10; + addChild(vidHolder); + vid = new Video(320,240); + vidHolder.addChild(vid); + vid.attachCamera(cam); + } + public function doUnInit():void { + vid.attachCamera(null); + vid.clear(); + if (ns != null) { + ns.close(); + ns.attachAudio(null); + ns.attachCamera(null); + ns = null; + } + cam = null; + mic = null; + } + private function doBroadCast():void { + var sN:String; + if (ns != null) { + ns.close(); + ns.attachAudio(null); + ns.attachCamera(null); + ns = null; + } + ns = new NetStream(tvMaster.tvNC); + ns.attachCamera(cam); + ns.attachAudio(mic); + sN = "stream" + tvMaster.userName + new Date().getTime(); + tvMaster.tvNetwork.sendData("LIVE " + tvMaster.currentChannel + ":" + sN + "\n"); + ns.publish(sN, "live"); + } + private function doStopCast():void { + if (ns != null) { + ns.close(); + ns.attachAudio(null); + ns.attachCamera(null); + ns = null; + tvMaster.tvNetwork.sendData("LIVE " + tvMaster.currentChannel + ":" + 0 + "\n"); + } + } + ]]> +</mx:Script> + <mx:Button x="10" y="328" label="Broadcast" click="doBroadCast()"/> + <mx:Button x="142" y="328" label="Stop Broadcast" click="doStopCast()" /> + <mx:HSlider x="10" y="308" id="quality" snapInterval="1" value="75" maximum="100" change="cam.setQuality(0,quality.value)"/> +</tvWindow> \ No newline at end of file diff --git a/src/main-app.xml b/src/main-app.xml new file mode 100644 index 0000000..4d50d72 --- /dev/null +++ b/src/main-app.xml @@ -0,0 +1,187 @@ +<?xml version="1.0" encoding="UTF-8"?> +<application xmlns="http://ns.adobe.com/air/application/1.0.M5" appId="main" version="1.0 Beta"> +<!-- + AIR Application Descriptor File: + Specifies parameters for identifying, installing, and launching AIR applications. + + The root element of the descriptor, "application" has these attributes: + appID - A string identifying this application. Every AIR + application must have a unique appID. The recommended + form of an appID is a dot-delimited, reverse-DNS-style + string, such as: "com.example.ApplicationName" + The appID string must be between 17-255 characters long + and may include the following characters: + 0-9 + a-z + A-Z + . (dot) + - (hyphen) + version - An application version designator. + Examples: "1.0", ".4", "0.5", "Alpha 1" + minimumPatchLevel - the minimum patch level of the runtime version that this + application requires. Example: 45 + xmlns - The AIR namespace: http://ns.adobe.com/air/application/1.0.M5 + The last segment of the namespace specifies the version + of the runtime required for this application to run. +--> + + <!-- + The application name displayed by the operating system. (Required.) + --> + <name>main</name> + + <!-- + The title displayed in the AIR application installer. + --> + <title/> + + <!-- + The description displayed in the AIR application installer. + --> + <description></description> + + <!-- + The application copyright information. + --> + <copyright></copyright> + + <!-- + The settings for the initial application window. + --> + <initialWindow> + <!-- + The title displayed in the AIR application installer. + --> + <title/> + + <!-- + The main content file of the application, which must be a SWF or HTML + file. (Required.) + + Note: In Flex Builder, the SWF reference required within this tag will + be set automatically when you launch or export this application. + --> + <content>!ApolloApplicationWizardPage.rootContentValue!</content> + + <!-- + Specifies the type of system chrome used by the window. + + standard - the application window is opened with standard operating + system window elements such as a title bar, minimize, + and close buttons. + none - the application must provide its own window controls. + (Note, that the Flex mx:WindowedApplication class supplies + its own window controls, shown only when systemChrome=none.) + + Default value: standard + --> + <systemChrome>standard</systemChrome> + + <!-- + Specifies whether the window supports transparency and alpha blending + against the desktop. + + If true, the window display is composited against the desktop. Areas of + the window not covered by a display object, or covered by display + objects with an alpha setting of zero, are effectively invisible and + will not intercept mouse events (which will be received by the desktop + object below the window). + + Setting transparent=true for a window with system chrome is not supported. + + Default value: false + --> + <transparent>false</transparent> + + <!-- + Specifies whether the window will be visible on application startup. + + If false, the main window will not be displayed until the application + changes the NativeWindow.visible property to true or calls + NativeWindow.activate(). Note that the Flex Framework will set the + initial window defined by mx:WindowedApplication to be visible + immediately prior to the applicationComplete event unless the + WindowedApplication.windowVisible property is false. + + Default value: false + --> + <visible>true</visible> + + <!-- + Other settings for the initial window. + --> + <!-- <minimizable>true</minimizable> --> + <!-- <maximizable>true</maximizable> --> + <!-- <resizable>true</resizable> --> + <!-- <width>500</width> --> + <!-- <height>500</height> --> + <!-- <x>150</x> --> + <!-- <y>150</y> --> + <!-- <minSize>300 300</minSize> --> + <!-- <maxSize>800 800</maxSize> --> + </initialWindow> + + <!-- + The subdirectory within the default application installation location in + which to install the application. + + Use forward slashes '/' to separate folders. The path cannot start with a + forward slash; end with a dot '.'; and cannot contain the characters: *":<>?\| + --> + <!-- <installFolder></installFolder> --> + + <!-- + The location within the Windows Programs menu in which to place + application shortcuts. Ignored on Mac OS X. + + Use forward slashes '/' to separate folders. The path cannot start with a + forward slash; end with a dot '.'; and cannot contain the characters: *":<>?\| + --> + <!-- <programMenuFolder>Example Company/Example Application</programMenuFolder> --> + + <!-- + One or more PNG, GIF, or JPEG graphics files to be used as application + icons. The path specified is relative to the application root directory. + If an image is specified, it must be the exact size. The image files must + be included in the AIR file. + --> + <icon> + <!-- <image16x16>icons/AIRApp_16.png</image16x16> --> + <!-- <image32x32>icons/AIRApp_32.png</image32x32> --> + <!-- <image48x48>icons/AIRApp_48.png</image48x48> --> + <!-- <image128x128>icons/AIRApp_128.png</image128x128> --> + </icon> + + <!-- + If the handleUpdates element is present in the application descriptor, + then the AIR runtime will defer version updates to this application. + --> + <!-- <handleUpdates/> --> + + <!-- + Defines the file types for which this application may register. + + Use the Shell object file registration methods at run-time to set an + application as the default application for a file type. + + Icons are optional. If used, the path specified is relative to the + application root directory. The icon files must be included in the AIR + file. + --> + <fileTypes> + <!-- + <fileType> + <name>com.example</name> + <extension>xmpl</extension> + <description>Example file</description> + <contentType>example/x-data-type</contentType> + <icon> + <image16x16>icons/AIRApp_16.png</image16x16> + <image32x32>icons/AIRApp_32.png</image32x32> + <image48x48>icons/AIRApp_48.png</image48x48> + <image128x128>icons/AIRApp_128.png</image128x128> + </icon> + </fileType> + --> + </fileTypes> +</application> diff --git a/src/main.mxml b/src/main.mxml new file mode 100644 index 0000000..dd6041d --- /dev/null +++ b/src/main.mxml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> + +</mx:WindowedApplication> diff --git a/src/searchWindow.mxml b/src/searchWindow.mxml new file mode 100644 index 0000000..26308b0 --- /dev/null +++ b/src/searchWindow.mxml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="utf-8"?> +<tvWindow xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" cornerRadius="7" title="Search Results" width="570" height="375" borderAlpha="1" show="onShow(event)" resize="carousel.reset(0)" creationComplete="doInit()"> +<mx:Script> + <![CDATA[ + import mx.collections.ArrayCollection; + import mx.controls.Alert; + import mx.events.FlexEvent; +// import mx.managers.FocusManager; + + [Bindable] + public var tvMaster:Master; + [Bindable] + private var nextWord:String; + [Bindable] + private var previousWord:String; + private var curSong:Number = 0; + + + [Embed(source="assets/icon_left.png")] + private const ICON_LEFT:Class; + + [Embed(source="assets/icon_right.png")] + private const ICON_RIGHT:Class; + + [Embed(source="assets/icon_left_disabled.png")] + private const ICON_LEFT_DISABLED:Class; + + [Embed(source="assets/icon_right_disabled.png")] + private const ICON_RIGHT_DISABLED:Class; + + public function addSong():void { + if (tvMaster.myQueue == null) + tvMaster.myQueue = new ArrayCollection; + + if (tvMaster.myQueue.length == 0) + tvMaster.tvNetwork.sendData("QUEUE FULL\n"); + + if (resGrid.selectedIndex >= 0) { + tvMaster.myQueue.addItem(tvMaster.songList[resGrid.selectedIndex]); + tvMaster.masterObject.chatWindow.htmlText += "<FONT COLOR=\"#0033CC\"><P>[" + new Date().toLocaleTimeString() + "] " + resGrid.selectedItem.artist + " - " + resGrid.selectedItem.title + " Has been added to your queue.</P></FONT>"; + } + + focusManager.setFocus(resGrid); + } + + private function onShow(event:FlexEvent):void + { + + if (resGrid.selectedIndex == 0) + prevVid.setStyle("icon", ICON_LEFT_DISABLED); + else + prevVid.setStyle("icon", ICON_LEFT); + + if (resGrid.selectedIndex >= tvMaster.songList.length - 1) + nextVid.setStyle("icon", ICON_RIGHT_DISABLED); + else + nextVid.setStyle("icon", ICON_RIGHT); + + carousel.reset(resGrid.selectedIndex); + Alert.show("On Show?"); + } + + private function doInit():void { + this.addEventListener(KeyboardEvent.KEY_DOWN,doKey,false,0x0,true); + resGrid.selectedIndex = 0; + carousel.reset(0); + } + + private function doKey(event:KeyboardEvent):void { + if (event.keyCode == 27) + dispatchEvent(new FlexEvent("closeWindow")); + } + private function showPrev():void { + resGrid.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0.0,38)); + } + + private function doPrev(iX:Number):void { + if (iX > 0) { + nextVid.setStyle("icon", ICON_RIGHT); + //resGrid.selectedIndex--; + //focusManager.setFocus(resGrid); + carousel.rotateRight(iX); + + if (resGrid.selectedIndex <= 0) + prevVid.setStyle("icon", ICON_LEFT_DISABLED); + } + } + + private function showNext():void { + resGrid.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN,true,false,0.0,40)); + } + + private function doNext(iX:Number):void { + if (iX < tvMaster.songList.length - 1) { + prevVid.setStyle("icon", ICON_LEFT); + + if (iX >= tvMaster.songList.length - 1) + nextVid.setStyle("icon", ICON_RIGHT_DISABLED); + } + } /* End showNext() */ + + private function findSong():void { + tvMaster.masterObject.searchBox.text = searchBox.text; + tvMaster.masterObject.findSong(); + curSong = 0; + } + private function doChange():void { + var i:Number; + var x:Number; + var tA:Object; + + if (resGrid.selectedIndex < curSong) { + x = curSong - resGrid.selectedIndex; + if (x > 1) + carousel.reset(resGrid.selectedIndex + 1); + carousel.rotateRight(resGrid.selectedIndex); + /* + for (i = 0;i < x;i++) { + tA = new Object(); + tA.dir = 0; + tA.end = curSong - i - 1; + tvMaster.SSA.push(tA); + } + */ + } + else { + x = resGrid.selectedIndex - curSong; + if (x > 1) + carousel.reset(resGrid.selectedIndex - 1); + carousel.rotateLeft(resGrid.selectedIndex); + /* + for (i = 0;i < x;i++) { + tA = new Object(); + tA.dir = 1; + tA.end = curSong + i + 1; + tvMaster.SSA.push(tA); + } + */ + } + curSong = resGrid.selectedIndex; + //carousel.animate(); + } + ]]> +</mx:Script> +<mx:VBox width="100%" height="100%"> + <mx:VBox width="100%" height="100%" horizontalAlign="center" horizontalCenter="0" backgroundColor="#000000" id="mySpot" color="#ffffff" verticalAlign="bottom"> + <Carousel id="carousel" gallery="{resGrid}" tvMaster="{tvMaster}" + width="100%" height="100%" + verticalCenter="0" horizontalCenter="0" doubleClick="addSong()" doubleClickEnabled="true"/> + + + +<mx:HBox> + <NavButton icon="{ICON_LEFT}" + id="prevVid" + toolTip="{previousWord}" + click="showPrev()" /> + + <NavButton + id="nextVid" + toolTip="{nextWord}" + icon="{ICON_RIGHT}" + click="showNext()" /> + + </mx:HBox> + <mx:Label id="vidName" text="{resGrid.selectedItem.artist} - {resGrid.selectedItem.title}" + + width="100%" height="20" + styleName="photoName" textAlign="center"/> + + </mx:VBox> + <mx:HBox horizontalAlign="center" width="100%"> + <mx:TextInput width="467" enter="findSong()" id="searchBox"/> + <mx:Button label="Search" click="findSong()" width="69"/> + </mx:HBox> + <mx:DataGrid x="5" y="475" width="100%" height="100%" id="resGrid" dataProvider="{tvMaster.songList}" doubleClick="addSong()" doubleClickEnabled="true" cornerRadius="5" color="#000000" change="doChange()"> + <mx:columns> + <mx:DataGridColumn headerText="Artist" dataField="artist" width="175" /> + <mx:DataGridColumn headerText="Title" dataField="title"/> + <mx:DataGridColumn headerText="Genre" dataField="genre" width="75"/> + <mx:DataGridColumn headerText="Length" dataField="length" width="60"/> + </mx:columns> + </mx:DataGrid> + </mx:VBox> + +</tvWindow> \ No newline at end of file diff --git a/src/tuveNetwork.as b/src/tuveNetwork.as new file mode 100644 index 0000000..60cdbe2 --- /dev/null +++ b/src/tuveNetwork.as @@ -0,0 +1,394 @@ +/************************************************************************ + * tuveNetwork Class, by Christopher Olsen <cwolsen@domainatlantic.com> * + * Copyright 2007 Christopher Olsen * + * * + * $Id$ * + ************************************************************************/ + +package { + import flash.net.Socket; + import flash.events.IOErrorEvent; + import mx.controls.Alert; + import flash.events.ProgressEvent; + import flash.events.Event; + import flash.utils.ByteArray; + import flash.utils.Timer; + import flash.events.TimerEvent; + import mx.collections.ArrayCollection; + import mx.utils.ArrayUtil; + + public class tuveNetwork { + private var tvSocket:Socket; + public var tvMaster:Master; + private var attempts:Number = 0; + private var myTimer:Timer = new Timer(20000,1); + public var tvNetCon:Boolean = false; + private var curTime:Number; + + public function init():void { + myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,conSocketEvent); + conSocketEvent(null); + } /* End init() */ + + private function conSocketEvent(event:TimerEvent):void { + if (attempts >=3) { + Alert.show("Cannot reconnect to server. Some services will not be available."); + } + else { + if (tvSocket == null) + this.tvSocket = new Socket(); + this.tvSocket.addEventListener(IOErrorEvent.IO_ERROR,onConnectError,false,0,true); + this.tvSocket.addEventListener(ProgressEvent.SOCKET_DATA,gotData,false,0,true); + this.tvSocket.addEventListener(Event.CONNECT,doNetAuth,false,0,true); + this.tvSocket.addEventListener(Event.CLOSE,doReconnect,false,0,true); + tvSocket.connect("tuved.ubixonline.com",9999); + attempts++; + } + } + + /* Send data to the socket */ + public function sendData(data:String):void { + tvSocket.writeUTFBytes(data); + tvSocket.flush(); + } /* End sendData */ + + /* Let's auth to the network */ + private function doNetAuth(event:Event):void { + tvNetCon = true; + tvSocket.writeUTFBytes("ident " + tvMaster.userName + ":" + tvMaster.tvSO.data.myID + "\n"); + tvSocket.flush(); + } /* End doNetAuth */ + + private function doNetSuccess():void { + tvMaster.userList = null; + tvMaster.userList = new XMLList(); + tvMaster.masterObject.userDispList.dataProvider = tvMaster.userList; + + tvSocket.writeUTFBytes("join " + tvMaster.currentChannel + "\n"); + tvSocket.flush(); + attempts = 0; + + tvMaster.masterObject.chatWindow.htmlText += "<FONT COLOR=\"#00FF00\"><P>CONNECTED To Server.</P></FONT>"; + + if ((tvMaster.myQueue != null) && (tvMaster.myQueue.length > 0)) { + tvSocket.writeUTFBytes("QUEUE FULL\n"); + tvSocket.flush(); + } + } + + private function onConnectError(event:IOErrorEvent):void { + if (event.text.match("close")) + myTimer.start(); + else + Alert.show("ERROR: " + event.text); + } /* End onConnectionError */ + + private function gotData(event:ProgressEvent):void { + var _data:String; + var _dataArray:Array; + var data:String; + var dataArray:Array; + var _i:Number; + var i:Number; + var x:Number; + var tmpString:String; + var fc:Boolean = false; + var date:Date; + + event.bytesLoaded + + _data = this.tvSocket.readUTFBytes(this.tvSocket.bytesAvailable); + _dataArray = _data.split("\n"); + + for (_i = 0;_dataArray[_i] != null;_i++) { + data = _dataArray[_i]; + + if (data.length <= 0) + return; + + + if (data.indexOf("MSG") == 0) { + dataArray = data.split(":"); + tmpString = dataArray[3]; + for (i=4;dataArray[i] != null;i++) + tmpString += ":" + dataArray[i]; + + if (dataArray[2].match("PRIVMSG")) { + tvMaster.sendIM(dataArray[1],tmpString); + } + else { + date = new Date; + if (dataArray[1].match("TUveD")) { + tvMaster.masterObject.chatWindow.htmlText += "<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Verdana\" SIZE=\"10\" COLOR=\"#FF0000\" LETTERSPACING=\"0\" KERNING=\"0\">[" + date.toLocaleTimeString() + "] " + dataArray[1] + ": " + tmpString + "</FONT></P></TEXTFORMAT>"; + } + else { + tvMaster.masterObject.chatWindow.htmlText += "<P>[" + date.toLocaleTimeString() + "] " + dataArray[1] + ": " + tmpString + "<P>"; + } + } + } + else if (data.indexOf("EMOTE") == 0) { + dataArray = data.split(":"); + tmpString = dataArray[3]; + for (i=4;dataArray[i] != null;i++) + tmpString += ":" + dataArray[i]; + date = new Date; + tvMaster.masterObject.chatWindow.htmlText += "[" + date.toLocaleTimeString() + "] " + dataArray[1] + " " + tmpString + "\n"; + } + else if (data.indexOf("PING") == 0) { + tvSocket.writeUTFBytes("PONG!\n"); + tvSocket.flush(); + } + else if (data.indexOf("LIST") == 0) { + dataArray = data.split(":"); + tvMaster.tuveShowLW(); + + if (dataArray[1].match("Channel")) { + tvMaster.channels = null; + tvMaster.channels = new XMLList(); + } + else { + tvMaster.channels += new XML("<mi channel=\"" + dataArray[1] + "\" users=\"" + dataArray[2] + "\" topic=\"" + dataArray[3] + "\" cursong=\"" + dataArray[4] + "\" />"); + } + + } + else if (data.indexOf("JOIN") == 0) { + dataArray = data.split(":"); + i = 2; + while (dataArray[i] != null) { + if (dataArray[i].indexOf("&") == 0) + tmpString = dataArray[i].toString().substring(1,dataArray[i].toString().length); + else + tmpString = dataArray[i]; + + tvMaster.userList += new XML("<mi label=\"" + dataArray[i] + "\" data=\"" + tmpString + "\" />"); + if (tvMaster.userName.match(dataArray[i])) { + tvMaster.topicHistory = null; + tvMaster.topicHistory = new XMLList(); + tvMaster.masterObject.chatWindow.htmlText += "You Are Now Talking In: " + dataArray[1] + "\n"; + tvMaster.currentChannel = dataArray[1]; + //Alert.show(tvMaster.chanList.length()); + for (x = 0;x < tvMaster.chanList.length();x++) { + //Alert.show(tvMaster.chanList[x].@data); + if (tvMaster.currentChannel.match(tvMaster.chanList[x].@data)) { + tvMaster.masterObject.selChan.selectedIndex = x; + fc = true; + } + } + if (fc == false) { + tvMaster.chanList += new XML("<mi label=\"" + dataArray[1] + "\" data=\"" + dataArray[1] + "\" />"); + tvMaster.masterObject.selChan.selectedIndex = tvMaster.chanList.length() - 1; + } + } + i += 2; + } + } + else if (data.indexOf("GETVIDEO") == 0) { + if (tvMaster.myQueue != null && tvMaster.myQueue.length > 0) { + tvSocket.writeUTFBytes("VIDEO " + tvMaster.currentChannel + ":" + tvMaster.myQueue[0].vid + "\n"); + tvMaster.myQueue.removeItemAt(0); + tvSocket.flush(); + } + else { + tvSocket.writeUTFBytes("QUEUE EMPTY\n"); + tvSocket.flush(); + } + } + else if (data.indexOf("PAUSE") == 0) { + curTime = tvMaster.tvNS.time; + tvMaster.myTimer.stop(); + tvMaster.tvNS.close(); + } + else if (data.indexOf("RESUME") == 0) { + tvMaster.tvNS.play(tvMaster.curSong,curTime); + tvMaster.myTimer.start(); + } + else if (data.indexOf("SEEK") == 0) { + dataArray = data.split(":"); + if (dataArray[1] != null) + tvMaster.tvNS.seek(Number(dataArray[1])); + } + else if (data.indexOf("CURPOS") == 0) { + dataArray = data.split(":"); + tvMaster.tvGotMeta = false; + tvMaster.curSong = dataArray[2]; + if (tvMaster.tvNC.connected == false) { + Alert.show("ERROR: tvMaster.tvNC.connected == false"); + return; + } + tvMaster.tvNS.close(); + tvMaster.myTimer.stop(); + tvMaster.myTimer.reset(); + tvMaster.tvStartTime = Number(dataArray[1]); + tvMaster.myTimer.delay = 1000; + tvMaster.myCount = Number(dataArray[4]) - tvMaster.tvStartTime; + tvMaster.myTimer.repeatCount = tvMaster.myCount; + tvMaster.myTimer.start(); + if (tvMaster.curSong.indexOf("stream") == 0) { + tvMaster.tvNS.play(tvMaster.curSong,-1); + tvMaster.tvVid.width = 320; + tvMaster.tvVid.height = 240; + tvMaster.tvVid.y = 30; + tvMaster.tvVid.x = 40; + + } + else + tvMaster.tvNS.play(tvMaster.curSong,0); + + tvMaster.masterObject.songTitle.text = dataArray[3]; + tvMaster.vid = Number(dataArray[5]); + tvMaster.getInfo(); + + } + else if (data.indexOf("BAN") == 0) { + if (tvMaster.tuveFW == null) { + tvMaster.tuveFW = new formatWindow(); + tvMaster.masterObject.addChild(tvMaster.tuveFW); + tvMaster.tuveFW.tvMaster = tvMaster; + tvMaster.tuveFW.addEventListener("closeWindow",tvMaster.tuveCloseFW,false,0,true); + } + } + else if (data.indexOf("KICK") == 0) { + dataArray = data.split(":"); + tmpString = dataArray[3]; + for (i=4;dataArray[i] != null;i++) + tmpString += ":" + dataArray[i]; + tvMaster.masterObject.chatWindow.htmlText += "You Have Been Kick By: " + dataArray[2] + " For " + tmpString + "\n"; + tvMaster.userList = null; + tvMaster.userList = new XMLList; + } + else if (data.indexOf("PART") == 0) { + dataArray = data.split(":"); + + for (i=0;i<tvMaster.userList.length();i++) { + if (dataArray[2].match(tvMaster.userList[i].@data)) { + delete(tvMaster.userList[i]); + tvMaster.masterObject.userDispList.dataProvider = tvMaster.userList; + break; + } + } + } + else if (data.indexOf("NICK") == 0) { + dataArray = data.split(":"); + if (dataArray[1].match(tvMaster.userName)) { + tvMaster.userName = dataArray[2]; + tvMaster.tvSO.data.userName = dataArray[2]; + } + for (i=0;i<tvMaster.userList.length();i++) { + if (dataArray[1].match(tvMaster.userList[i].@label)) { + delete(tvMaster.userList[i]); + tmpString = dataArray[2].toString(); + + if (tmpString.indexOf("&") == 0) + tmpString = tmpString.substr(1,tmpString.length -1); + + tvMaster.userList += new XML("<mi label=\"" + dataArray[2] + "\" data=\"" + tmpString + "\" />"); + tvMaster.masterObject.userDispList.dataProvider = tvMaster.userList; + break; + } + } + } /* End NICK */ + else if (data.indexOf("MODE") == 0) { + dataArray = data.split(":"); + switch (dataArray[2]) { + case 'E': + if (dataArray[3] == '1') + tvMaster.masterObject.tvE.selected = true; + else + tvMaster.masterObject.tvE.selected = false; + break; + case 'R': + if (dataArray[3] == '1') + tvMaster.masterObject.tvR.selected = true; + else + tvMaster.masterObject.tvR.selected = false; + break; + case 'Q': + if (dataArray[3] == '1') + tvMaster.masterObject.tvQ.selected = true; + else + tvMaster.masterObject.tvQ.selected = false; + break; + case 'T': + if (dataArray[3] == '1') + tvMaster.masterObject.tvT.selected = true; + else + tvMaster.masterObject.tvT.selected = false; + tvMaster.masterObject.tvTime.text = dataArray[4]; + break; + case 'A': + for (i = 0;i<tvMaster.tvRating.length();i++) { + if (dataArray[3].match(tvMaster.tvRating[i].@data)) { + tvMaster.masterObject.selR.selectedIndex = i; + tvMaster.tvCurRating = i; + break; + } + } + break; + case 'C': + for (i = 0;i<tvMaster.tvClass.length();i++) { + if (dataArray[3].match(tvMaster.tvClass[i].@data)) { + tvMaster.masterObject.selC.selectedIndex = i; + tvMaster.tvCurClass = i; + break; + } + } + break; + case 'O': + for (i=0;i<tvMaster.userList.length();i++) { + if (dataArray[4].toLowerCase().match(tvMaster.userList[i].@data.toLowerCase())) { + delete(tvMaster.userList[i]); + tmpString = dataArray[2].toString(); + + if (dataArray[3] == 1) + tmpString = "&" + dataArray[4]; + else tmpString = dataArray[4]; + + tvMaster.userList += new XML("<mi label=\"" + tmpString + "\" data=\"" + dataArray[4] + "\" />"); + tvMaster.masterObject.userDispList.dataProvider = tvMaster.userList; + break; + } + } + break; + } + } + else if (data.indexOf("IDENT") == 0) { + dataArray = data.split(":"); + if (dataArray[1] == 0) { + doNetSuccess(); + tvMaster.authSuccess(); + } + else { + tvMaster.masterObject.authFail(dataArray[2]); + } + } + else if (data.indexOf("TOPIC") == 0) { + var topic:Object = new Object(); + dataArray = data.split(":"); + tmpString = dataArray[2]; + for (i=3;dataArray[i] != null;i++) + tmpString += ":" + dataArray[i]; + + for (i=0;i<tvMaster.topicHistory.length();i++) { + if (tmpString.match(tvMaster.topicHistory[i].@label)) { + tvMaster.masterObject.topicNew.selectedIndex = i; + return; + } + } + + tvMaster.topicHistory += new XML("<mi label=\"" + tmpString + "\" />"); + tvMaster.masterObject.topicNew.selectedIndex = tvMaster.topicHistory.length() - 1; + } + + } /*End big for */ + } + + /* Reconnect when connection fails */ + private function doReconnect(event:Event):void { + tvMaster.masterObject.chatWindow.htmlText += "<FONT COLOR=\"#990000\"><P>DISCONNECTED From Server!!!</P></FONT>"; + tvNetCon = false; + myTimer.start(); /* Reconnect */ + } /* End doReconnect() */ + + } /* End podzNEtwork Class */ + + } /* End package */ \ No newline at end of file diff --git a/src/tvWindow.as b/src/tvWindow.as new file mode 100644 index 0000000..9a6c267 --- /dev/null +++ b/src/tvWindow.as @@ -0,0 +1,489 @@ +/**************************************************************** + * ucWindow Class, by Christopher Olsen <cwolsen@domainatlantic.com> + * Copyright 2007 Christopher Olsen + * + * This is the PodWindow container + * + * It handles the following: + * Window Resize + * Invokes Windows Close Event + * + * It contains the following: + * Top margin for window move + * Left margine for window move + * Minimum window size + * Max window size + * !! Note: The pod manager can override these values + * + * $Id$ + ***************************************************************/ + +package { + + import flash.events.MouseEvent; + import flash.events.Event; + import mx.controls.Button; + import mx.containers.Panel; + import mx.controls.Image; + import mx.events.FlexEvent + import flash.geom.Point; + import mx.managers.CursorManager; + import mx.managers.CursorManagerPriority; + import mx.core.Application; + import mx.containers.ApplicationControlBar; + import mx.controls.ColorPicker; + import mx.events.ColorPickerEvent; + import mx.events.DragEvent; + import mx.core.DragSource; + import mx.managers.DragManager; + + public class tvWindow extends Panel { + + /* Mouse Pointers */ + [Embed(source="assets/leftObliqueSize.gif")] + private static var leftObliqueSize:Class; + [Embed(source="assets/rightObliqueSize.gif")] + private static var rightObliqueSize:Class; + [Embed(source="assets/horizontalSize.gif")] + private static var horizontalSize:Class; + [Embed(source="assets/verticalSize.gif")] + private static var verticalSize:Class; + + /* The close button */ + private var closeButton:Button; + [Embed(source="assets/closeButtonUp.gif")] + private var closeButtonUp:Class; + [Embed(source="assets/closeButtonOver.gif")] + private var closeButtonOver:Class; + [Embed(source="assets/closeButtonDown.gif")] + private var closeButtonDown:Class; + /* The min button */ + private var minButton:Button; + [Embed(source="assets/minButtonUp.gif")] + private var minButtonUp:Class; + [Embed(source="assets/minButtonOver.gif")] + private var minButtonOver:Class; + [Embed(source="assets/minButtonDown.gif")] + private var minButtonDown:Class; + + /* The max button */ + private var maxButton:Button; + [Embed(source="assets/maxButtonUp.gif")] + private var maxButtonUp:Class; + [Embed(source="assets/maxButtonOver.gif")] + private var maxButtonOver:Class; + [Embed(source="assets/maxButtonDown.gif")] + private var maxButtonDown:Class; + [Embed(source="assets/restButtonUp.gif")] + private var restButtonUp:Class; + [Embed(source="assets/restButtonOver.gif")] + private var restButtonOver:Class; + [Embed(source="assets/restButtonDown.gif")] + private var restButtonDown:Class; + + private var mMC:Boolean = false; + + private var _pwMin:Boolean = false; + private var _stageY: Number; + private var _startY: Number; + private var _startX: Number; + private var _dragStartX: Number; + private var _dragStartY: Number; + private var oWidth:Number; + private var oHeight:Number; + //public var myPod:Podz; + public var closeable:Boolean = true; + private var resizePoint:Point = new Point(); + private var resizeType:Number = 0; + public var tvSizable:Boolean = true; + + /* Previous x,y width and height before maximized */ + private var oldX:Number = 0; + private var oldY:Number = 0; + private var oldWidth:Number = 0; + private var oldHeight:Number = 0; + private var pwButtonVisible:Boolean = false; + private var pwAttached:Boolean = false; + + + public function tvWindow() { + super(); + this.addEventListener(FlexEvent.CREATION_COMPLETE, pwInit); + this.addEventListener(MouseEvent.MOUSE_DOWN, mouseClickHandler, false); + this.addEventListener(MouseEvent.MOUSE_MOVE, oMouseMove, false); + this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler,true); + this.setStyle("borderThicknessTop",0); + this.setStyle("borderThicknessBottom",0); + this.setStyle("borderThicknessLeft",0); + this.setStyle("borderThicknessRight",0); + this.setStyle("headerHeight",20); + this.setStyle("borderAlpha",.75); + this.setStyle("borderColor","#808080"); + } /* end Pod Window */ + + /****************************************************** + * Handlers Section + * + ******************************************************/ + private function pwMouseOver(event:MouseEvent):void { + pwShowButtons(); + } + + private function pwMouseOut(event:MouseEvent):void { + pwHideButtons(); + } + + private function pwInit(event:FlexEvent):void { + titleBar.addEventListener(MouseEvent.MOUSE_OVER, pwMouseOver,false,0,true); + titleBar.addEventListener(MouseEvent.MOUSE_OUT, pwMouseOut,false,0,true); + } + + /* + This function attaches the buttons to the PodWindow + */ + + public function pwAttachButtons():void { + var nC:Boolean = false; + + /* + if (myPod != null) + nC = myPod.podzMaster.podzManager.nC; + */ + + if ((closeButton == null) && (nC == false)) { + closeButton = new Button(); + closeButton.width=10; + closeButton.height=10; + closeButton.focusEnabled=false; + closeButton.setStyle("upSkin", closeButtonUp); + closeButton.setStyle("overSkin", closeButtonOver); + closeButton.setStyle("downSkin", closeButtonDown); + closeButton.addEventListener(MouseEvent.CLICK, closeButtonHandler); + titleBar.addChild(closeButton); + } + else if ((closeButton != null) && (closeable == false)) { + titleBar.removeChild(closeButton); + closeButton.removeEventListener(MouseEvent.CLICK,closeButtonHandler); + closeButton = null; + } + + if ((maxButton == null) && (tvSizable == true)) { + maxButton = new Button(); + maxButton.width=10; + maxButton.height=10; + maxButton.focusEnabled=false; + maxButton.setStyle("upSkin", maxButtonUp); + maxButton.setStyle("overSkin", maxButtonOver); + maxButton.setStyle("downSkin", maxButtonDown); + maxButton.addEventListener(MouseEvent.CLICK, maxButtonHandler); + titleBar.addChild(maxButton); + } + + if ((minButton == null) && (tvSizable == true)) { + minButton = new Button(); + minButton.width=10; + minButton.height=10; + minButton.focusEnabled=false; + minButton.setStyle("upSkin", minButtonUp); + minButton.setStyle("overSkin", minButtonOver); + minButton.setStyle("downSkin", minButtonDown); + minButton.addEventListener(MouseEvent.CLICK, minButtonHandler); + titleBar.addChild(minButton); + } + + pwAttached = true; + alignButtons(); + } /* end addButtons */ + + + // Event handler for mouse over moves + private function oMouseMove(event:MouseEvent):void { + var contentPoint:Point = event.currentTarget.globalToContent(new Point(event.stageX, event.stageY)); + + if (_pwMin == true) + return; + + if ((contentPoint.y > event.currentTarget.height - 40) && (contentPoint.x > event.currentTarget.width - 30)){ + CursorManager.removeCursor(CursorManager.currentCursorID); + CursorManager.setCursor(leftObliqueSize,CursorManagerPriority.MEDIUM, -6, -6); + mMC = true; + } + else if ((contentPoint.y < -15) && (contentPoint.x > event.currentTarget.width - 5)) { + CursorManager.removeCursor(CursorManager.currentCursorID); + CursorManager.setCursor(rightObliqueSize,CursorManagerPriority.MEDIUM, -6, -6); + mMC = true; + } + else if (mMC == true) { + CursorManager.removeCursor(CursorManager.currentCursorID); + mMC = false; + } + } /* End oMouseMose */ + + // Event handler to do actual resize + private function pwDoResize(event:MouseEvent):void { + var xPlus:Number = Application.application.parent.mouseX - resizePoint.x; + var yPlus:Number = Application.application.parent.mouseY - resizePoint.y; + var newY:Number; + + switch (resizeType) { + case 1: + this.width = oWidth + xPlus > 0 ? oWidth + xPlus : this.width; + this.height = oHeight + yPlus > 0 ? oHeight + yPlus : this.height; + break; + case 2: + this.width = oWidth + xPlus > 0 ? oWidth + xPlus : this.width; + + newY = _startY + event.stageY - _stageY; + if (newY >= 1) { + this.y = newY; + this.height = oHeight - yPlus > 0 ? oHeight - yPlus : this.height; + } + + break; + } + /* re-align the buttons */ + alignButtons(); + } + + // Event handler to end resize + private function pwEndResize(event:MouseEvent):void { + var xPlus:Number = Application.application.parent.mouseX - resizePoint.x; + var yPlus:Number = Application.application.parent.mouseY - resizePoint.y; + var newY:Number; + + event.stopImmediatePropagation(); + + Application.application.parent.removeEventListener(MouseEvent.MOUSE_MOVE, pwDoResize, true); + Application.application.parent.removeEventListener(MouseEvent.MOUSE_UP, pwEndResize, true); + + switch (resizeType) { + case 1: + this.width = oWidth + xPlus > 0 ? oWidth + xPlus : this.width; + this.height = oHeight + yPlus > 0 ? oHeight + yPlus : this.height; + break; + case 2: + this.width = oWidth + xPlus > 0 ? oWidth + xPlus : this.width; + + newY = _startY + event.stageY - _stageY; + if (newY >= 1) { + this.y = newY; + this.height = oHeight - yPlus > 0 ? oHeight - yPlus : this.height; + } + + break; + } + /* re-align the buttons */ + alignButtons(); + + /* Unset resizeType incase event is still in propagation */ + resizeType = 0; + + } /* End pwEndResize */ + + private function mouseOutHandler(event:MouseEvent):void { + CursorManager.removeCursor(CursorManager.currentCursorID); + } + + // Event handler for mouse click + private function mouseClickHandler(event:MouseEvent):void { + var contentPoint:Point = event.currentTarget.globalToContent(new Point(event.stageX, event.stageY)); + //podParent.setChildIndex(event.currentTarget,podParent.numChildren-1); + this.parentDocument.setChildIndex(event.currentTarget,this.parentDocument.numChildren-1); + + if ((contentPoint.y > this.height - 40) && (contentPoint.x > this.width - 30) && (tvSizable == true)){ + _dragStartX = event.localX; + _dragStartY = event.localY; + + oWidth = event.currentTarget.width; + oHeight = event.currentTarget.height; + + resizePoint = event.currentTarget.localToGlobal(new Point(event.currentTarget.mouseX,event.currentTarget.mouseY)); + + resizeType = 1; + + Application.application.parent.addEventListener(MouseEvent.MOUSE_UP, pwEndResize, true); + Application.application.parent.addEventListener(MouseEvent.MOUSE_MOVE, pwDoResize, true); + } + else if ((contentPoint.y < -15) && (contentPoint.x > this.width - 5) && (tvSizable == true)) { + _dragStartX = event.localX; + _dragStartY = event.localY; + + _startY = event.currentTarget.y; + _stageY = event.stageY; + + oWidth = event.currentTarget.width + oHeight = event.currentTarget.height; + resizePoint = event.currentTarget.localToGlobal(new Point(event.currentTarget.mouseX,event.currentTarget.mouseY)); + resizeType = 2; + Application.application.parent.addEventListener(MouseEvent.MOUSE_UP, pwEndResize, true); + Application.application.parent.addEventListener(MouseEvent.MOUSE_MOVE, pwDoResize, true); + } + else if ((contentPoint.y < 0) && (contentPoint.x < (event.currentTarget.width - 5))) { + Application.application.parent.addEventListener(MouseEvent.MOUSE_UP, podEndMove, true); + Application.application.parent.addEventListener(MouseEvent.MOUSE_MOVE, podDoMove, true); + _startX = event.currentTarget.x; + _startY = event.currentTarget.y; + _dragStartX = event.stageX; + _dragStartY = event.stageY; + } + + + } /* End hMouseClick */ + + public function closeButtonHandler(event:MouseEvent):void{ + dispatchEvent(new FlexEvent("closeWindow")); + } /* end buttonCloseHandler */ + + private function minButtonHandler(event:MouseEvent):void { + this.oldHeight = this.height; + this.oldWidth = this.width; + this.oldY = this.y; + + this.height = this.titleBar.height; + + maxButton.setStyle("upSkin", restButtonUp); + maxButton.setStyle("overSkin", restButtonOver); + maxButton.setStyle("downSkin", restButtonDown); + + _pwMin = true; + + } /* End minButtonHandler() */ + + private function maxButtonHandler(event:MouseEvent):void { + if (this.oldY != 0) { + if (_pwMin != true) { + this.x = this.oldX; + this.y = this.oldY; + } + else + _pwMin = false; + + this.height = this.oldHeight; + this.width = this.oldWidth; + this.oldY = 0; + maxButton.setStyle("upSkin", maxButtonUp); + maxButton.setStyle("overSkin", maxButtonOver); + maxButton.setStyle("downSkin", maxButtonDown); + } + else { + this.oldX = this.x; + this.oldY = this.y; + this.oldHeight = this.height; + this.oldWidth = this.width; + this.width = this.parentDocument.width - 2; + this.height = this.parentDocument.height - 23; + this.y = 1; + this.x = 1; + maxButton.setStyle("upSkin", restButtonUp); + maxButton.setStyle("overSkin", restButtonOver); + maxButton.setStyle("downSkin", restButtonDown); + } + + resizeType = 0; + + this.titleBar.width = this.width; + alignButtons(); + } /* End maxButtonHandler() */ + + /****************************************************** + * Private functions to the new container class + * + *****************************************************/ + public function pwHideButtons():void { + + if (closeButton != null) + closeButton.visible = false; + + if (maxButton != null) + maxButton.visible = false; + + if (minButton != null) + minButton.visible = false; + + pwButtonVisible = false; + } + + public function pwShowButtons():void { + if (pwAttached == false) + pwAttachButtons(); + + if (closeButton != null) + closeButton.visible = true; + + if (maxButton != null) + maxButton.visible = true; + + if (minButton != null) + minButton.visible = true; + + pwButtonVisible = true; + } + + private function alignButtons():void { + var bcnt:Number = 1; + + if (closeButton != null) { + closeButton.move(titleBar.width - (bcnt * 16), (titleBar.height - 10) / 2); + bcnt++; + } + if (maxButton != null) { + maxButton.move(titleBar.width - (bcnt * 16), (titleBar.height - 10) / 2); + bcnt++; + } + if (minButton != null) { + minButton.move(titleBar.width - (bcnt * 16), (titleBar.height - 10) / 2); + bcnt++; + } + + + if (pwButtonVisible == true) + pwShowButtons(); + else + pwHideButtons(); + } + + /*************/ + private function podDoMove(event:MouseEvent):void { + var newY:Number; + var newX:Number; + event.stopImmediatePropagation(); + + newY = _startY + event.stageY - _dragStartY; + newX = _startX + event.stageX - _dragStartX; + + if (newY > 1 && newX > 1) + move(newX,newY); + else if (newY > 1 && newX < 1) + move(1,newY); + else if (newY < 1 && newX < 1) + move(1,1); + else + move(newX,1); + } /* End podDoMove */ + + // Event handler to end moving + private function podEndMove(event:MouseEvent):void { + var newY:Number; + var newX:Number; + + event.stopImmediatePropagation(); + Application.application.parent.removeEventListener(MouseEvent.MOUSE_MOVE, podDoMove, true); + Application.application.parent.removeEventListener(MouseEvent.MOUSE_UP, podEndMove, true); + + newY = _startY + event.stageY - _dragStartY; + newX = _startX + event.stageX - _dragStartX; + + if (newY > 22 && newX > 1) + move(newX,newY); + else if (newY > 1 && newX < 1) + move(1,newY); + else if (newY < 1 && newX < 1) + move(1,1); + else + move(newX,1); + } /* End podEndMove */ + /*************/ + + } /* end class */ + + } /* end package */ \ No newline at end of file