Newer
Older
SuperTUve / Master.as
@reddawg reddawg on 11 Dec 2007 5 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;
  //import flash.media.*;
  //import mx.core.UIComponent;
  //import flash.net.ObjectEncoding;
  //import flash.events.NetStatusEvent;
  //import flash.events.SecurityErrorEvent;  
  //import flash.events.AsyncErrorEvent;
  //import flash.net.SharedObject;
  //import mx.formatters.NumberFormatter;
  //import flash.system.System;
  //import mx.controls.TextArea;


  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 Video" 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;
	
 	
 	/* 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);
      }
    
    /* Video Window 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 tuveShowLW() */
      
    /* This function closes the channel list window */
    public function tuveCloseVW(event:FlexEvent):void {
      if (tuveVW != null) {
      	masterObject.removeChild(tuveVW);
      	tuveVW = null;
        }
      } /* End tuveCloseLW */
    /* End Video Window 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 channel list window */
    public function tuveCloseBW(event:FlexEvent):void {
      if (tuveBW != null) {
      	masterObject.removeChild(tuveBW);
      	tuveBW = null;
        }
      } /* End tuveCloseLW */
    /* End bio Window Functions */
    
   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 tuveCloseLW */

   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 tuveShowNBW() */    
      
    public function tuveCloseUW(event:FlexEvent):void {
      if (tuveUW != null) {
      	masterObject.removeChild(tuveUW);
      	tuveUW = null;
        }
      } /* End tuveCloseLW */
    
    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;
        }
  
    } /* End Master */
    
  } /* End package */