package org.mangui.chromeless {
    import flash.net.URLStream;

    import org.mangui.HLS.parsing.Level;
    import org.mangui.HLS.*;
    import org.mangui.HLS.utils.*;

    import flash.display.*;
    import flash.events.*;
    import flash.external.ExternalInterface;
    import flash.geom.Rectangle;
    import flash.media.Video;
    import flash.media.SoundTransform;
    import flash.media.StageVideo;
    import flash.media.StageVideoAvailability;
    import flash.utils.setTimeout;

    public class ChromelessPlayer extends Sprite {
        /** reference to the framework. **/
        private var _hls : HLS;
        /** Sheet to place on top of the video. **/
        private var _sheet : Sprite;
        /** Reference to the stage video element. **/
        private var _stageVideo : StageVideo = null;
        /** Reference to the video element. **/
        private var _video : Video = null;
        /** Video size **/
        private var _videoWidth : Number = 0;
        private var _videoHeight : Number = 0;
        /** current media position */
        private var _media_position : Number;

        /** Initialization. **/
        public function ChromelessPlayer() : void {
            // Set stage properties
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.fullScreenSourceRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, _onStageVideoState);
            stage.addEventListener(Event.RESIZE, _onStageResize);
            // Draw sheet for catching clicks
            _sheet = new Sprite();
            _sheet.graphics.beginFill(0x000000, 0);
            _sheet.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            _sheet.addEventListener(MouseEvent.CLICK, _clickHandler);
            _sheet.buttonMode = true;
            addChild(_sheet);
            // Connect getters to JS.
            ExternalInterface.addCallback("getLevel", _getLevel);
            ExternalInterface.addCallback("getLevels", _getLevels);
            ExternalInterface.addCallback("getMetrics", _getMetrics);
            ExternalInterface.addCallback("getPosition", _getPosition);
            ExternalInterface.addCallback("getState", _getState);
            ExternalInterface.addCallback("getType", _getType);
            ExternalInterface.addCallback("getmaxBufferLength", _getmaxBufferLength);
            ExternalInterface.addCallback("getminBufferLength", _getminBufferLength);
            ExternalInterface.addCallback("getbufferLength", _getbufferLength);
            ExternalInterface.addCallback("getLogDebug", _getLogDebug);
            ExternalInterface.addCallback("getLogDebug2", _getLogDebug2);
            ExternalInterface.addCallback("getflushLiveURLCache", _getflushLiveURLCache);
            ExternalInterface.addCallback("getstartFromLowestLevel", _getstartFromLowestLevel);
            ExternalInterface.addCallback("getseekFromLowestLevel", _getseekFromLowestLevel);
            ExternalInterface.addCallback("getJSURLStream", _getJSURLStream);
            ExternalInterface.addCallback("getPlayerVersion", _getPlayerVersion);
            ExternalInterface.addCallback("getAudioTrackList", _getAudioTrackList);
            ExternalInterface.addCallback("getAudioTrackId", _getAudioTrackId);
            // Connect calls to JS.
            ExternalInterface.addCallback("playerLoad", _load);
            ExternalInterface.addCallback("playerPlay", _play);
            ExternalInterface.addCallback("playerPause", _pause);
            ExternalInterface.addCallback("playerResume", _resume);
            ExternalInterface.addCallback("playerSeek", _seek);
            ExternalInterface.addCallback("playerStop", _stop);
            ExternalInterface.addCallback("playerVolume", _volume);
            ExternalInterface.addCallback("playerSetLevel", _setLevel);
            ExternalInterface.addCallback("playerSetmaxBufferLength", _setmaxBufferLength);
            ExternalInterface.addCallback("playerSetminBufferLength", _setminBufferLength);
            ExternalInterface.addCallback("playerSetflushLiveURLCache", _setflushLiveURLCache);
            ExternalInterface.addCallback("playerSetstartFromLowestLevel", _setstartFromLowestLevel);
            ExternalInterface.addCallback("playerSetseekFromLowestLevel", _setseekFromLowestLevel);
            ExternalInterface.addCallback("playerSetLogDebug", _setLogDebug);
            ExternalInterface.addCallback("playerSetLogDebug2", _setLogDebug2);
            ExternalInterface.addCallback("playerSetAudioTrack", _setAudioTrack);
            ExternalInterface.addCallback("playerSetJSURLStream", _setJSURLStream);

            setTimeout(_pingJavascript, 50);
        };

        /** Notify javascript the framework is ready. **/
        private function _pingJavascript() : void {
            ExternalInterface.call("onHLSReady", ExternalInterface.objectID);
        };

        /** Forward events from the framework. **/
        private function _completeHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onComplete");
            }
        };

        private function _errorHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onError", event.message);
            }
        };

        private function _fragmentHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onFragment", event.metrics.bandwidth, event.metrics.level, stage.stageWidth);
            }
        };

        private function _manifestHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onManifest", event.levels[0].duration);
            }
        };

        private function _mediaTimeHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                _media_position = event.mediatime.position;
                ExternalInterface.call("onPosition", event.mediatime.position, event.mediatime.duration, event.mediatime.live_sliding);
            }

            var videoWidth : Number = _video ? _video.videoWidth : _stageVideo.videoWidth;
            var videoHeight : Number = _video ? _video.videoHeight : _stageVideo.videoHeight;

            if (videoWidth && videoHeight) {
                var changed : Boolean = _videoWidth != videoWidth || _videoHeight != videoHeight;
                if (changed) {
                    _videoHeight = videoHeight;
                    _videoWidth = videoWidth;
                    _resize();
                    if (ExternalInterface.available) {
                        ExternalInterface.call("onVideoSize", _videoWidth, _videoHeight);
                    }
                }
            }
        };

        private function _stateHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onState", event.state);
            }
        };

        private function _switchHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onSwitch", event.level);
            }
        };

        private function _audioTracksListChange(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onAudioTracksListChange", _getAudioTrackList());
            }
        }

        private function _audioTrackChange(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onAudioTrackChange", event.audioTrack);
            }
        }

        /** Javascript getters. **/
        private function _getLevel() : Number {
            return _hls.level;
        };

        private function _getLevels() : Vector.<Level> {
            return _hls.levels;
        };

        private function _getMetrics() : Object {
            return _hls.metrics;
        };

        private function _getPosition() : Number {
            return _hls.position;
        };

        private function _getState() : String {
            return _hls.state;
        };

        private function _getType() : String {
            return _hls.type;
        };

        private function _getbufferLength() : Number {
            return _hls.bufferLength;
        };

        private function _getmaxBufferLength() : Number {
            return _hls.maxBufferLength;
        };

        private function _getminBufferLength() : Number {
            return _hls.minBufferLength;
        };

        private function _getflushLiveURLCache() : Boolean {
            return _hls.flushLiveURLCache;
        };

        private function _getstartFromLowestLevel() : Boolean {
            return _hls.startFromLowestLevel;
        };

        private function _getseekFromLowestLevel() : Boolean {
            return _hls.seekFromLowestLevel;
        };

        private function _getLogDebug() : Boolean {
            return Log.LOG_DEBUG_ENABLED;
        };

        private function _getLogDebug2() : Boolean {
            return Log.LOG_DEBUG2_ENABLED;
        };

        private function _getJSURLStream() : Boolean {
            return (_hls.URLstream is JSURLStream);
        };

        private function _getPlayerVersion() : Number {
            return 2;
        };

        private function _getAudioTrackList() : Array {
            var list : Array = [];
            var vec : Vector.<HLSAudioTrack> = _hls.audioTracks;
            for (var i : Object in vec) {
                list.push(vec[i]);
            }
            return list;
        };

        private function _getAudioTrackId() : Number {
            return _hls.audioTrack;
        };

        /** Javascript calls. **/
        private function _load(url : String) : void {
            _hls.load(url);
        };

        private function _play() : void {
            _hls.stream.play();
        };

        private function _pause() : void {
            _hls.stream.pause();
        };

        private function _resume() : void {
            _hls.stream.resume();
        };

        private function _seek(position : Number) : void {
            _hls.stream.seek(position);
        };

        private function _stop() : void {
            _hls.stream.close();
        };

        private function _volume(percent : Number) : void {
            _hls.stream.soundTransform = new SoundTransform(percent / 100);
        };

        private function _setLevel(level : Number) : void {
            _hls.level = level;
            if (!isNaN(_media_position)) {
                _hls.stream.seek(_media_position);
            }
        };

        private function _setmaxBufferLength(new_len : Number) : void {
            _hls.maxBufferLength = new_len;
        };

        private function _setminBufferLength(new_len : Number) : void {
            _hls.minBufferLength = new_len;
        };

        private function _setflushLiveURLCache(flushLiveURLCache : Boolean) : void {
            _hls.flushLiveURLCache = flushLiveURLCache;
        };

        private function _setstartFromLowestLevel(startFromLowestLevel : Boolean) : void {
            _hls.startFromLowestLevel = startFromLowestLevel;
        };

        private function _setseekFromLowestLevel(seekFromLowestLevel : Boolean) : void {
            _hls.seekFromLowestLevel = seekFromLowestLevel;
        };

        private function _setLogDebug(debug : Boolean) : void {
            Log.LOG_DEBUG_ENABLED = debug;
        };

        private function _setLogDebug2(debug2 : Boolean) : void {
            Log.LOG_DEBUG2_ENABLED = debug2;
        };

        private function _setJSURLStream(jsURLstream : Boolean) : void {
            if (jsURLstream) {
                _hls.URLstream = JSURLStream as Class;
            } else {
                _hls.URLstream = URLStream as Class;
            }
        };

        private function _setAudioTrack(val : Number) : void {
            if (val == _hls.audioTrack) return;
            _hls.audioTrack = val;
            if (!isNaN(_media_position)) {
                _hls.stream.seek(_media_position);
            }
        };

        /** Mouse click handler. **/
        private function _clickHandler(event : MouseEvent) : void {
            if (stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE || stage.displayState == StageDisplayState.FULL_SCREEN) {
                stage.displayState = StageDisplayState.NORMAL;
            } else {
                stage.displayState = StageDisplayState.FULL_SCREEN;
            }
        };

        /** StageVideo detector. **/
        private function _onStageVideoState(event : StageVideoAvailabilityEvent) : void {
            var available : Boolean = (event.availability == StageVideoAvailability.AVAILABLE);
            _hls = new HLS();
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _completeHandler);
            _hls.addEventListener(HLSEvent.ERROR, _errorHandler);
            _hls.addEventListener(HLSEvent.FRAGMENT_LOADED, _fragmentHandler);
            _hls.addEventListener(HLSEvent.MANIFEST_LOADED, _manifestHandler);
            _hls.addEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            _hls.addEventListener(HLSEvent.STATE, _stateHandler);
            _hls.addEventListener(HLSEvent.QUALITY_SWITCH, _switchHandler);
            _hls.addEventListener(HLSEvent.AUDIO_TRACKS_LIST_CHANGE, _audioTracksListChange);
            _hls.addEventListener(HLSEvent.AUDIO_TRACK_CHANGE, _audioTrackChange);

            if (available && stage.stageVideos.length > 0) {
                _stageVideo = stage.stageVideos[0];
                _stageVideo.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
                _stageVideo.attachNetStream(_hls.stream);
            } else {
                _video = new Video(stage.stageWidth, stage.stageHeight);
                addChild(_video);
                _video.smoothing = true;
                _video.attachNetStream(_hls.stream);
            }
            stage.removeEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, _onStageVideoState);
        };

        private function _onStageResize(event : Event) : void {
            stage.fullScreenSourceRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            _sheet.width = stage.stageWidth;
            _sheet.height = stage.stageHeight;
            _resize();
        };

        private function _resize() : void {
            var rect : Rectangle;
            rect = ScaleVideo.resizeRectangle(_videoWidth, _videoHeight, stage.stageWidth, stage.stageHeight);
            // resize video
            if (_video) {
                _video.width = rect.width;
                _video.height = rect.height;
                _video.x = rect.x;
                _video.y = rect.y;
            } else if (_stageVideo) {
                _stageVideo.viewPort = rect;
            }
        }
    }
}

