 package org.mangui.hls.loader {
     import flash.utils.getTimer;
 
+    import org.mangui.hls.HLS;
+    import org.mangui.hls.HLSSettings;
     import org.mangui.hls.controller.AudioTrackController;
     import org.mangui.hls.controller.LevelController;
-    import org.mangui.hls.HLSSettings;
-    import org.mangui.hls.event.HLSLoadMetrics;
     import org.mangui.hls.constant.HLSTypes;
-    import org.mangui.hls.flv.FLVTag;
+    import org.mangui.hls.demux.Demuxer;
+    import org.mangui.hls.demux.DemuxHelper;
     import org.mangui.hls.event.HLSError;
     import org.mangui.hls.event.HLSEvent;
-    import org.mangui.hls.demux.Demuxer;
-    import org.mangui.hls.demux.DemuxHelper;
+    import org.mangui.hls.event.HLSLoadMetrics;
+    import org.mangui.hls.flv.FLVTag;
     import org.mangui.hls.model.AudioTrack;
-    import org.mangui.hls.HLS;
     import org.mangui.hls.model.Fragment;
     import org.mangui.hls.model.FragmentData;
     import org.mangui.hls.model.FragmentMetrics;
     import org.mangui.hls.model.Level;
+    import org.mangui.hls.stream.StreamBuffer;
     import org.mangui.hls.utils.AES;
-    import org.mangui.hls.stream.StreamBuffer;
 
     import flash.events.*;
     import flash.net.*;

            stop();
            _hls.removeEventListener(HLSEvent.MANIFEST_LOADED, _manifestLoadedHandler);
            _hls.removeEventListener(HLSEvent.LEVEL_LOADED, _levelLoadedHandler);
            _manifest_loaded = false;
            _keymap = new Object();
        }

        /**  fragment loading Timer **/
        private function _checkLoading(e : Event) : void {
            // cannot load fragment until manifest is loaded
            if (_manifest_loaded == false) {
                return;
            }
            switch(_loading_state) {
                // nothing to load until level is retrieved
                case LOADING_WAITING_LEVEL_UPDATE:
                // loading already in progress

            _hls.addEventListener(HLSEvent.LEVEL_LOADED, _levelLoadedHandler);
            _timer = new Timer(100, 0);
            _timer.addEventListener(TimerEvent.TIMER, _checkLoading);
            _loading_state = MANIFEST_LOADING;
            _manifest_just_loaded = false;
            _keymap = new Object();
        };
