home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / com / facebook / delegates / VideoUploadDelegate.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  1.8 KB  |  56 lines

  1. package com.facebook.delegates
  2. {
  3.    import com.facebook.commands.video.UploadVideo;
  4.    import com.facebook.net.FacebookCall;
  5.    import com.facebook.session.WebSession;
  6.    import com.facebook.utils.PlayerUtils;
  7.    import flash.events.Event;
  8.    import flash.net.FileReference;
  9.    import flash.net.URLRequest;
  10.    import flash.utils.ByteArray;
  11.    
  12.    public class VideoUploadDelegate extends AbstractFileUploadDelegate
  13.    {
  14.       public function VideoUploadDelegate(param1:FacebookCall, param2:WebSession)
  15.       {
  16.          super(param1,param2);
  17.       }
  18.       
  19.       override protected function getExt() : String
  20.       {
  21.          return (call as UploadVideo).ext;
  22.       }
  23.       
  24.       override protected function getContentType() : String
  25.       {
  26.          return "Content-Type: video/" + (call as UploadVideo).ext;
  27.       }
  28.       
  29.       override protected function sendRequest() : void
  30.       {
  31.          var _loc1_:ByteArray = null;
  32.          var _loc2_:URLRequest = new URLRequest(_session.rest_url);
  33.          var _loc3_:Object = call.args.data;
  34.          if(PlayerUtils.majorVersion == 9 && _loc3_ is FileReference)
  35.          {
  36.             throw new TypeError("Uploading FileReference with Player 9 is unsupported.  Use ByteArray.");
  37.          }
  38.          if(PlayerUtils.majorVersion == 10 && _loc3_ is FileReference)
  39.          {
  40.             _loc1_ = (_loc3_ as FileReference)["load"]();
  41.             fileRef = _loc3_ as FileReference;
  42.             fileRef.addEventListener(Event.COMPLETE,onFileRefComplete);
  43.          }
  44.          else
  45.          {
  46.             if(!(_loc3_ is ByteArray))
  47.             {
  48.                throw new Error("Error data type " + call.args.data + " is not supported.  Please use one of the following types:  FileReference or ByteArray.");
  49.             }
  50.             uploadByteArray(_loc3_ as ByteArray);
  51.          }
  52.       }
  53.    }
  54. }
  55.  
  56.