package org.mangui.chromeless {
    import flash.net.URLStream;

    import org.mangui.HLS.parsing.Level;
    import org.mangui.HLS.*;
    import org.mangui.HLS.utils.*;

    import flash.display.*;
    import flash.events.*;
    import flash.external.ExternalInterface;
    import flash.geom.Rectangle;
    import flash.media.Video;
    import flash.media.SoundTransform;
    import flash.media.StageVideo;
    import flash.media.StageVideoAvailability;
    import flash.utils.setTimeout;

    public class ChromelessPlayer extends Sprite {
        /** reference to the framework. **/
        private var _hls : HLS;
        /** Sheet to place on top of the video. **/
        private var _sheet : Sprite;
        /** Reference to the stage video element. **/
        private var _stageVideo : StageVideo = null;
        /** Reference to the video element. **/
        private var _video : Video = null;
        /** Video size **/
        private var _videoWidth : Number = 0;
        private var _videoHeight : Number = 0;
        /** current media position */
        private var _media_position : Number;
        private var _duration : Number;

        /** Initialization. **/
        public function ChromelessPlayer() : void {
            // Set stage properties
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.fullScreenSourceRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, _onStageVideoState);
            stage.addEventListener(Event.RESIZE, _onStageResize);
            // Draw sheet for catching clicks
            _sheet = new Sprite();
            _sheet.graphics.beginFill(0x000000, 0);
            _sheet.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            _sheet.addEventListener(MouseEvent.CLICK, _clickHandler);
            _sheet.buttonMode = true;
            addChild(_sheet);
            // Connect getters to JS.
            ExternalInterface.addCallback("getLevel", _getLevel);
            ExternalInterface.addCallback("getLevels", _getLevels);
            ExternalInterface.addCallback("getMetrics", _getMetrics);
            ExternalInterface.addCallback("getDuration", _getDuration);
            ExternalInterface.addCallback("getPosition", _getPosition);
            ExternalInterface.addCallback("getState", _getState);
            ExternalInterface.addCallback("getType", _getType);
            ExternalInterface.addCallback("getmaxBufferLength", _getmaxBufferLength);
            ExternalInterface.addCallback("getminBufferLength", _getminBufferLength);
            ExternalInterface.addCallback("getbufferLength", _getbufferLength);
            ExternalInterface.addCallback("getLogDebug", _getLogDebug);
            ExternalInterface.addCallback("getLogDebug2", _getLogDebug2);
            ExternalInterface.addCallback("getflushLiveURLCache", _getflushLiveURLCache);
            ExternalInterface.addCallback("getstartFromLowestLevel", _getstartFromLowestLevel);
            ExternalInterface.addCallback("getseekFromLowestLevel", _getseekFromLowestLevel);
            ExternalInterface.addCallback("getJSURLStream", _getJSURLStream);
            ExternalInterface.addCallback("getPlayerVersion", _getPlayerVersion);
            ExternalInterface.addCallback("getAudioTrackList", _getAudioTrackList);
            ExternalInterface.addCallback("getAudioTrackId", _getAudioTrackId);
            // Connect calls to JS.
            ExternalInterface.addCallback("playerLoad", _load);
            ExternalInterface.addCallback("playerPlay", _play);
            ExternalInterface.addCallback("playerPause", _pause);
            ExternalInterface.addCallback("playerResume", _resume);
            ExternalInterface.addCallback("playerSeek", _seek);
            ExternalInterface.addCallback("playerStop", _stop);
            ExternalInterface.addCallback("playerVolume", _volume);
            ExternalInterface.addCallback("playerSetLevel", _setLevel);
            ExternalInterface.addCallback("playerSetmaxBufferLength", _setmaxBufferLength);
            ExternalInterface.addCallback("playerSetminBufferLength", _setminBufferLength);
            ExternalInterface.addCallback("playerSetflushLiveURLCache", _setflushLiveURLCache);
            ExternalInterface.addCallback("playerSetstartFromLowestLevel", _setstartFromLowestLevel);
            ExternalInterface.addCallback("playerSetseekFromLowestLevel", _setseekFromLowestLevel);
            ExternalInterface.addCallback("playerSetLogDebug", _setLogDebug);
            ExternalInterface.addCallback("playerSetLogDebug2", _setLogDebug2);
            ExternalInterface.addCallback("playerSetAudioTrack", _setAudioTrack);
            ExternalInterface.addCallback("playerSetJSURLStream", _setJSURLStream);

            setTimeout(_pingJavascript, 50);
        };

        /** Notify javascript the framework is ready. **/
        private function _pingJavascript() : void {
            ExternalInterface.call("onHLSReady", ExternalInterface.objectID);
        };

        /** Forward events from the framework. **/
        private function _completeHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onComplete");
            }
        };

        private function _errorHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onError", event.message);
            }
        };

        private function _fragmentHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onFragment", event.metrics.bandwidth, event.metrics.level, stage.stageWidth);
            }
        };

        private function _manifestHandler(event : HLSEvent) : void {
            _duration = event.levels[0].duration;
            if (ExternalInterface.available) {
                ExternalInterface.call("onManifest", event.levels[0].duration);
            }
        };

        private function _mediaTimeHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                _media_position = event.mediatime.position;
                ExternalInterface.call("onPosition", event.mediatime.position, event.mediatime.duration, event.mediatime.live_sliding);
            }

            var videoWidth : Number = _video ? _video.videoWidth : _stageVideo.videoWidth;
            var videoHeight : Number = _video ? _video.videoHeight : _stageVideo.videoHeight;

            if (videoWidth && videoHeight) {
                var changed : Boolean = _videoWidth != videoWidth || _videoHeight != videoHeight;
                if (changed) {
                    _videoHeight = videoHeight;
                    _videoWidth = videoWidth;
                    _resize();
                    if (ExternalInterface.available) {
                        ExternalInterface.call("onVideoSize", _videoWidth, _videoHeight);
                    }
                }
            }
        };

        private function _stateHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onState", event.state);
            }
        };

        private function _switchHandler(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onSwitch", event.level);
            }
        };

        private function _audioTracksListChange(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onAudioTracksListChange", _getAudioTrackList());
            }
        }

        private function _audioTrackChange(event : HLSEvent) : void {
            if (ExternalInterface.available) {
                ExternalInterface.call("onAudioTrackChange", event.audioTrack);
            }
        }

        /** Javascript getters. **/
        private function _getLevel() : Number {
            return _hls.level;
        };

        private function _getLevels() : Vector.<Level> {
            return _hls.levels;
        };

        private function _getMetrics() : Object {
            return _hls.metrics;
        };

        private function _getDuration() : Number {
          return _duration;
        };

        private function _getPosition() : Number {
            return _hls.position;
        };

        private function _getState() : String {
            return _hls.state;
        };

        private function _getType() : String {
            return _hls.type;
        };

        private function _getbufferLength() : Number {
            return _hls.bufferLength;
        };

        private function _getmaxBufferLength() : Number {
            return _hls.maxBufferLength;
        };

        private function _getminBufferLength() : Number {
            return _hls.minBufferLength;
        };

        private function _getflushLiveURLCache() : Boolean {
            return _hls.flushLiveURLCache;
        };

        private function _getstartFromLowestLevel() : Boolean {
            return _hls.startFromLowestLevel;
        };

        private function _getseekFromLowestLevel() : Boolean {
            return _hls.seekFromLowestLevel;
        };

        private function _getLogDebug() : Boolean {
            return Log.LOG_DEBUG_ENABLED;
        };

        private function _getLogDebug2() : Boolean {
            return Log.LOG_DEBUG2_ENABLED;
        };

        private function _getJSURLStream() : Boolean {
            return (_hls.URLstream is JSURLStream);
        };

        private function _getPlayerVersion() : Number {
            return 2;
        };

        private function _getAudioTrackList() : Array {
            var list : Array = [];
            var vec : Vector.<HLSAudioTrack> = _hls.audioTracks;
            for (var i : Object in vec) {
                list.push(vec[i]);
            }
            return list;
        };

        private function _getAudioTrackId() : Number {
            return _hls.audioTrack;
        };

        /** Javascript calls. **/
        private function _load(url : String) : void {
            _hls.load(url);
        };

        private function _play() : void {
            _hls.stream.play();
        };

        private function _pause() : void {
            _hls.stream.pause();
        };

        private function _resume() : void {
            _hls.stream.resume();
        };

        private function _seek(position : Number) : void {
            _hls.stream.seek(position);
        };

        private function _stop() : void {
            _hls.stream.close();
        };

        private function _volume(percent : Number) : void {
            _hls.stream.soundTransform = new SoundTransform(percent / 100);
        };

        private function _setLevel(level : Number) : void {
            _hls.level = level;
            if (!isNaN(_media_position)) {
                _hls.stream.seek(_media_position);
            }
        };

        private function _setmaxBufferLength(new_len : Number) : void {
            _hls.maxBufferLength = new_len;
        };

        private function _setminBufferLength(new_len : Number) : void {
            _hls.minBufferLength = new_len;
        };

        private function _setflushLiveURLCache(flushLiveURLCache : Boolean) : void {
            _hls.flushLiveURLCache = flushLiveURLCache;
        };

        private function _setstartFromLowestLevel(startFromLowestLevel : Boolean) : void {
            _hls.startFromLowestLevel = startFromLowestLevel;
        };

        private function _setseekFromLowestLevel(seekFromLowestLevel : Boolean) : void {
            _hls.seekFromLowestLevel = seekFromLowestLevel;
        };

        private function _setLogDebug(debug : Boolean) : void {
            Log.LOG_DEBUG_ENABLED = debug;
        };

        private function _setLogDebug2(debug2 : Boolean) : void {
            Log.LOG_DEBUG2_ENABLED = debug2;
        };

        private function _setJSURLStream(jsURLstream : Boolean) : void {
            if (jsURLstream) {
                _hls.URLstream = JSURLStream as Class;
            } else {
                _hls.URLstream = URLStream as Class;
            }
        };

        private function _setAudioTrack(val : Number) : void {
            if (val == _hls.audioTrack) return;
            _hls.audioTrack = val;
            if (!isNaN(_media_position)) {
                _hls.stream.seek(_media_position);
            }
        };

        /** Mouse click handler. **/
        private function _clickHandler(event : MouseEvent) : void {
            if (stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE || stage.displayState == StageDisplayState.FULL_SCREEN) {
                stage.displayState = StageDisplayState.NORMAL;
            } else {
                stage.displayState = StageDisplayState.FULL_SCREEN;
            }
        };

        /** StageVideo detector. **/
        private function _onStageVideoState(event : StageVideoAvailabilityEvent) : void {
            var available : Boolean = (event.availability == StageVideoAvailability.AVAILABLE);
            _hls = new HLS();
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _completeHandler);
            _hls.addEventListener(HLSEvent.ERROR, _errorHandler);
            _hls.addEventListener(HLSEvent.FRAGMENT_LOADED, _fragmentHandler);
            _hls.addEventListener(HLSEvent.MANIFEST_LOADED, _manifestHandler);
            _hls.addEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            _hls.addEventListener(HLSEvent.STATE, _stateHandler);
            _hls.addEventListener(HLSEvent.QUALITY_SWITCH, _switchHandler);
            _hls.addEventListener(HLSEvent.AUDIO_TRACKS_LIST_CHANGE, _audioTracksListChange);
            _hls.addEventListener(HLSEvent.AUDIO_TRACK_CHANGE, _audioTrackChange);

            if (available && stage.stageVideos.length > 0) {
                _stageVideo = stage.stageVideos[0];
                _stageVideo.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
                _stageVideo.attachNetStream(_hls.stream);
            } else {
                _video = new Video(stage.stageWidth, stage.stageHeight);
                addChild(_video);
                _video.smoothing = true;
                _video.attachNetStream(_hls.stream);
            }
            stage.removeEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, _onStageVideoState);
        };

        private function _onStageResize(event : Event) : void {
            stage.fullScreenSourceRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            _sheet.width = stage.stageWidth;
            _sheet.height = stage.stageHeight;
            _resize();
        };

        private function _resize() : void {
            var rect : Rectangle;
            rect = ScaleVideo.resizeRectangle(_videoWidth, _videoHeight, stage.stageWidth, stage.stageHeight);
            // resize video
            if (_video) {
                _video.width = rect.width;
                _video.height = rect.height;
                _video.x = rect.x;
                _video.y = rect.y;
            } else if (_stageVideo) {
                _stageVideo.viewPort = rect;
            }
        }
    }
}

