﻿/**
	 * Widget Developer should include this class into their widget if they want to use some resoruces as  FLV video  or Audio...
	 * in their widget. 
*/

package com.adobe.captivate.widgets
{
	import flash.utils.ByteArray;
	/**
		* This class decscribes the handle Adobe Captivate passes  to the widget during runtime using the cpSetValue function.
	*/
	public class CPWidgetExternalResourceLoader
	{
		/**
     		* @private
     	*/
		private var _browseResouce:Function;
		/**
     		* @private
     	*/
		private var _getResourceStream:Function;
		
		public static const RESOURCE_FILE:uint = 0;
		public static const RESOURCE_MULTIPLE_FILES:uint = 1;
		public static const RESOURCE_FOLDER:uint = 2;
		

		public function CPWidgetExternalResourceLoader(aBrowseResouce:Function=null,aGetResourceStream:Function=null)
		{
			_browseResouce = aBrowseResouce;
			_getResourceStream = aGetResourceStream;
		}
		
		/**
     		* The widget parameter provided by the widget during edit time.			
			* @return A Integer that's the resource id
     	*/
		public function browseResource(aResType:int = 0) :Object
		{
			var lResourceID :Object = -1;
			if(_browseResouce!= null)
			{
				lResourceID = _browseResouce(aResType);
			}
			return lResourceID;
		}

		/**
     		* This function returns the resource path, and resource would have been copied in current directory
			
			* @return A String
			
		*/
		public function getResourcePath( resourceID:int ) : String
		{
			var lResourceStream:String;
			if(_getResourceStream != null)
			{
				lResourceStream = _getResourceStream(resourceID);
			}
			return lResourceStream;
		}
	}
}

