Newer
Older
SuperTUve / Master.as
@reddawg reddawg on 11 Feb 2008 6 KB Sync
/****************************************************************
 * Master.as, by Christopher Olsen <cwolsen@domainatlantic.com>
 * Copyright 2007 Christopher Olsen
 *                Mark Iuzzolino
 * 
 * This is the Master class used by the TUve player
 * 
 * $Id$
 ***************************************************************/
 
package {
  import flash.net.NetConnection;
  
  import mx.collections.ArrayCollection;
  import mx.events.FlexEvent;

  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 tvCurRating:Number;
	[Bindable]
	public var tvRating:XMLList = 
	  <>
	    <mi label="G" data="1" />
	    <mi label="PG" data="2" />
	    <mi label="13+" data="3" />
	    <mi label="MA" data="4" />
	    <mi label="AD" data="5" />
	  </>;
	
    public var tvCurClass:Number;
    [Bindable]
    public var tvClass:XMLList = 
      <>
        <mi label="Anime/Toons" data="3" />
        <mi label="Documentary" data="5" />
        <mi label="Movie" data="4" />
        <mi label="Music" data="1" />
        <mi label="TV" data="2" />
        <mi label="Original" data="6" />
      </>;
      
    public var currentChannel:String;
    
    [Bindable]
    public var channels:XMLList;
    
    [Bindable]
	private var metaData:Object = {duration:0};
	
	public var userInfo:ArrayCollection;
	
	/* Pop Up Windows */
	public  var tuveVW:videoWindow;
	private var tuveBW:bioWindow;
	private var tuveNBW:newBio;
	private var tuveUW:uploadWindow;
	private var tuveCW:channelWindow;
	private var tuveRW:registerWindow;
 	
 	/* Initialization Routine */
    public function init(mO:Object):Boolean {
      /* Set Master Object */
      masterObject = mO;

      /* Initialize the AMF gateway */	
      gateway = new NetConnection();
      gateway.connect("/amfphp/gateway.php");

      return(true);
      } /* End init */
      
    /* AMF Fault Handler */
    public function onFault(fault:String):void {
      //Alert.show("Error: " + fault.toString());
      trace(fault);
      }
      
    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;
      }
    
   /**************************
    * Video Functions        *
    **************************/
   /* This function opens up the video window */
   public function tuveShowVW():void {
      if (tuveVW == null) {
   	  	tuveVW = new videoWindow();
   	  	tuveVW.tvMaster = this;   	  	
  	  	tuveVW.x = ((masterObject.width - tuveVW.width) / 2);
  	  	tuveVW.y = ((masterObject.height - tuveVW.height) /2 ) + 12;
  	  	tuveVW.addEventListener("closeWindow",tuveCloseVW,false,0,true);   	  	
   	  	masterObject.addChild(tuveVW);
   	    }
      } /* End tuveShowVW() */      
    /* This function closes the channel list window */
    public function tuveCloseVW(event:FlexEvent):void {
      if (tuveVW != null) {
      	masterObject.removeChild(tuveVW);
      	tuveVW = null;
        }
      } /* End tuveCloseVW */

   public function tuveShowUW():void {
      if (tuveUW == null) {
   	  	tuveUW = new uploadWindow();
   	  	tuveUW.tvMaster = this;   	  	
  	  	tuveUW.x = ((masterObject.width - tuveUW.width) / 2);
  	  	tuveUW.y = ((masterObject.height - tuveUW.height) /2 ) + 12;
  	  	tuveUW.addEventListener("closeWindow",tuveCloseUW,false,0,true);   	  	
   	  	masterObject.addChild(tuveUW);
   	    }
      } /* End tuveShowCW() */
    /* This function closes the register window */
    public function tuveCloseUW(event:FlexEvent):void {
      if (tuveUW != null) {
      	masterObject.removeChild(tuveUW);
      	tuveUW = null;
        }
      } /* End tuveCloseUW */
    /***********************
     * End Video Functions *
     ***********************/
     
   /**************************
    * Bio Functions          *
    **************************/
   /* This function opens up the bio window */
   public function tuveShowBW(artist:String):void {
      if (tuveBW == null) {
   	  	tuveBW = new bioWindow();
   	  	tuveBW.tvMaster = this; 
   	  	tuveBW.bioData = artist;  	  	
  	  	tuveBW.x = ((masterObject.width - tuveBW.width) / 2);
  	  	tuveBW.y = ((masterObject.height - tuveBW.height) /2 ) + 12;
  	  	tuveBW.addEventListener("closeWindow",tuveCloseBW,false,0,true);   	  	
   	  	masterObject.addChild(tuveBW);
   	    }
   	  else {
   	  	tuveBW.bioData = artist;
   	  	tuveBW.findBio();
   	    }
      } /* End tuveShowBW() */   
    /* This function closes the bio window */
    public function tuveCloseBW(event:FlexEvent):void {
      if (tuveBW != null) {
      	masterObject.removeChild(tuveBW);
      	tuveBW = null;
        }
      } /* End tuveCloseBW */

   public function tuveShowNBW():void {
      if (tuveNBW == null) {
   	  	tuveNBW = new newBio();
   	  	tuveNBW.tvMaster = this;   	  	
  	  	tuveNBW.x = ((masterObject.width - tuveNBW.width) / 2);
  	  	tuveNBW.y = ((masterObject.height - tuveNBW.height) /2 ) + 12;

   	  	masterObject.addChild(tuveNBW);
   	    }
      } /* End tuveShowNBW() */
    public function tuveCloseNBW():void {
      if (tuveNBW != null) {
      	masterObject.removeChild(tuveNBW);
      	tuveNBW = null;
        }
      } /* End tuveCloseNBW */
   /***************************
    *    End Bio Functions    *
    ***************************/
   /***************************
    *    Channel Functions    *
    ***************************/
   public function tuveShowCW():void {
      if (tuveCW == null) {
   	  	tuveCW = new channelWindow();
   	  	tuveCW.tvMaster = this;   	  	
  	  	tuveCW.x = ((masterObject.width - tuveCW.width) / 2);
  	  	tuveCW.y = ((masterObject.height - tuveCW.height) /2 ) + 12;
  	  	tuveCW.addEventListener("closeWindow",tuveCloseCW,false,0,true);   	  	
   	  	masterObject.addChild(tuveCW);
   	    }
      } /* End tuveShowCW() */
    /* This function closes the Channel window */
    public function tuveCloseCW(event:FlexEvent):void {
      if (tuveCW != null) {
      	masterObject.removeChild(tuveCW);
      	tuveCW = null;
        }
      } /* End tuveCloseCW */

   public function tuveShowRW():void {
      if (tuveRW == null) {
   	  	tuveRW = new registerWindow();
   	  	tuveRW.tvMaster = this;   	  	
  	  	tuveRW.x = ((masterObject.width - tuveRW.width) / 2);
  	  	tuveRW.y = ((masterObject.height - tuveRW.height) /2 ) + 12;
  	  	tuveRW.addEventListener("closeWindow",tuveCloseRW,false,0,true);   	  	
   	  	masterObject.addChild(tuveRW);
   	    }
      } /* End tuveShowCW() */
    /* This function closes the register window */
    public function tuveCloseRW(event:FlexEvent):void {
      if (tuveRW != null) {
      	masterObject.removeChild(tuveRW);
      	tuveRW = null;
        }
      } /* End tuveCloseRW */
    /*******************************
     *    End Channel Functions    *
     *******************************/
    } /* End Master */
    
  } /* End package */