add getDuration() function to ChromelessPlayer


//
// $Id$
//
// Nenya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/nenya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.threerings.flex {

import flash.display.DisplayObject;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.ui.Mouse;

import mx.core.Application;
import mx.managers.SystemManager;
import mx.styles.CSSStyleDeclaration;
import mx.styles.StyleManager;

import com.threerings.util.HashMap;

/**
 * A better CursorManager.
 */
public class CursorManager
{
    public static const SYSTEM_CURSOR :int = 0;

    public static const BUSY_CURSOR :int = 1;

    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Makes the cursor visible.
     *  Cursor visibility is not reference-counted.
     *  A single call to the showCursor() method
     *  always shows the cursor regardless of how many calls
     *  to the hideCursor() method were made.
     */
    public static function showCursor () :void
    {
        if (_currentCursorId == SYSTEM_CURSOR) {
            Mouse.show();
        } else {
            _cursorHolder.visible = true;
        }
    }

    /**
     *  Makes the cursor invisible.
     *  Cursor visibility is not reference-counted.
     *  A single call to the hideCursor() method
     *  always hides the cursor regardless of how many calls
     *  to the showCursor() method were made.
     */
    public static function hideCursor () :void
    {
        _cursorHolder.visible = false;
        Mouse.hide();
    }

    public static function getCurrentCursorId () :int
    {
        return _currentCursorId;
    }

