/** * Licensed under the MIT License * * Copyright (c) 2009-2010 Martin Sandström * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * http://www.marteinn.se * http://www.opensource.org/licenses/mit-license.php * */ package se.marteinn.net.client { import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; import flash.utils.Proxy; import flash.utils.flash_proxy; import nl.base42.log.Logger; dynamic public class NetStreamClient extends Proxy implements IEventDispatcher { protected var dispatcher:EventDispatcher; public function NetStreamClient ( ) : void { dispatcher = new EventDispatcher(this); } // this is a catch-all method witch dispatches events flash_proxy override function callProperty( name:*, ...args ):* { var qName:QName = name as QName; switch( qName.localName ) { case NetStreamClientEvent.XMP_DATA: case NetStreamClientEvent.META_DATA: case NetStreamClientEvent.CUE_POINT: case NetStreamClientEvent.IMAGE_DATA: case NetStreamClientEvent.TEXT_DATA: case NetStreamClientEvent.DRM_CONTENT_DATA: case NetStreamClientEvent.PLAY_STATUS: dispatchEvent( new NetStreamClientEvent( qName.localName, args, qName.localName ) ); break; default: dispatchEvent( new NetStreamClientEvent( NetStreamClientEvent.UNKNOWN_CALL, args, qName.localName ) ); break; } } flash_proxy override function getProperty(name:*) : * { var qName:QName = name as QName; return function ( ...args ) : void { flash_proxy::callProperty( qName, args[0] ); } } // inherited methods for EventDispatcher public function addEventListener( type:String, listener:Function, useCapture:Boolean = false, priority:int = 0 , useWeakListener:Boolean = true ) : void { dispatcher.addEventListener( type, listener, useCapture, priority, useWeakListener ); } public function dispatchEvent( event:Event ) : Boolean { return dispatcher.dispatchEvent( event ); } public function hasEventListener( type:String ) : Boolean { return dispatcher.hasEventListener( type ); } public function removeEventListener( type:String, listener:Function, useCapture:Boolean = false ) : void { dispatcher.removeEventListener( type, listener, useCapture ); } public function willTrigger( type:String ) : Boolean { return dispatcher.willTrigger( type ); } } }