    /**
     *  Creates a new cursor.
     *
     *  @param cursorClass Class of the cursor to display.
     *
     *  @param xOffset Number that specifies the x offset
     *  of the cursor, in pixels, relative to the mouse pointer.
     *  The default value is 0.
     *
     *  @param yOffset Number that specifies the y offset
     *  of the cursor, in pixels, relative to the mouse pointer.
     *  The default value is 0.
     *
     *  @return The ID of the cursor.
     */
    public static function addCursor (
            cursorClass :Class, xOffset :int = 0, yOffset :int = 0) :int
    {
        var cursorId :int = _nextCursorId++;

        var rec :CursorRecord = new CursorRecord(cursorClass);
        rec.x = xOffset;
        rec.y = yOffset;

        _cursors.put(cursorId, rec);

        return cursorId;
    }

    /**
     * Set the current cursor.
     */
    public static function setCursor (id :int) :void
    {
        if (id == _currentCursorId) {
            return;
        }

        if (!_initialized) {
            // oh, let's set it up
            _systemManager = Application.application.systemManager;

            // set up the busy cursor
            var cursorManagerStyleDeclaration :CSSStyleDeclaration =
                StyleManager.getStyleDeclaration("CursorManager");
            var busyCursorClass :Class =
                cursorManagerStyleDeclaration.getStyle("busyCursor");
            _busyCursor = new CursorRecord(busyCursorClass);

            // The first time a cursor is requested of the CursorManager,
            // create a Sprite to hold the cursor symbol
            _cursorHolder = new Sprite();
            _cursorHolder.mouseEnabled = false;
            _systemManager.cursorChildren.addChild(_cursorHolder);

            _initialized = true;
        }

        // figure out what the new cursor will be like
        var rec :CursorRecord;
        if (id == BUSY_CURSOR) {
            rec = _busyCursor;

        } else if (id != SYSTEM_CURSOR) {
            rec = (_cursors.get(id) as CursorRecord);
            if (rec == null) {
                // a bogus id was specified
                // TODO: throw an error?
                return;
            }
        }

        if (rec != null && (rec.cursor is Class)) {
            // go ahead and instantiate the class
            try {
                var disp :DisplayObject = new (rec.cursor as Class);
                rec.cursor = disp;
                if (disp is InteractiveObject) {
                    (disp as InteractiveObject).mouseEnabled = false;
                }

            } catch (err :Error) {
                // this cursor is not usable, bail
                return;
            }
        }

        // always remove any custom cursors from the hierarchy
        if (_cursorHolder.numChildren > 0) {
            _cursorHolder.removeChildAt(0);
        }

        if (id != SYSTEM_CURSOR) {
            Mouse.hide();
            var currentCursor :DisplayObject = (rec.cursor as DisplayObject);
            _cursorHolder.addChild(currentCursor);
            _cursorHolder.x = _systemManager.mouseX + rec.x;
            _cursorHolder.y = _systemManager.mouseY + rec.y;

            _currentXOffset = rec.x;
            _currentYOffset = rec.y;
            _systemManager.stage.addEventListener(
                MouseEvent.MOUSE_MOVE, mouseMoveHandler);

        } else {
            _currentXOffset = 0;
            _currentYOffset = 0;
            _systemManager.stage.removeEventListener(
                MouseEvent.MOUSE_MOVE, mouseMoveHandler);

            Mouse.show();
        }

        _currentCursorId = id;
    }

    /**
     *  Removes a cursor from the cursor list.
     *  If the cursor being removed is the currently displayed cursor,
     *  the CursorManager displays the next cursor in the list, if one exists.
     *  If the list becomes empty, the CursorManager displays
     *  the default system cursor.
     *
     *  @param cursorID ID of cursor to remove.
     */
    public static function removeCursor (id :int) :void
    {
        var rec :CursorRecord = (_cursors.remove(id) as CursorRecord);

        if (rec != null && id == _currentCursorId) {
            setCursor(SYSTEM_CURSOR);
        }
    }

    /**
     *  Removes all of the cursors from the cursor list
     *  and restores the system cursor.
     */
    public static function removeAllCursors () :void
    {
        _cursors.clear();

        if (_currentCursorId != BUSY_CURSOR) {
            setCursor(SYSTEM_CURSOR);
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Class event handlers
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    private static function mouseMoveHandler (event :MouseEvent) :void
    {
        _cursorHolder.x = _systemManager.mouseX + _currentXOffset;
        _cursorHolder.y = _systemManager.mouseY + _currentYOffset;

        var target :Object = event.target;

        // Do target test.
        if (!_overTextField &&
                target is TextField && target.type == TextFieldType.INPUT) {
            _overTextField = true;
            _showSystemCursor = true;

        } else if (_overTextField &&
                !(target is TextField && target.type == TextFieldType.INPUT)) {
            _overTextField = false;
            _showCustomCursor = true;
        }

        // Handle switching between system and custom cursor.
        if (_showSystemCursor) {
            _showSystemCursor = false;
            _cursorHolder.visible = false;
            Mouse.show();
        }
        if (_showCustomCursor) {
            _showCustomCursor = false;
            _cursorHolder.visible = true;
            Mouse.hide();
        }
    }

    /** A mapping of all assigned cursor ids. */
    private static const _cursors :HashMap = new HashMap();

    private static var _currentCursorId :int = 0; // SYSTEM_CURSOR

    private static var _nextCursorId :int = 2; // skip BUSY

    private static var _initialized :Boolean = false;

    private static var _cursorHolder :Sprite;

    private static var _currentXOffset :int = 0;
    private static var _currentYOffset :int = 0;

    /** A record for the busy cursor (where it can't be removed). */
    private static var _busyCursor :CursorRecord;

    private static var _overTextField :Boolean = false;

    private static var _overLink :Boolean = false;

    private static var _showSystemCursor :Boolean = false;

    private static var _showCustomCursor :Boolean = false;

    private static var _systemManager :SystemManager = null;
}
}

/**
 */
class CursorRecord extends Object
{
    public function CursorRecord (clazz :Class)
    {
        cursor = clazz;
    }

    /** The class, or instantiated cursor. */
    public var cursor :Object

    /** The x/y offset for the hotspot. */
    public var x :Number;
    public var y :Number;
}

//
// $Id$
//
// Nenya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/nenya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.threerings.flex {

import flash.display.DisplayObject;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.ui.Mouse;

import mx.core.Application;
import mx.managers.SystemManager;
import mx.styles.CSSStyleDeclaration;
import mx.styles.StyleManager;

import com.threerings.util.Map;
import com.threerings.util.Maps;

/**
 * A better CursorManager.
 */
public class CursorManager
{
    public static const SYSTEM_CURSOR :int = 0;

    public static const BUSY_CURSOR :int = 1;

    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Makes the cursor visible.
     *  Cursor visibility is not reference-counted.
     *  A single call to the showCursor() method
     *  always shows the cursor regardless of how many calls
     *  to the hideCursor() method were made.
     */
    public static function showCursor () :void
    {
        if (_currentCursorId == SYSTEM_CURSOR) {
            Mouse.show();
        } else {
            _cursorHolder.visible = true;
        }
    }

    /**
     *  Makes the cursor invisible.
     *  Cursor visibility is not reference-counted.
     *  A single call to the hideCursor() method
     *  always hides the cursor regardless of how many calls
     *  to the showCursor() method were made.
     */
    public static function hideCursor () :void
    {
        _cursorHolder.visible = false;
        Mouse.hide();
    }

    public static function getCurrentCursorId () :int
    {
        return _currentCursorId;
    }

    /**
     *  Creates a new cursor.
     *
     *  @param cursorClass Class of the cursor to display.
     *
     *  @param xOffset Number that specifies the x offset
     *  of the cursor, in pixels, relative to the mouse pointer.
     *  The default value is 0.
     *
     *  @param yOffset Number that specifies the y offset
     *  of the cursor, in pixels, relative to the mouse pointer.
     *  The default value is 0.
     *
     *  @return The ID of the cursor.
     */
    public static function addCursor (
            cursorClass :Class, xOffset :int = 0, yOffset :int = 0) :int
    {
        var cursorId :int = _nextCursorId++;

        var rec :CursorRecord = new CursorRecord(cursorClass);
        rec.x = xOffset;
        rec.y = yOffset;

        _cursors.put(cursorId, rec);

        return cursorId;
    }

    /**
     * Set the current cursor.
     */
    public static function setCursor (id :int) :void
    {
        if (id == _currentCursorId) {
            return;
        }

        if (!_initialized) {
            // oh, let's set it up
            _systemManager = Application.application.systemManager;

            // set up the busy cursor
            var cursorManagerStyleDeclaration :CSSStyleDeclaration =
                StyleManager.getStyleDeclaration("CursorManager");
            var busyCursorClass :Class =
                cursorManagerStyleDeclaration.getStyle("busyCursor");
            _busyCursor = new CursorRecord(busyCursorClass);

            // The first time a cursor is requested of the CursorManager,
            // create a Sprite to hold the cursor symbol
            _cursorHolder = new Sprite();
            _cursorHolder.mouseEnabled = false;
            _systemManager.cursorChildren.addChild(_cursorHolder);

            _initialized = true;
        }

        // figure out what the new cursor will be like
        var rec :CursorRecord;
        if (id == BUSY_CURSOR) {
            rec = _busyCursor;

        } else if (id != SYSTEM_CURSOR) {
            rec = (_cursors.get(id) as CursorRecord);
            if (rec == null) {
                // a bogus id was specified
                // TODO: throw an error?
                return;
            }
        }

        if (rec != null && (rec.cursor is Class)) {
            // go ahead and instantiate the class
            try {
                var disp :DisplayObject = new (rec.cursor as Class);
                rec.cursor = disp;
                if (disp is InteractiveObject) {
                    (disp as InteractiveObject).mouseEnabled = false;
                }

            } catch (err :Error) {
                // this cursor is not usable, bail
                return;
            }
        }

        // always remove any custom cursors from the hierarchy
        if (_cursorHolder.numChildren > 0) {
            _cursorHolder.removeChildAt(0);
        }

        if (id != SYSTEM_CURSOR) {
            Mouse.hide();
            var currentCursor :DisplayObject = (rec.cursor as DisplayObject);
            _cursorHolder.addChild(currentCursor);
            _cursorHolder.x = _systemManager.mouseX + rec.x;
            _cursorHolder.y = _systemManager.mouseY + rec.y;

            _currentXOffset = rec.x;
            _currentYOffset = rec.y;
            _systemManager.stage.addEventListener(
                MouseEvent.MOUSE_MOVE, mouseMoveHandler);

        } else {
            _currentXOffset = 0;
            _currentYOffset = 0;
            _systemManager.stage.removeEventListener(
                MouseEvent.MOUSE_MOVE, mouseMoveHandler);

            Mouse.show();
        }

        _currentCursorId = id;
    }

    /**
     *  Removes a cursor from the cursor list.
     *  If the cursor being removed is the currently displayed cursor,
     *  the CursorManager displays the next cursor in the list, if one exists.
     *  If the list becomes empty, the CursorManager displays
     *  the default system cursor.
     *
     *  @param cursorID ID of cursor to remove.
     */
    public static function removeCursor (id :int) :void
    {
        var rec :CursorRecord = (_cursors.remove(id) as CursorRecord);

        if (rec != null && id == _currentCursorId) {
            setCursor(SYSTEM_CURSOR);
        }
    }

    /**
     *  Removes all of the cursors from the cursor list
     *  and restores the system cursor.
     */
    public static function removeAllCursors () :void
    {
        _cursors.clear();

        if (_currentCursorId != BUSY_CURSOR) {
            setCursor(SYSTEM_CURSOR);
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Class event handlers
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    private static function mouseMoveHandler (event :MouseEvent) :void
    {
        _cursorHolder.x = _systemManager.mouseX + _currentXOffset;
        _cursorHolder.y = _systemManager.mouseY + _currentYOffset;

        var target :Object = event.target;

        // Do target test.
        if (!_overTextField &&
                target is TextField && target.type == TextFieldType.INPUT) {
            _overTextField = true;
            _showSystemCursor = true;

        } else if (_overTextField &&
                !(target is TextField && target.type == TextFieldType.INPUT)) {
            _overTextField = false;
            _showCustomCursor = true;
        }

        // Handle switching between system and custom cursor.
        if (_showSystemCursor) {
            _showSystemCursor = false;
            _cursorHolder.visible = false;
            Mouse.show();
        }
        if (_showCustomCursor) {
            _showCustomCursor = false;
            _cursorHolder.visible = true;
            Mouse.hide();
        }
    }

    /** A mapping of all assigned cursor ids. */
    private static const _cursors :Map = Maps.newMapOf(int);

    private static var _currentCursorId :int = 0; // SYSTEM_CURSOR

    private static var _nextCursorId :int = 2; // skip BUSY

    private static var _initialized :Boolean = false;

    private static var _cursorHolder :Sprite;

    private static var _currentXOffset :int = 0;
    private static var _currentYOffset :int = 0;

    /** A record for the busy cursor (where it can't be removed). */
    private static var _busyCursor :CursorRecord;

    private static var _overTextField :Boolean = false;

    private static var _overLink :Boolean = false;

    private static var _showSystemCursor :Boolean = false;

    private static var _showCustomCursor :Boolean = false;

    private static var _systemManager :SystemManager = null;
}
}

/**
 */
class CursorRecord extends Object
{
    public function CursorRecord (clazz :Class)
    {
        cursor = clazz;
    }

    /** The class, or instantiated cursor. */
    public var cursor :Object

    /** The x/y offset for the hotspot. */
    public var x :Number;
    public var y :Number;
}

Use new Maps factory.
Does anyone care about this crappy class?

git-svn-id: b675b909355d5cf946977f44a8ec5a6ceb3782e4@852 ed5b42cb-e716-0410-a449-f6a68f950b19


package org.mangui.osmf.plugins {
    import org.osmf.traits.SeekTrait;
    import org.osmf.traits.TimeTrait;
    import org.mangui.HLS.HLS;
    import org.mangui.HLS.HLSStates;
    import org.mangui.HLS.HLSEvent;
    import org.mangui.HLS.utils.*;

    public class HLSSeekTrait extends SeekTrait {
        private var _hls : HLS;

        public function HLSSeekTrait(hls : HLS, timeTrait : TimeTrait) {
            super(timeTrait);
            _hls = hls;
            _hls.addEventListener(HLSEvent.STATE, _stateChangedHandler);
        }

        /**
         * @private
         * Communicates a seeking change to the media through the NetStream.
         * @param newSeeking New seeking value.
         * @param time Time to seek to, in seconds.
         */
        override protected function seekingChangeStart(newSeeking : Boolean, time : Number) : void {
            if (newSeeking) {
                _hls.stream.seek(time);
            }
            super.seekingChangeStart(newSeeking, time);
        }

        /** state changed handler **/
        private function _stateChangedHandler(event : HLSEvent) : void {
            if (seeking && (event.state != HLSStates.PAUSED_BUFFERING && event.state != HLSStates.PLAYING_BUFFERING)) {
                Log.debug("HLSSeekTrait:setSeeking(false);");
                setSeeking(false, timeTrait.currentTime);
            }
        }
    }
}

package org.mangui.osmf.plugins {
    import org.osmf.traits.SeekTrait;
    import org.osmf.traits.TimeTrait;
    import org.mangui.HLS.HLS;
    import org.mangui.HLS.HLSStates;
    import org.mangui.HLS.HLSEvent;
    import org.mangui.HLS.utils.*;

    public class HLSSeekTrait extends SeekTrait {
        private var _hls : HLS;

        public function HLSSeekTrait(hls : HLS, timeTrait : TimeTrait) {
            super(timeTrait);
            _hls = hls;
            _hls.addEventListener(HLSEvent.STATE, _stateChangedHandler);
        }

        /**
         * @private
         * Communicates a seeking change to the media through the NetStream.
         * @param newSeeking New seeking value.
         * @param time Time to seek to, in seconds.
         */
        override protected function seekingChangeStart(newSeeking : Boolean, time : Number) : void {
            if (newSeeking) {
                Log.info("HLSSeekTrait:seekingChangeStart(newSeeking/time):(" + newSeeking  + "/" + time + ")");
                _hls.stream.seek(time);
            }
            super.seekingChangeStart(newSeeking, time);
        }

        /** state changed handler **/
        private function _stateChangedHandler(event : HLSEvent) : void {
            if (seeking && (event.state != HLSStates.PAUSED_BUFFERING && event.state != HLSStates.PLAYING_BUFFERING)) {
                Log.debug("HLSSeekTrait:setSeeking(false);");
                setSeeking(false, timeTrait.currentTime);
            }
        }
    }
}

add logs

add logs


package org.osflash.signals {
	import asunit4.ui.MinimalRunnerUI;
	import org.osflash.signals.AllTests;

	public class AllTestsRunner extends MinimalRunnerUI
	{
		public function AllTestsRunner()
		{
			run(org.osflash.signals.AllTests);
		}
	}
}

package org.osflash.signals {
	import asunit4.ui.MinimalRunnerUI;
	import org.osflash.signals.AllTests;

	[SWF(width='1000', height='800', backgroundColor='#333333', frameRate='31')]
	public class AllTestsRunner extends MinimalRunnerUI
	{
		public function AllTestsRunner()
		{
			run(org.osflash.signals.AllTests);
		}
	}
}

Put [SWF] tag in test runner app.

Put [SWF] tag in test runner app.


m4_pattern_allow([^URBI_(PATH|SERVER)$])         -*- shell-script -*-

AS_INIT()dnl
URBI_PREPARE()

set -e

case $VERBOSE in
  x) set -x;;
esac

# Avoid zombies and preserve debugging information.
cleanup ()
{
  exit_status=$?

  # In case we were caught by set -e, kill the children.
  children_kill
  children_harvest
  children_report

  children_sta=$(children_status remote)
  # Don't clean before calling children_status...
  test x$VERBOSE != x || children_clean

  case $exit_status:$children_sta in
    0:0) ;;
    0:*) # Maybe a children exited for SKIP etc.
	 exit $children_sta;;
    *:*) # If liburbi-check failed, there is a big problem.
	 error SOFTWARE "liburbi-check itself failed with $exit_status";;
  esac
  # rst_expect sets exit=false if it saw a failure.
  $exit
}
for signal in 1 2 13 15; do
  trap 'error $((128 + $signal)) \
	      "received signal $signal ($(kill -l $signal))"' $signal
done
trap cleanup 0

# Overriden to include the test name.
stderr ()
{
  echo >&2 "$(basename $0): $me: $@"
  echo >&2
}

# Sleep some time, but taking into account the fact that
# instrumentation slows down a lot.
my_sleep ()
{
  if $INSTRUMENT; then
    sleep $(($1 * 5))
  else
    sleep $1
  fi
}

## -------------- ##
## Main program.  ##
## -------------- ##

exec 3>&2

: ${abs_builddir='@abs_builddir@'}
check_dir abs_builddir liburbi-check
: ${abs_top_builddir='@abs_top_builddir@'}
check_dir abs_top_builddir config.status
: ${abs_top_srcdir='@abs_top_srcdir@'}
check_dir abs_top_srcdir configure.ac

# Make it absolute.
chk=$(absolute "$1")
if test ! -f "$chk.cc"; then
  fatal "no such file: $chk.cc"
fi

period=32
# ./../../../tests/2.x/andexp-pipeexp.chk -> 2.x
medir=$(basename $(dirname "$chk"))
# ./../../../tests/2.x/andexp-pipeexp.chk -> 2.x/andexp-pipeexp
me=$medir/$(basename "$chk" ".cc")
# ./../../../tests/2.x/andexp-pipeexp.chk -> andexp-pipeexp
meraw=$(basename $me)    # MERAW!

srcdir=$(absolute $srcdir)
export srcdir
# Move to a private dir.
rm -rf $me.dir
mkdir -p $me.dir
cd $me.dir

# Help debugging
set | rst_pre "$me variables"

# $URBI_SERVER.
#
# If this SDK-Remote is part of the Kernel package, then we should not
# use an installed urbi-console, but rather the one which is part of
# this package.
if test -d $abs_top_srcdir/../../src/kernel; then
  stderr "This SDK-Remote is part of a kernel package" \
         "  ($abs_top_srcdir/../../src/kernel exists)."
  URBI_SERVER=$abs_top_builddir/../src/urbi-console
  export URBI_PATH=$abs_top_srcdir/../share
else
  stderr "This SDK-Remote is standalone."
fi
# Leaves trailing files, so run it in subdir.
find_urbi_server

# Compute expected output.
sed -n -e 's@//= @@p' $chk.cc >output.exp
touch error.exp
echo 0 >status.exp

# Start it.
valgrind=$(instrument "server.val")
cmd="$valgrind $URBI_SERVER --port 0 -w server.port --period $period"
echo "$cmd" >server.cmd
$cmd >server.out 2>server.err &
children_register server

my_sleep 2

# Start the test.
valgrind=$(instrument "remote.val")
cmd="$valgrind ../../tests localhost $(cat server.port) $meraw"
echo "$cmd" >remote.cmd
$cmd >remote.out.raw 2>remote.err &
children_register remote

# Let some time to run the tests.
children_wait 10

# Ignore the "client errors".
sed -e '/^E client error/d' remote.out.raw >remote.out.eff
# Compare expected output with actual output.
rst_expect output remote.out
rst_pre "Error output" remote.err

# Display Valgrind report.
rst_pre "Valgrind" remote.val

# Exit with success: liburbi-check made its job.  But now clean (on
# trap 0) will check $exit to see if there is a failure in the tests
# and adjust the exit status accordingly.
exit 0

m4_pattern_allow([^URBI_(PATH|SERVER)$])         -*- shell-script -*-
URBI_INIT

# Avoid zombies and preserve debugging information.
cleanup ()
{
  exit_status=$?

  # In case we were caught by set -e, kill the children.
  children_kill
  children_harvest
  children_report

  children_sta=$(children_status remote)
  # Don't clean before calling children_status...
  test x$VERBOSE != x || children_clean

  case $exit_status:$children_sta in
    0:0) ;;
    0:*) # Maybe a children exited for SKIP etc.
	 exit $children_sta;;
    *:*) # If liburbi-check failed, there is a big problem.
	 error SOFTWARE "liburbi-check itself failed with $exit_status";;
  esac
  # rst_expect sets exit=false if it saw a failure.
  $exit
}
for signal in 1 2 13 15; do
  trap 'error $((128 + $signal)) \
	      "received signal $signal ($(kill -l $signal))"' $signal
done
trap cleanup 0

# Overriden to include the test name.
stderr ()
{
  echo >&2 "$(basename $0): $me: $@"
  echo >&2
}

# Sleep some time, but taking into account the fact that
# instrumentation slows down a lot.
my_sleep ()
{
  if $INSTRUMENT; then
    sleep $(($1 * 5))
  else
    sleep $1
  fi
}

## -------------- ##
## Main program.  ##
## -------------- ##

exec 3>&2

check_dir abs_builddir liburbi-check
check_dir abs_top_builddir config.status
check_dir abs_top_srcdir configure.ac

# Make it absolute.
chk=$(absolute "$1")
if test ! -f "$chk.cc"; then
  fatal "no such file: $chk.cc"
fi

period=32
# ./../../../tests/2.x/andexp-pipeexp.chk -> 2.x
medir=$(basename $(dirname "$chk"))
# ./../../../tests/2.x/andexp-pipeexp.chk -> 2.x/andexp-pipeexp
me=$medir/$(basename "$chk" ".cc")
# ./../../../tests/2.x/andexp-pipeexp.chk -> andexp-pipeexp
meraw=$(basename $me)    # MERAW!

srcdir=$(absolute $srcdir)
export srcdir
# Move to a private dir.
rm -rf $me.dir
mkdir -p $me.dir
cd $me.dir

# Help debugging
set | rst_pre "$me variables"

# $URBI_SERVER.
#
# If this SDK-Remote is part of the Kernel package, then we should not
# use an installed urbi-console, but rather the one which is part of
# this package.
if test -d $abs_top_srcdir/../../src/kernel; then
  stderr "This SDK-Remote is part of a kernel package" \
         "  ($abs_top_srcdir/../../src/kernel exists)."
  export PATH=$abs_top_builddir/../tests/bin:$PATH
else
  stderr "This SDK-Remote is standalone."
fi
# Leaves trailing files, so run it in subdir.
find_urbi_server

# Compute expected output.
sed -n -e 's,//= ,,p' $chk.cc >output.exp
touch error.exp
echo 0 >status.exp

# Start it.
valgrind=$(instrument "server.val")
cmd="$valgrind $URBI_SERVER --port 0 -w server.port --period $period"
echo "$cmd" >server.cmd
$cmd >server.out 2>server.err &
children_register server

my_sleep 2

# Start the test.
valgrind=$(instrument "remote.val")
cmd="$valgrind ../../tests localhost $(cat server.port) $meraw"
echo "$cmd" >remote.cmd
$cmd >remote.out.raw 2>remote.err &
children_register remote

# Let some time to run the tests.
children_wait 10

# Ignore the "client errors".
sed -e '/^E client error/d' remote.out.raw >remote.out.eff
# Compare expected output with actual output.
rst_expect output remote.out
rst_pre "Error output" remote.err

# Display Valgrind report.
rst_pre "Valgrind" remote.val

# Exit with success: liburbi-check made its job.  But now clean (on
# trap 0) will check $exit to see if there is a failure in the tests
# and adjust the exit status accordingly.
exit 0

Update to use the urbi-console wrapper.

Update to use the urbi-console wrapper.

	* src/tests/liburbi-check.as: Use URBI_INIT.
	Remove factored code.
	Style changes.
	No longer define URBI_SERVER and URBI_PATH to force the use of the
	shipped one (instead of the installed version in case of a
	standalone SDK Remote).  Rather, define the PATH to use the
	urbi-console wrapper from the kernel if present.


////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
package modules.supportClasses
{

[Bindable]
public class FieldSettings
{
    public var name:String;
    public var alias:String;
    public var tooltip:String;

    public function fromXML(configXML:XML):void
    {
        name = configXML.@name[0];
        alias = configXML.@alias[0];
        tooltip = configXML.@tooltip[0];
    }

    public function toXML():XML
    {
        var configXML:XML = <field name={name}/>

        if (alias)
        {
            configXML.@alias = alias;
        }
        if (tooltip)
        {
            configXML.@tooltip = tooltip;
        }

        return configXML;
    }
}
}

////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
package modules.supportClasses
{

[Bindable]
public class FieldSettings
{
    public var name:String;
    public var alias:String;
    public var tooltip:String;
    public var dateFormat:String;
    public var useUTC:Boolean;
    public var required:Boolean;

    public function fromXML(configXML:XML):void
    {
        name = configXML.@name[0];
        alias = configXML.@alias[0];
        tooltip = configXML.@tooltip[0];
        dateFormat = configXML.@dateformat[0];
        useUTC = configXML.@useutc[0] == "true";
        required = configXML.@required[0] == "true";
    }

    public function toXML():XML
    {
        var configXML:XML = <field name={name} required={required} useutc={useUTC}/>

        if (alias)
        {
            configXML.@alias = alias;
        }
        if (tooltip)
        {
            configXML.@tooltip = tooltip;
        }
        if (dateFormat)
        {
            configXML.@dateformat = dateFormat;
        }

        return configXML;
    }
}
}

Update FieldSettings to store supported properties.


/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirInAppPurchase {

	import flash.events.EventDispatcher;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;

    /**
     *
     */
	public class InAppPurchase extends EventDispatcher {

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									   PUBLIC API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        /**
         * If true, logs will be displayed at the ActionScript level.
         */
        public static var logEnabled:Boolean = false;

        /**
         *
         */
        public static function get isSupported():Boolean {
            return _isIOS() || _isAndroid();
        }

        /**
         *
         */
        public static function get instance():InAppPurchase {
            return _instance ? _instance : new InAppPurchase();
        }

        /**
         * INIT_SUCCESSFUL
         * INIT_ERROR
         * @param googlePlayKey
         * @param debug
         */
        public function init(googlePlayKey:String, debug:Boolean = false):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.INIT_ERROR, "InAppPurchase not supported");
            else
                _context.call("initLib", googlePlayKey, debug);
        }

        /**
         * PURCHASE_SUCCESSFUL
         * PURCHASE_ERROR
         * @param productId
         */
        public function makePurchase(productId:String):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PURCHASE_ERROR, "InAppPurchase not supported");
            else
                _context.call("makePurchase", productId);
        }

        /**
         * PURCHASE_SUCCESSFUL
         * PURCHASE_ERROR
         * @param productId
         */
        public function makeSubscription(productId:String):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PURCHASE_ERROR, "InAppPurchase not supported");
            else
                _context.call("makeSubscription", productId);
        }

        /**
         * CONSUME_SUCCESSFUL
         * CONSUME_ERROR
         * @param productId
         * @param receipt
         * @param developerPayload used on Android
         */
        public function removePurchaseFromQueue(productId:String, receipt:String, developerPayload:String = null):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.CONSUME_ERROR, "InAppPurchase not supported");
            else {

                _context.call("removePurchaseFromQueue", productId, receipt, developerPayload ? developerPayload : "");

                if (_isIOS()) {

                    var filterPurchase:Function = function(jsonPurchase:String, index:int, purchases:Vector.<Object>):Boolean {

                        try {

                            var purchase:Object = JSON.parse(jsonPurchase);
                            return JSON.stringify(purchase.receipt) != receipt;
                        }
                        catch (error:Error) {
                            _log("ERROR", "couldn't parse purchase: " + jsonPurchase);
                        }

                        return false;
                    };

                    _iosPendingPurchases = _iosPendingPurchases.filter(filterPurchase);
                }
            }
        }

        /**
         * PRODUCT_INFO_RECEIVED
         * PRODUCT_INFO_ERROR
         * @param productsIds
         * @param subscriptionIds
         */
        public function getProductsInfo(productsIds:Array, subscriptionIds:Array):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PRODUCT_INFO_ERROR, "InAppPurchase not supported");
            else {

                productsIds ||= [];
                subscriptionIds ||= [];
                _context.call("getProductsInfo", productsIds, subscriptionIds);
            }
        }

        /**
         * RESTORE_INFO_RECEIVED
         * RESTORE_INFO_ERROR
         */
        public function restoreTransactions(restoreIOSHistory:Boolean=false):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.RESTORE_INFO_ERROR, "InAppPurchase not supported");
            else if (_isAndroid() || restoreIOSHistory)
                _context.call("restoreTransaction");
            else if (_isIOS()) {

                var jsonPurchases:String = "[" + _iosPendingPurchases.join(",") + "]";
                var jsonData:String = "{ \"purchases\": " + jsonPurchases + "}";

                _dispatchEvent(InAppPurchaseEvent.RESTORE_INFO_RECEIVED, jsonData);
            }
        }

        public function clearTransactions():void
        {
            _iosPendingPurchases = new Vector.<Object>();
            if (!isSupported || _isAndroid()) {
                _dispatchEvent(InAppPurchaseEvent.CLEAR_TRANSACTIONS_ERROR, "clear transactions not supported");
            } else if (_isIOS()) {
                _context.call("clearTransactions");
            }
        }

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									 	PRIVATE API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        private static const EXTENSION_ID:String = "com.freshplanet.ane.AirInAppPurchase";
        private static var _instance:InAppPurchase = null;
		private var _context:ExtensionContext = null;

        private var _iosPendingPurchases:Vector.<Object> = new Vector.<Object>();

        /**
         * "private" singleton constructor
         */
		public function InAppPurchase() {

            super();

            if (_instance)
                throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");

            _instance = this;

            _context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);

            if (!_context)
                _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.");
            else
                _context.addEventListener(StatusEvent.STATUS, _onStatus);
		}

        /**
         *
         * @param type
         * @param eventData
         */
        private function _dispatchEvent(type:String, eventData:String):void {
            this.dispatchEvent(new InAppPurchaseEvent(type, eventData))
        }

        /**
         *
         * @param event
         */
		private function _onStatus(event:StatusEvent):void {

            if (event.code == InAppPurchaseEvent.PURCHASE_SUCCESSFUL && _isIOS())
                _iosPendingPurchases.push(event.level);

            _dispatchEvent(event.code, event.level);
		}

        /**
         *
         * @param strings
         */
        private function _log(...strings):void {

            if (logEnabled) {

                strings.unshift(EXTENSION_ID);
                trace.apply(null, strings);
            }
        }

        /**
         *
         * @return
         */
        private static function _isIOS():Boolean {
			return Capabilities.manufacturer.indexOf("iOS") > -1 && Capabilities.os.indexOf("x86_64") < 0 && Capabilities.os.indexOf("i386") < 0;
        }

        /**
         *
         * @return
         */
        private static function _isAndroid():Boolean {
            return Capabilities.manufacturer.indexOf("Android") > -1;
        }
	}
}

/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirInAppPurchase {

	import flash.events.EventDispatcher;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;

    /**
     *
     */
	public class InAppPurchase extends EventDispatcher {

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									   PUBLIC API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        /**
         * If true, logs will be displayed at the ActionScript level.
         */
        public static var logEnabled:Boolean = false;

        /**
         *
         */
        public static function get isSupported():Boolean {
            return _isIOS() || _isAndroid();
        }

        /**
         *
         */
        public static function get instance():InAppPurchase {
            return _instance ? _instance : new InAppPurchase();
        }

        /**
         * INIT_SUCCESSFUL
         * INIT_ERROR
         * @param googlePlayKey
         * @param debug
         */
        public function init(googlePlayKey:String, debug:Boolean = false):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.INIT_ERROR, "InAppPurchase not supported");
            else
                _context.call("initLib", googlePlayKey, debug);
        }

        /**
         * PURCHASE_SUCCESSFUL
         * PURCHASE_ERROR
         * @param productId
         */
        public function makePurchase(productId:String):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PURCHASE_ERROR, "InAppPurchase not supported");
            else
                _context.call("makePurchase", productId);
        }

        /**
         * PURCHASE_SUCCESSFUL
         * PURCHASE_ERROR
         * @param productId
         */
        public function makeSubscription(productId:String):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PURCHASE_ERROR, "InAppPurchase not supported");
            else
                _context.call("makeSubscription", productId);
        }

        /**
         * CONSUME_SUCCESSFUL
         * CONSUME_ERROR
         * @param productId
         * @param receipt
         * @param developerPayload used on Android
         */
        public function removePurchaseFromQueue(productId:String, receipt:String, developerPayload:String = null):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.CONSUME_ERROR, "InAppPurchase not supported");
            else {

                _context.call("removePurchaseFromQueue", productId, receipt, developerPayload ? developerPayload : "");

                if (_isIOS()) {

                    var filterPurchase:Function = function(jsonPurchase:String, index:int, purchases:Vector.<Object>):Boolean {

                        try {

                            var purchase:Object = JSON.parse(jsonPurchase);
                            return JSON.stringify(purchase.receipt) != receipt;
                        }
                        catch (error:Error) {
                            _log("ERROR", "couldn't parse purchase: " + jsonPurchase);
                        }

                        return false;
                    };

                    _iosPendingPurchases = _iosPendingPurchases.filter(filterPurchase);
                }
            }
        }

        /**
         * PRODUCT_INFO_RECEIVED
         * PRODUCT_INFO_ERROR
         * @param productsIds
         * @param subscriptionIds
         */
        public function getProductsInfo(productsIds:Array, subscriptionIds:Array):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.PRODUCT_INFO_ERROR, "InAppPurchase not supported");
            else {

                productsIds ||= [];
                subscriptionIds ||= [];
                _context.call("getProductsInfo", productsIds, subscriptionIds);
            }
        }

        /**
         * RESTORE_INFO_RECEIVED
         * RESTORE_INFO_ERROR
         */
        public function restoreTransactions(restoreIOSHistory:Boolean=false):void {

            if (!isSupported)
                _dispatchEvent(InAppPurchaseEvent.RESTORE_INFO_ERROR, "InAppPurchase not supported");
            else if (_isAndroid() || restoreIOSHistory)
                _context.call("restoreTransaction");
            else if (_isIOS()) {

                var jsonPurchases:String = "[" + _iosPendingPurchases.join(",") + "]";
                var jsonData:String = "{ \"purchases\": " + jsonPurchases + "}";

                _dispatchEvent(InAppPurchaseEvent.RESåTORE_INFO_RECEIVED, jsonData);
            }
        }

        public function clearTransactions():void
        {
            _iosPendingPurchases = new Vector.<Object>();
            if (!isSupported || _isAndroid()) {
                _dispatchEvent("CLEAR_TRANSACTIONS_ERROR", "clear transactions not supported");
            } else if (_isIOS()) {
                _context.call("clearTransactions");
            }
        }

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									 	PRIVATE API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        private static const EXTENSION_ID:String = "com.freshplanet.ane.AirInAppPurchase";
        private static var _instance:InAppPurchase = null;
		private var _context:ExtensionContext = null;

        private var _iosPendingPurchases:Vector.<Object> = new Vector.<Object>();

        /**
         * "private" singleton constructor
         */
		public function InAppPurchase() {

            super();

            if (_instance)
                throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");

            _instance = this;

            _context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);

            if (!_context)
                _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.");
            else
                _context.addEventListener(StatusEvent.STATUS, _onStatus);
		}

        /**
         *
         * @param type
         * @param eventData
         */
        private function _dispatchEvent(type:String, eventData:String):void {
            this.dispatchEvent(new InAppPurchaseEvent(type, eventData))
        }

        /**
         *
         * @param event
         */
		private function _onStatus(event:StatusEvent):void {

            if (event.code == InAppPurchaseEvent.PURCHASE_SUCCESSFUL && _isIOS())
                _iosPendingPurchases.push(event.level);

            _dispatchEvent(event.code, event.level);
		}

        /**
         *
         * @param strings
         */
        private function _log(...strings):void {

            if (logEnabled) {

                strings.unshift(EXTENSION_ID);
                trace.apply(null, strings);
            }
        }

        /**
         *
         * @return
         */
        private static function _isIOS():Boolean {
			return Capabilities.manufacturer.indexOf("iOS") > -1 && Capabilities.os.indexOf("x86_64") < 0 && Capabilities.os.indexOf("i386") < 0;
        }

        /**
         *
         * @return
         */
        private static function _isAndroid():Boolean {
            return Capabilities.manufacturer.indexOf("Android") > -1;
        }
	}
}

fix typo & event name

fix typo & event name


package aerys.minko.render.material.realistic
{
	import aerys.minko.render.Effect;
	import aerys.minko.render.material.environment.EnvironmentMappingProperties;
	import aerys.minko.render.material.phong.PhongEffect;
	import aerys.minko.render.material.phong.PhongMaterial;
	import aerys.minko.render.resource.texture.ITextureResource;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.binding.IDataProvider;

	import flash.utils.Dictionary;

	public class RealisticMaterial extends PhongMaterial
	{
		private static const DEFAULT_NAME		: String		= 'RealisticMaterial';
        private static const DEFAULT_EFFECT     : Effect        = new PhongEffect(
            new RealisticShader()
        );

		public function get environmentMap() : ITextureResource
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP) as ITextureResource;
		}
		public function set environmentMap(value : ITextureResource) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP, value);
		}

        public function get environmentMapFiltering() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FILTERING);
        }
        public function set environmentMapFiltering(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FILTERING, value);
        }

        public function get environmentMapMipMapping() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_MIPMAPPING);
        }
        public function set environmentMapMipMapping(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_MIPMAPPING, value);
        }

        public function get environmentMapWrapping() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_WRAPPING);
        }
        public function set environmentMapWrapping(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_WRAPPING, value);
        }

        public function get environmentMapFormat() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FORMAT);
        }
        public function set environmentMapFormat(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FORMAT, value);
        }

		public function get reflectivity() : Number
		{
			return getProperty(EnvironmentMappingProperties.REFLECTIVITY) as Number;
		}
		public function set reflectivity(value : Number) : void
		{
			setProperty(EnvironmentMappingProperties.REFLECTIVITY, value);
		}

		public function get environmentMappingType() : uint
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAPPING_TYPE) as uint;
		}
		public function set environmentMappingType(value : uint) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAPPING_TYPE, value);
		}

		public function get environmentBlending() : uint
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_BLENDING) as uint;
		}
		public function set environmentBlending(value : uint) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_BLENDING, value);
		}

		public function RealisticMaterial(properties	: Object	= null,
										  effect		: Effect	= null,
										  name			: String	= DEFAULT_NAME)
		{
			super(properties, effect || DEFAULT_EFFECT, name);
		}

        override public function clone() : IDataProvider
        {
            return new RealisticMaterial(this, effect, name);
        }
	}
}

package aerys.minko.render.material.realistic
{
	import aerys.minko.render.Effect;
	import aerys.minko.render.material.environment.EnvironmentMappingProperties;
	import aerys.minko.render.material.phong.PhongEffect;
	import aerys.minko.render.material.phong.PhongMaterial;
	import aerys.minko.render.resource.texture.ITextureResource;
	import aerys.minko.type.binding.IDataProvider;

	public class RealisticMaterial extends PhongMaterial
	{
		private static const DEFAULT_NAME		: String		= 'RealisticMaterial';
        private static const DEFAULT_EFFECT     : Effect        = new PhongEffect(
            new RealisticShader()
        );

		public function get environmentMap() : ITextureResource
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP) as ITextureResource;
		}
		public function set environmentMap(value : ITextureResource) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP, value);
		}

        public function get environmentMapFiltering() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FILTERING);
        }
        public function set environmentMapFiltering(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FILTERING, value);
        }

        public function get environmentMapMipMapping() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_MIPMAPPING);
        }
        public function set environmentMapMipMapping(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_MIPMAPPING, value);
        }

        public function get environmentMapWrapping() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_WRAPPING);
        }
        public function set environmentMapWrapping(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_WRAPPING, value);
        }

        public function get environmentMapFormat() : uint
        {
            return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FORMAT);
        }
        public function set environmentMapFormat(value : uint) : void
        {
            setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAP_FORMAT, value);
        }

		public function get reflectivity() : Number
		{
			return getProperty(EnvironmentMappingProperties.REFLECTIVITY) as Number;
		}
		public function set reflectivity(value : Number) : void
		{
			setProperty(EnvironmentMappingProperties.REFLECTIVITY, value);
		}

		public function get environmentMappingType() : uint
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_MAPPING_TYPE) as uint;
		}
		public function set environmentMappingType(value : uint) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_MAPPING_TYPE, value);
		}

		public function get environmentBlending() : uint
		{
			return getProperty(EnvironmentMappingProperties.ENVIRONMENT_BLENDING) as uint;
		}
		public function set environmentBlending(value : uint) : void
		{
			setProperty(EnvironmentMappingProperties.ENVIRONMENT_BLENDING, value);
		}

		public function RealisticMaterial(properties	: Object	= null,
										  effect		: Effect	= null,
										  name			: String	= DEFAULT_NAME)
		{
			super(properties, effect || DEFAULT_EFFECT, name);
		}

        override public function clone() : IDataProvider
        {
            return new RealisticMaterial(this, effect, name);
        }
	}
}

remove useless imports

remove useless imports