package goplayer
{
  import flash.display.DisplayObject
  import flash.display.InteractiveObject
  import flash.display.Sprite
  import flash.text.TextField

	public class StandardSkin extends AbstractStandardSkin
  {
    private var _seekBarWidth : Number

    override public function update() : void
    {
      super.update()

      setPosition(largePlayButton, dimensions.center)
      setPosition(bufferingIndicator, dimensions.center)

      setDimensions(largePlayButton, dimensions.halved.innerSquare)

      upperPanel.x = 0
      upperPanel.y = 0

      packLeft
        (upperPanelLeft,
         [upperPanelMiddle, setUpperPanelWidth],
         upperPanelRight)

      controlBar.x = 0
      controlBar.y = dimensions.height

      packLeft
        (showPlayPauseButton ? playPausePart : null,
         beforeLeftTimePart,
         showElapsedTime ? leftTimeBackgroundPart : null,
         afterLeftTimePart,
         [seekBar, setSeekBarWidth],
         beforeRightTimePart,
         showTotalTime ? rightTimeBackgroundPart : null,
         afterRightTimePart,
         showVolumeControl ? volumePart : null,
         showFullscreenButton ? fullscreenPart : null)

      leftTimeFieldPart.x = beforeLeftTimePart.x
      rightTimeFieldPart.x = beforeRightTimePart.x

      playPausePart.visible = showPlayPauseButton
      leftTimeBackgroundPart.visible = showElapsedTime
      leftTimeFieldPart.visible = showElapsedTime

      seekBarBuffer.visible = showSeekBar
      seekBarPlayhead.visible = showSeekBar
      seekBarTooltip.visible = showSeekBar
      seekBarTooltipField.visible = showSeekBar

      rightTimeBackgroundPart.visible = showTotalTime
      rightTimeFieldPart.visible = showTotalTime
      volumePart.visible = showVolumeControl
      fullscreenPart.visible = showFullscreenButton
    }

    private function packLeft(... items : Array) : void
    { Packer.$packLeft(dimensions.width, items) }

    private function setUpperPanelWidth(value : Number) : void
    {
      upperPanelMiddleBackground.width = value
      titleField.width = value
    }

    private function setSeekBarWidth(value : Number) : void
    { _seekBarWidth = value }

    override protected function get seekBarWidth() : Number
    { return _seekBarWidth }

    override protected function get upperPanel() : Sprite
    { return lookup("chrome.upperPanel") }
    private function get upperPanelLeft() : Sprite
    { return lookup("chrome.upperPanel.left") }
    private function get upperPanelMiddle() : Sprite
    { return lookup("chrome.upperPanel.middle") }
    private function get upperPanelMiddleBackground() : Sprite
    { return lookup("chrome.upperPanel.middle.background") }
    private function get upperPanelRight() : Sprite
    { return lookup("chrome.upperPanel.right") }

    override protected function get largePlayButton() : InteractiveObject
    { return lookup("largePlayButton") }
    override protected function get bufferingIndicator() : InteractiveObject
    { return lookup("bufferingIndicator") }

    override protected function get chrome() : Sprite
    { return lookup("chrome") }

    override protected function get titleField() : TextField
    { return lookup("chrome.upperPanel.middle.titleField") }

    override protected function get controlBar() : Sprite
    { return lookup("chrome.controlBar") }

    private function get playPausePart() : DisplayObject
    { return lookup("chrome.controlBar.playPause") }
    override protected function get playButton() : DisplayObject
    { return lookup("chrome.controlBar.playPause.playButton") }
    override protected function get pauseButton() : DisplayObject
    { return lookup("chrome.controlBar.playPause.pauseButton") }

    private function get beforeLeftTimePart() : DisplayObject
    { return lookup("chrome.controlBar.beforeLeftTime") }

    private function get leftTimeBackgroundPart() : DisplayObject
    { return lookup("chrome.controlBar.leftTimeBackground") }
    private function get leftTimeFieldPart() : DisplayObject
    { return lookup("chrome.controlBar.leftTime") }
    override protected function get leftTimeField() : TextField
    { return lookup("chrome.controlBar.leftTime.field") }

    private function get afterLeftTimePart() : DisplayObject
    { return lookup("chrome.controlBar.afterLeftTime") }

    override protected function get seekBar() : Sprite
    { return lookup("chrome.controlBar.seekBar") }
    override protected function get seekBarBackground() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.background") }
    override protected function get seekBarBuffer() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.buffer") }
    override protected function get seekBarPlayhead() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.playhead") }
    override protected function get seekBarTooltip() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.tooltip") }
    override protected function get seekBarTooltipField() : TextField
    { return lookup("chrome.controlBar.seekBar.tooltip.field") }

    private function get beforeRightTimePart() : DisplayObject
    { return lookup("chrome.controlBar.beforeRightTime") }

    private function get rightTimeBackgroundPart() : DisplayObject
    { return lookup("chrome.controlBar.rightTimeBackground") }
    private function get rightTimeFieldPart() : DisplayObject
    { return lookup("chrome.controlBar.rightTime") }
    override protected function get rightTimeField() : TextField
    { return lookup("chrome.controlBar.rightTime.field") }

    private function get afterRightTimePart() : DisplayObject
    { return lookup("chrome.controlBar.afterRightTime") }

    private function get volumePart() : DisplayObject
    { return lookup("chrome.controlBar.volume") }
    override protected function get muteButton() : DisplayObject
    { return lookup("chrome.controlBar.volume.muteButton") }
    override protected function get unmuteButton() : DisplayObject
    { return lookup("chrome.controlBar.volume.unmuteButton") }
    override protected function get volumeSlider() : Sprite
    { return lookup("chrome.controlBar.volume.slider") }
    override protected function get volumeSliderThumb() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.thumb") }
    override protected function get volumeSliderThumbGuide() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.thumbGuide") }
    override protected function get volumeSliderFill() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.fill") }

    private function get fullscreenPart() : DisplayObject
    { return lookup("chrome.controlBar.fullscreen") }
    override protected function get enableFullscreenButton() : DisplayObject
    { return lookup("chrome.controlBar.fullscreen.enableButton") }

    override protected function lookup(name : String) : *
    { return super.lookup("skinContent." + name) }
	}
}

package goplayer
{
  import flash.display.DisplayObject
  import flash.display.InteractiveObject
  import flash.display.Sprite
  import flash.text.TextField

	public class StandardSkin extends AbstractStandardSkin
  {
    private var _seekBarWidth : Number

    override public function update() : void
    {
      super.update()

      setPosition(largePlayButton, dimensions.center)
      setPosition(bufferingIndicator, dimensions.center)

      setDimensions(largePlayButton, dimensions.halved.innerSquare)

      upperPanel.x = 0
      upperPanel.y = 0

      packLeft
        (upperPanelLeft,
         [upperPanelMiddle, setUpperPanelWidth],
         upperPanelRight)

      controlBar.x = 0
      controlBar.y = dimensions.height

      packLeft
        (showPlayPauseButton ? playPausePart : null,
         beforeLeftTimePart,
         showElapsedTime ? leftTimeBackgroundPart : null,
         afterLeftTimePart,
         [seekBar, setSeekBarWidth],
         beforeRightTimePart,
         showTotalTime ? rightTimeBackgroundPart : null,
         afterRightTimePart,
         showVolumeControl ? volumePart : null,
         showFullscreenButton ? fullscreenPart : null)

      leftTimeFieldPart.x = beforeLeftTimePart.x
      rightTimeFieldPart.x = beforeRightTimePart.x

      playPausePart.visible = showPlayPauseButton
      leftTimeBackgroundPart.visible = showElapsedTime
      leftTimeFieldPart.visible = showElapsedTime
      seekBar.visible = showSeekBar
      rightTimeBackgroundPart.visible = showTotalTime
      rightTimeFieldPart.visible = showTotalTime
      volumePart.visible = showVolumeControl
      fullscreenPart.visible = showFullscreenButton
    }

    private function packLeft(... items : Array) : void
    { Packer.$packLeft(dimensions.width, items) }

    private function setUpperPanelWidth(value : Number) : void
    {
      upperPanelMiddleBackground.width = value
      titleField.width = value
    }

    private function setSeekBarWidth(value : Number) : void
    { _seekBarWidth = value }

    override protected function get seekBarWidth() : Number
    { return _seekBarWidth }

    override protected function get upperPanel() : Sprite
    { return lookup("chrome.upperPanel") }
    private function get upperPanelLeft() : Sprite
    { return lookup("chrome.upperPanel.left") }
    private function get upperPanelMiddle() : Sprite
    { return lookup("chrome.upperPanel.middle") }
    private function get upperPanelMiddleBackground() : Sprite
    { return lookup("chrome.upperPanel.middle.background") }
    private function get upperPanelRight() : Sprite
    { return lookup("chrome.upperPanel.right") }

    override protected function get largePlayButton() : InteractiveObject
    { return lookup("largePlayButton") }
    override protected function get bufferingIndicator() : InteractiveObject
    { return lookup("bufferingIndicator") }

    override protected function get chrome() : Sprite
    { return lookup("chrome") }

    override protected function get titleField() : TextField
    { return lookup("chrome.upperPanel.middle.titleField") }

    override protected function get controlBar() : Sprite
    { return lookup("chrome.controlBar") }

    private function get playPausePart() : DisplayObject
    { return lookup("chrome.controlBar.playPause") }
    override protected function get playButton() : DisplayObject
    { return lookup("chrome.controlBar.playPause.playButton") }
    override protected function get pauseButton() : DisplayObject
    { return lookup("chrome.controlBar.playPause.pauseButton") }

    private function get beforeLeftTimePart() : DisplayObject
    { return lookup("chrome.controlBar.beforeLeftTime") }

    private function get leftTimeBackgroundPart() : DisplayObject
    { return lookup("chrome.controlBar.leftTimeBackground") }
    private function get leftTimeFieldPart() : DisplayObject
    { return lookup("chrome.controlBar.leftTime") }
    override protected function get leftTimeField() : TextField
    { return lookup("chrome.controlBar.leftTime.field") }

    private function get afterLeftTimePart() : DisplayObject
    { return lookup("chrome.controlBar.afterLeftTime") }

    override protected function get seekBar() : Sprite
    { return lookup("chrome.controlBar.seekBar") }
    override protected function get seekBarBackground() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.background") }
    override protected function get seekBarBuffer() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.buffer") }
    override protected function get seekBarPlayhead() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.playhead") }
    override protected function get seekBarTooltip() : DisplayObject
    { return lookup("chrome.controlBar.seekBar.tooltip") }
    override protected function get seekBarTooltipField() : TextField
    { return lookup("chrome.controlBar.seekBar.tooltip.field") }

    private function get beforeRightTimePart() : DisplayObject
    { return lookup("chrome.controlBar.beforeRightTime") }

    private function get rightTimeBackgroundPart() : DisplayObject
    { return lookup("chrome.controlBar.rightTimeBackground") }
    private function get rightTimeFieldPart() : DisplayObject
    { return lookup("chrome.controlBar.rightTime") }
    override protected function get rightTimeField() : TextField
    { return lookup("chrome.controlBar.rightTime.field") }

    private function get afterRightTimePart() : DisplayObject
    { return lookup("chrome.controlBar.afterRightTime") }

    private function get volumePart() : DisplayObject
    { return lookup("chrome.controlBar.volume") }
    override protected function get muteButton() : DisplayObject
    { return lookup("chrome.controlBar.volume.muteButton") }
    override protected function get unmuteButton() : DisplayObject
    { return lookup("chrome.controlBar.volume.unmuteButton") }
    override protected function get volumeSlider() : Sprite
    { return lookup("chrome.controlBar.volume.slider") }
    override protected function get volumeSliderThumb() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.thumb") }
    override protected function get volumeSliderThumbGuide() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.thumbGuide") }
    override protected function get volumeSliderFill() : DisplayObject
    { return lookup("chrome.controlBar.volume.slider.fill") }

    private function get fullscreenPart() : DisplayObject
    { return lookup("chrome.controlBar.fullscreen") }
    override protected function get enableFullscreenButton() : DisplayObject
    { return lookup("chrome.controlBar.fullscreen.enableButton") }

    override protected function lookup(name : String) : *
    { return super.lookup("skinContent." + name) }
	}
}

Fix bug: Seek bar tooltip visibility was being reverted all the time.


package org.servebox.cafe.core.application
{
	import org.servebox.cafe.core.spring.ApplicationContext;

	import spark.components.Application;

	public class Application extends spark.components.Application implements CafeApplication
	{
		private var _context : ApplicationContext;

		public function Application()
		{
			super();
			ApplicationInitializer.prepare( this );
			_context = ApplicationInitializer.getDefaultContext();
		}

		public function getContext():ApplicationContext
		{
			return null;
		}
	}
}

package org.servebox.cafe.core.application
{
	import org.servebox.cafe.core.spring.ApplicationContext;

	import spark.components.Application;

	public class Application extends spark.components.Application implements CafeApplication
	{
		private var _context : ApplicationContext;

		public function Application()
		{
			super();
			ApplicationInitializer.prepare( this );
			_context = ApplicationInitializer.getDefaultContext();
		}

		public function getContext():ApplicationContext
		{
			return _context;
		}
	}
}

Fix bug on getContext() null

Fix bug on getContext() null


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

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

  # We can be killed even before children are spawned.
  test -n "$children" ||
    exit $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

# ./../../../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.
spawn_urbi_server

# Start the test.
valgrind=$(instrument "remote.val")
cmd="$valgrind ../../tests --port-file 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=$?

  # We can be killed even before children are spawned.
  test -n "$children" ||
    exit $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 bin/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

# ./../../../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.
spawn_urbi_server

# Start the test.
valgrind=$(instrument "remote.val")
cmd="$valgrind ../../tests --port-file 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 a dir witness.

Update a dir witness.

	* src/tests/bin/liburbi-check.as: liburbi-check is now in bin/.
	This remained unnoticed because the previous liburbi-check was
	still there.


package krewfw.core {

    import flash.media.Sound;

    import starling.display.Image;
    import starling.display.Sprite;
    import starling.textures.Texture;

    /**
     * Scene 上にのっていない Actor が Actor めいた仕事をしたいときの委譲先。
     * バックエンドに存在する各 Scene のシステム Actor に処理を代行してもらう。
     * 以下のように使う。
     *
     * <pre>
     *     import krewfw.utils.krew;
     *     krew.delegate.sendMessage(...);
     * </pre>
     *
     * krewFramework は Actor の集まりで構成するという設計思想を持つが、
     * static な Model クラスなどがリソースへのアクセスやメッセージングなどを
     * 行いたくなった時、または Actor を増やした時のオーバヘッドを減らしたい場合などに利用する。
     *
     * ただしフレームワークのポリシー上、Actor にタスクを登録する系統のものは代行できない。
     * そういうことをしたくなったクラスは Actor として Scene 上に生きなければならない。
     */
    //------------------------------------------------------------
    public class KrewActorDelegate {

        /** system actor on current scene */
        private static var _actor:KrewActor = null;

        //------------------------------------------------------------
        // Called by framework
        //------------------------------------------------------------

        public static function setSystemActor(actor:KrewActor):void {
            _actor = actor;
        }

        public static function clearSystemActor():void {
            _actor = null;
        }

        //------------------------------------------------------------
        // Singleton interface
        //------------------------------------------------------------

        private static var _instance:KrewActorDelegate;

        public function KrewActorDelegate() {
            if (_instance) {
                throw new Error("[KrewActorDelegate] Cannot instantiate singleton.");
            }
        }

        public static function get instance():KrewActorDelegate {
            if (_actor == null) {
                throw new Error("[KrewActorDelegate] System actor is not ready.");
            }

            if (!_instance) {
                _instance = new KrewActorDelegate();
            }
            return _instance;
        }

        //------------------------------------------------------------
        // Delegate methods
        //------------------------------------------------------------

        public function getTexture(fileName:String):Texture { return _actor.getTexture(fileName); }
        public function getImage  (fileName:String):Image   { return _actor.getImage  (fileName); }
        public function getSound  (fileName:String):Sound   { return _actor.getSound  (fileName); }
        public function getXml    (fileName:String):XML     { return _actor.getXml    (fileName); }
        public function getObject (fileName:String):Object  { return _actor.getObject (fileName); }

        public function loadResources(fileNameList:Array, onLoadProgress:Function,
                                      onLoadComplete:Function):void
        {
            _actor.loadResources(fileNameList, onLoadProgress, onLoadComplete);
        }

        public function sendMessage(eventType:String, eventArgs:Object=null):void {
            _actor.sendMessage(eventType, eventArgs);
        }

        public function createActor(newActor:KrewActor, layerName:String):void {
            _actor.createActor(newActor, layerName);
        }

    }
}

package krewfw.core {

    import flash.media.Sound;

    import starling.display.Image;
    import starling.display.Sprite;
    import starling.textures.Texture;

    import krewfw.core_internal.KrewSharedObjects;

    /**
     * Scene 上にのっていない Actor が Actor めいた仕事をしたいときの委譲先。
     * バックエンドに存在する各 Scene のシステム Actor に処理を代行してもらう。
     * 以下のように使う。
     *
     * <pre>
     *     import krewfw.utils.krew;
     *     krew.delegate.sendMessage(...);
     * </pre>
     *
     * krewFramework は Actor の集まりで構成するという設計思想を持つが、
     * static な Model クラスなどがリソースへのアクセスやメッセージングなどを
     * 行いたくなった時、または Actor を増やした時のオーバヘッドを減らしたい場合などに利用する。
     *
     * ただしフレームワークのポリシー上、Actor にタスクを登録する系統のものは代行できない。
     * そういうことをしたくなったクラスは Actor として Scene 上に生きなければならない。
     */
    //------------------------------------------------------------
    public class KrewActorDelegate {

        /** system actor on current scene */
        private static var _actor:KrewActor = null;

        //------------------------------------------------------------
        // Called by framework
        //------------------------------------------------------------

        public static function setSystemActor(actor:KrewActor):void {
            _actor = actor;
        }

        public static function clearSystemActor():void {
            _actor = null;
        }

        //------------------------------------------------------------
        // Singleton interface
        //------------------------------------------------------------

        private static var _instance:KrewActorDelegate;

        public function KrewActorDelegate() {
            if (_instance) {
                throw new Error("[KrewActorDelegate] Cannot instantiate singleton.");
            }
        }

        public static function get instance():KrewActorDelegate {
            if (_actor == null) {
                throw new Error("[KrewActorDelegate] System actor is not ready.");
            }

            if (!_instance) {
                _instance = new KrewActorDelegate();
            }
            return _instance;
        }

        //------------------------------------------------------------
        // Delegate methods
        //------------------------------------------------------------

        public function get sharedObj():KrewSharedObjects { return _actor.sharedObj; }

        public function getTexture(fileName:String):Texture { return _actor.getTexture(fileName); }
        public function getImage  (fileName:String):Image   { return _actor.getImage  (fileName); }
        public function getSound  (fileName:String):Sound   { return _actor.getSound  (fileName); }
        public function getXml    (fileName:String):XML     { return _actor.getXml    (fileName); }
        public function getObject (fileName:String):Object  { return _actor.getObject (fileName); }

        public function loadResources(fileNameList:Array, onLoadProgress:Function,
                                      onLoadComplete:Function):void
        {
            _actor.loadResources(fileNameList, onLoadProgress, onLoadComplete);
        }

        public function sendMessage(eventType:String, eventArgs:Object=null):void {
            _actor.sendMessage(eventType, eventArgs);
        }

        public function createActor(newActor:KrewActor, layerName:String):void {
            _actor.createActor(newActor, layerName);
        }

    }
}

Modify krewActorDelegate

Modify krewActorDelegate


package com.kaltura.kdpfl
{
	import com.kaltura.kdpfl.controller.InitMacroCommand;
	import com.kaltura.kdpfl.controller.LayoutReadyCommand;
	import com.kaltura.kdpfl.controller.PlaybackCompleteCommand;
	import com.kaltura.kdpfl.controller.SequenceItemPlayEndCommand;
	import com.kaltura.kdpfl.controller.SequenceSkipNextCommand;
	import com.kaltura.kdpfl.controller.StartupCommand;
	import com.kaltura.kdpfl.controller.media.InitChangeMediaMacroCommand;
	import com.kaltura.kdpfl.controller.media.LiveStreamCommand;
	import com.kaltura.kdpfl.controller.media.MediaReadyCommand;
	import com.kaltura.kdpfl.events.DynamicEvent;
	import com.kaltura.kdpfl.model.ExternalInterfaceProxy;
	import com.kaltura.kdpfl.model.type.DebugLevel;
	import com.kaltura.kdpfl.model.type.NotificationType;
	import com.kaltura.kdpfl.view.controls.KTrace;
	import com.kaltura.kdpfl.view.media.KMediaPlayerMediator;
	import com.kaltura.puremvc.as3.core.KView;

	import flash.display.DisplayObject;

	import mx.utils.ObjectProxy;

	import org.osmf.media.MediaPlayerState;
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.facade.Facade;

	public class ApplicationFacade extends Facade implements IFacade
	{
		/**
		 * The current version of the KDP.
		 */
		public var kdpVersion : String = "v3.9.5";

		/**
		 * save any mediator name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _mediatorNameArray : Array = new Array();
		/**
		 * save any proxy name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _proxyNameArray : Array = new Array();
		/**
		 * save any notification that create a command name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _commandNameArray : Array = new Array();

		/**
		 * The bindObject create dynamicly all attributes that need to be binded on it
		 */
		public var bindObject:ObjectProxy = new ObjectProxy();
		/**
		 * a reference to KDP3 main application
		 */
		private var _app : DisplayObject;

		/**
		 * the url of the kdp
		 */
		public var appFolder : String;
		public var debugMode : Boolean = false;
		/**
		 *
		 * will affect the traces that will be sent. See DebugLevel enum
		 */
		public var debugLevel:int;

		private var externalInterface : ExternalInterfaceProxy;

		/**
		 * return the one and only instance of the ApplicationFacade,
		 * if not exist it will be created.
		 * @return
		 *
		 */
		public static function getInstance() : ApplicationFacade
		{
			if (instance == null) instance = new ApplicationFacade();
			return instance as ApplicationFacade;
		}

		/**
		 * All this simply does is fire a notification which is routed to
		 * "StartupCommand" via the "registerCommand" handlers
		 * @param app
		 *
		 */
		public function start(app:DisplayObject):void
		{
			CONFIG::isSDK46 {
				kdpVersion += ".sdk46";
			}

			_app = app;
			appFolder = app.root.loaderInfo.url;
			appFolder = appFolder.substr(0, appFolder.lastIndexOf('/') + 1);

			sendNotification(NotificationType.STARTUP, app);
			externalInterface = retrieveProxy(ExternalInterfaceProxy.NAME) as ExternalInterfaceProxy;
		}

		/**
		 * Created to trace all notifications for debug
		 * @param notificationName
		 * @param body
		 * @param type
		 *
		 */
		override public function sendNotification(notificationName:String, body:Object = null, type:String = null):void {
			if (debugMode) {
				var s:String;
				if ((notificationName == NotificationType.BYTES_DOWNLOADED_CHANGE && debugLevel == DebugLevel.HIGH) ||
					(notificationName == NotificationType.PLAYER_UPDATE_PLAYHEAD && (debugLevel == DebugLevel.HIGH || debugLevel == DebugLevel.MEDIUM)) ||
					(notificationName != NotificationType.PLAYER_UPDATE_PLAYHEAD && notificationName != NotificationType.BYTES_DOWNLOADED_CHANGE))
				 {
					if (notificationName == NotificationType.PLAYER_STATE_CHANGE)
						s = 'Sent ' + notificationName + ' ==> ' + body.toString();
					else {
						s = 'Sent ' + notificationName;
						if (body) {
							var found:Boolean = false;
							for (var o:* in body) {
								s += ", " + o + ":" + body[o];
								found = true;
							}
							if (!found) {
								s += ", " + body.toString();
							}
						}
					}
				}

				if (s && s != "null") {
					var curTime:Number = 0;
					var kmediaPlayerMediator:KMediaPlayerMediator = retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator;
					if (kmediaPlayerMediator &&
						kmediaPlayerMediator.player &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.LOADING &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.UNINITIALIZED &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.PLAYBACK_ERROR)
					{
						curTime = kmediaPlayerMediator.getCurrentTime();
					}
					var date:Date = new Date();

					KTrace.getInstance().log(date.toTimeString(), ":", s, ", playhead position:", curTime);
				}

			}

			super.sendNotification(notificationName, body, type);
			//For external Flash/Flex application application listening to the KDP events
			_app.dispatchEvent(new DynamicEvent(notificationName, body));

			//For external Javascript application listening to the KDP events
			if (externalInterface)
				externalInterface.notifyJs(notificationName, body);

		}

		/**
		 * controls the routing of notifications to our controllers,
		 * we all know them as commands
		 *
		 */
		override protected function initializeController():void
		{
			super.initializeController();
			registerCommand(NotificationType.STARTUP, StartupCommand);

			// we do both init start KDP life cycle, and start to load the entry simultaneously
			registerCommand(NotificationType.INITIATE_APP, InitMacroCommand);

			//There are several things that need to be done as soon as the layout of the kdp is ready.
			registerCommand(NotificationType.LAYOUT_READY, LayoutReadyCommand );
			//when one call change media we fire the load media command again
			registerCommand(NotificationType.CHANGE_MEDIA, InitChangeMediaMacroCommand);

			registerCommand (NotificationType.LIVE_ENTRY, LiveStreamCommand );

			registerCommand (NotificationType.MEDIA_LOADED, MediaReadyCommand );

			registerCommand (NotificationType.PLAYBACK_COMPLETE, PlaybackCompleteCommand);

			registerCommand(NotificationType.SEQUENCE_ITEM_PLAY_END, SequenceItemPlayEndCommand);

			registerCommand(NotificationType.SEQUENCE_SKIP_NEXT, SequenceSkipNextCommand);
		}

		override protected function initializeView():void
		{
			if ( view != null ) return;
			view = KView.getInstance();
		}

		override protected function initializeFacade():void
		{
			initializeView();
			initializeModel();
			initializeController();
		}

		/**
		 * Help to remove all commands, mediator, proxies from the facade
		 *
		 */
		public function dispose() : void
		{
			var i:int =0;

			for(i=0; i<_commandNameArray.length; i++)
				this.removeCommand( _commandNameArray[i] );

			for(i=0; i<_mediatorNameArray.length; i++)
				this.removeMediator( _mediatorNameArray[i] );

			for(i=0; i<_proxyNameArray.length; i++)
				this.removeProxy( _proxyNameArray[i] );

			_commandNameArray = new Array();
			_mediatorNameArray = new Array();
			_proxyNameArray = new Array();
		}

		/**
		 * after registartion add the notification name to a
		 * @param notificationName
		 * @param commandClassRef
		 *
		 */
		override public function registerCommand(notificationName:String, commandClassRef:Class):void
		{
			super.registerCommand(notificationName, commandClassRef);

			//save the notification name so we can delete it later
			_commandNameArray.push( notificationName );
		}

		override public function registerMediator(mediator:IMediator):void
		{
			super.registerMediator(mediator);

			//save the mediator name so we can delete it later
			_mediatorNameArray.push( mediator.getMediatorName() );
		}

		override public function registerProxy(proxy:IProxy):void
		{
			bindObject[proxy.getProxyName()] = proxy.getData();

			super.registerProxy(proxy);

			//save the proxy name so we can delete it later
			_proxyNameArray.push( proxy.getProxyName() );
		}

		/**
		 * add notification observer for a given mediator
		 * @param notification the notification to listen for
		 * @param notificationHandler handler to be called
		 * @param mediator
		 *
		 */
		public function addNotificationInterest(notification:String, notificationHandler:Function, mediator:IMediator):void {
			(view as KView).addNotificationInterest(notification, notificationHandler, mediator);
		}

		public function get app () : DisplayObject
		{
			return _app;
		}

		public function set app (disObj : DisplayObject) : void
		{
			_app = disObj;
		}

	}
}

package com.kaltura.kdpfl
{
	import com.kaltura.kdpfl.controller.InitMacroCommand;
	import com.kaltura.kdpfl.controller.LayoutReadyCommand;
	import com.kaltura.kdpfl.controller.PlaybackCompleteCommand;
	import com.kaltura.kdpfl.controller.SequenceItemPlayEndCommand;
	import com.kaltura.kdpfl.controller.SequenceSkipNextCommand;
	import com.kaltura.kdpfl.controller.StartupCommand;
	import com.kaltura.kdpfl.controller.media.InitChangeMediaMacroCommand;
	import com.kaltura.kdpfl.controller.media.LiveStreamCommand;
	import com.kaltura.kdpfl.controller.media.MediaReadyCommand;
	import com.kaltura.kdpfl.events.DynamicEvent;
	import com.kaltura.kdpfl.model.ExternalInterfaceProxy;
	import com.kaltura.kdpfl.model.type.DebugLevel;
	import com.kaltura.kdpfl.model.type.NotificationType;
	import com.kaltura.kdpfl.view.controls.KTrace;
	import com.kaltura.kdpfl.view.media.KMediaPlayerMediator;
	import com.kaltura.puremvc.as3.core.KView;

	import flash.display.DisplayObject;

	import mx.utils.ObjectProxy;

	import org.osmf.media.MediaPlayerState;
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.facade.Facade;

	public class ApplicationFacade extends Facade implements IFacade
	{
		/**
		 * The current version of the KDP.
		 */
		public var kdpVersion : String = "v3.9.6";

		/**
		 * save any mediator name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _mediatorNameArray : Array = new Array();
		/**
		 * save any proxy name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _proxyNameArray : Array = new Array();
		/**
		 * save any notification that create a command name that is registered to this array in order to delete at any time
		 * (the pure mvc don't support it as built-in function)
		 */
		private var _commandNameArray : Array = new Array();

		/**
		 * The bindObject create dynamicly all attributes that need to be binded on it
		 */
		public var bindObject:ObjectProxy = new ObjectProxy();
		/**
		 * a reference to KDP3 main application
		 */
		private var _app : DisplayObject;

		/**
		 * the url of the kdp
		 */
		public var appFolder : String;
		public var debugMode : Boolean = false;
		/**
		 *
		 * will affect the traces that will be sent. See DebugLevel enum
		 */
		public var debugLevel:int;

		private var externalInterface : ExternalInterfaceProxy;

		/**
		 * return the one and only instance of the ApplicationFacade,
		 * if not exist it will be created.
		 * @return
		 *
		 */
		public static function getInstance() : ApplicationFacade
		{
			if (instance == null) instance = new ApplicationFacade();
			return instance as ApplicationFacade;
		}

		/**
		 * All this simply does is fire a notification which is routed to
		 * "StartupCommand" via the "registerCommand" handlers
		 * @param app
		 *
		 */
		public function start(app:DisplayObject):void
		{
			CONFIG::isSDK46 {
				kdpVersion += ".sdk46";
			}

			_app = app;
			appFolder = app.root.loaderInfo.url;
			appFolder = appFolder.substr(0, appFolder.lastIndexOf('/') + 1);

			sendNotification(NotificationType.STARTUP, app);
			externalInterface = retrieveProxy(ExternalInterfaceProxy.NAME) as ExternalInterfaceProxy;
		}

		/**
		 * Created to trace all notifications for debug
		 * @param notificationName
		 * @param body
		 * @param type
		 *
		 */
		override public function sendNotification(notificationName:String, body:Object = null, type:String = null):void {
			if (debugMode) {
				var s:String;
				if ((notificationName == NotificationType.BYTES_DOWNLOADED_CHANGE && debugLevel == DebugLevel.HIGH) ||
					(notificationName == NotificationType.PLAYER_UPDATE_PLAYHEAD && (debugLevel == DebugLevel.HIGH || debugLevel == DebugLevel.MEDIUM)) ||
					(notificationName != NotificationType.PLAYER_UPDATE_PLAYHEAD && notificationName != NotificationType.BYTES_DOWNLOADED_CHANGE))
				 {
					if (notificationName == NotificationType.PLAYER_STATE_CHANGE)
						s = 'Sent ' + notificationName + ' ==> ' + body.toString();
					else {
						s = 'Sent ' + notificationName;
						if (body) {
							var found:Boolean = false;
							for (var o:* in body) {
								s += ", " + o + ":" + body[o];
								found = true;
							}
							if (!found) {
								s += ", " + body.toString();
							}
						}
					}
				}

				if (s && s != "null") {
					var curTime:Number = 0;
					var kmediaPlayerMediator:KMediaPlayerMediator = retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator;
					if (kmediaPlayerMediator &&
						kmediaPlayerMediator.player &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.LOADING &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.UNINITIALIZED &&
						kmediaPlayerMediator.player.state!=MediaPlayerState.PLAYBACK_ERROR)
					{
						curTime = kmediaPlayerMediator.getCurrentTime();
					}
					var date:Date = new Date();

					KTrace.getInstance().log(date.toTimeString(), ":", s, ", playhead position:", curTime);
				}

			}

			super.sendNotification(notificationName, body, type);
			//For external Flash/Flex application application listening to the KDP events
			_app.dispatchEvent(new DynamicEvent(notificationName, body));

			//For external Javascript application listening to the KDP events
			if (externalInterface)
				externalInterface.notifyJs(notificationName, body);

		}

		/**
		 * controls the routing of notifications to our controllers,
		 * we all know them as commands
		 *
		 */
		override protected function initializeController():void
		{
			super.initializeController();
			registerCommand(NotificationType.STARTUP, StartupCommand);

			// we do both init start KDP life cycle, and start to load the entry simultaneously
			registerCommand(NotificationType.INITIATE_APP, InitMacroCommand);

			//There are several things that need to be done as soon as the layout of the kdp is ready.
			registerCommand(NotificationType.LAYOUT_READY, LayoutReadyCommand );
			//when one call change media we fire the load media command again
			registerCommand(NotificationType.CHANGE_MEDIA, InitChangeMediaMacroCommand);

			registerCommand (NotificationType.LIVE_ENTRY, LiveStreamCommand );

			registerCommand (NotificationType.MEDIA_LOADED, MediaReadyCommand );

			registerCommand (NotificationType.PLAYBACK_COMPLETE, PlaybackCompleteCommand);

			registerCommand(NotificationType.SEQUENCE_ITEM_PLAY_END, SequenceItemPlayEndCommand);

			registerCommand(NotificationType.SEQUENCE_SKIP_NEXT, SequenceSkipNextCommand);
		}

		override protected function initializeView():void
		{
			if ( view != null ) return;
			view = KView.getInstance();
		}

		override protected function initializeFacade():void
		{
			initializeView();
			initializeModel();
			initializeController();
		}

		/**
		 * Help to remove all commands, mediator, proxies from the facade
		 *
		 */
		public function dispose() : void
		{
			var i:int =0;

			for(i=0; i<_commandNameArray.length; i++)
				this.removeCommand( _commandNameArray[i] );

			for(i=0; i<_mediatorNameArray.length; i++)
				this.removeMediator( _mediatorNameArray[i] );

			for(i=0; i<_proxyNameArray.length; i++)
				this.removeProxy( _proxyNameArray[i] );

			_commandNameArray = new Array();
			_mediatorNameArray = new Array();
			_proxyNameArray = new Array();
		}

		/**
		 * after registartion add the notification name to a
		 * @param notificationName
		 * @param commandClassRef
		 *
		 */
		override public function registerCommand(notificationName:String, commandClassRef:Class):void
		{
			super.registerCommand(notificationName, commandClassRef);

			//save the notification name so we can delete it later
			_commandNameArray.push( notificationName );
		}

		override public function registerMediator(mediator:IMediator):void
		{
			super.registerMediator(mediator);

			//save the mediator name so we can delete it later
			_mediatorNameArray.push( mediator.getMediatorName() );
		}

		override public function registerProxy(proxy:IProxy):void
		{
			bindObject[proxy.getProxyName()] = proxy.getData();

			super.registerProxy(proxy);

			//save the proxy name so we can delete it later
			_proxyNameArray.push( proxy.getProxyName() );
		}

		/**
		 * add notification observer for a given mediator
		 * @param notification the notification to listen for
		 * @param notificationHandler handler to be called
		 * @param mediator
		 *
		 */
		public function addNotificationInterest(notification:String, notificationHandler:Function, mediator:IMediator):void {
			(view as KView).addNotificationInterest(notification, notificationHandler, mediator);
		}

		public function get app () : DisplayObject
		{
			return _app;
		}

		public function set app (disObj : DisplayObject) : void
		{
			_app = disObj;
		}

	}
}

bump version to 3.9.6

bump version to 3.9.6


class LightsOutScript {
    Hub @hub;
    Entity @self;

    LightsOutScript(Entity @entity){
        @hub = Managers();
        @self = @entity;
    }

	// Index goes first row 0 -> 4, second row 5 -> 9 etc.
	void ButtonPress(int index) {
		// Check if button is not pressed, in which case we invert its neighbors (check for out of bounds)
		print("Pressed button nr `" + index + "`\n");
	}

	void b_0_0() {
		ButtonPress(0);
	}

	void b_0_1() {
		ButtonPress(1);
	}

	void b_0_2() {
		ButtonPress(2);
	}

	void b_0_3() {
		ButtonPress(3);
	}

	void b_0_4() {
		ButtonPress(4);
	}

	void b_1_0() {
		ButtonPress(5);
	}

	void b_1_1() {
		ButtonPress(6);
	}

	void b_1_2() {
		ButtonPress(7);
	}

	void b_1_3() {
		ButtonPress(8);
	}

	void b_1_4() {
		ButtonPress(9);
	}

	void b_2_0() {
		ButtonPress(10);
	}

	void b_2_1() {
		ButtonPress(11);
	}

	void b_2_2() {
		ButtonPress(12);
	}

	void b_2_3() {
		ButtonPress(13);
	}

	void b_2_4() {
		ButtonPress(14);
	}

	void b_3_0() {
		ButtonPress(15);
	}

	void b_3_1() {
		ButtonPress(16);
	}

	void b_3_2() {
		ButtonPress(17);
	}

	void b_3_3() {
		ButtonPress(18);
	}

	void b_3_4() {
		ButtonPress(19);
	}

	void b_4_0() {
		ButtonPress(20);
	}

	void b_4_1() {
		ButtonPress(21);
	}

	void b_4_2() {
		ButtonPress(22);
	}

	void b_4_3() {
		ButtonPress(23);
	}

	void b_4_4() {
		ButtonPress(24);
	}
}

Change tabs to spaces in script.

Change tabs to spaces in script.


package aerys.minko.scene.node.camera
{
	import aerys.minko.scene.controller.camera.CameraController;
	import aerys.minko.scene.data.CameraDataProvider;
	import aerys.minko.scene.node.AbstractSceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.math.Frustum;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	public class AbstractCamera extends AbstractSceneNode
	{
		public static const DEFAULT_ZNEAR	: Number	= .1;
		public static const DEFAULT_ZFAR	: Number	= 500.;

		protected var _cameraCtrl	: CameraController;
		protected var _cameraData	: CameraDataProvider;

		protected var _enabled		: Boolean;

		protected var _activated	: Signal;
		protected var _deactivated	: Signal;

		public function get zNear() : Number
		{
			return _cameraData.zNear;
		}
		public function set zNear(value : Number) : void
		{
			_cameraData.zNear = value;
		}

		public function get zFar() : Number
		{
			return _cameraData.zFar;
		}
		public function set zFar(value : Number) : void
		{
			_cameraData.zFar = value;
		}

		public function get enabled() : Boolean
		{
			return _enabled;
		}
		public function set enabled(value : Boolean) : void
		{
			if (value != _enabled)
			{
				_enabled = value;

				if (_enabled)
					_activated.execute(this);
				else
					_deactivated.execute(this);
			}
		}

		public function get activated() : Signal
		{
			return _activated;
		}
		public function get deactivated() : Signal
		{
			return _deactivated;
		}

		public function get frustum() : Frustum
		{
			return _cameraData.frustum;
		}

		protected function get cameraController() : CameraController
		{
			return _cameraCtrl;
		}

		protected function get cameraData() : CameraDataProvider
		{
			return _cameraData;
		}

		public function AbstractCamera(zNear	: Number = DEFAULT_ZNEAR,
									   zFar		: Number = DEFAULT_ZFAR)
		{
			super();

			initializeCameraData(zNear, zFar);
		}

		override protected function initialize() : void
		{
			_enabled = true;

			super.initialize();
		}

		override protected function initializeSignals():void
		{
			super.initializeSignals();

			_activated = new Signal('Camera.activated');
			_deactivated = new Signal('Camera.deactivated');
		}

		override protected function initializeContollers():void
		{
			super.initializeContollers();

			_cameraCtrl = new CameraController();
			addController(_cameraCtrl);
		}

		override protected function initializeDataProviders():void
		{
			super.initializeDataProviders();

			_cameraData = _cameraCtrl.cameraData;
		}

		protected function initializeCameraData(zNear : Number, zFar : Number) : void
		{
			_cameraData.zNear = zNear;
			_cameraData.zFar = zFar;
		}

		public function unproject(x : Number, y : Number, out : Ray = null) : Ray
		{
			throw new Error('Must be overriden.');
		}

		/**
		 * Return a copy of the world to view matrix. This method is an alias on the
		 * getWorldToLocalTransform() method.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getWorldToViewTransform(forceUpdate	: Boolean,
												output 		: Matrix4x4 = null) : Matrix4x4
		{
			return getWorldToLocalTransform(forceUpdate, output);
		}

		/**
		 * Return a copy of the view to world matrix. This method is an alias on the
		 * getLocalToWorldTransform() method.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getViewToWorldTransform(forceUpdate : Boolean,
												output 		: Matrix4x4 = null) : Matrix4x4
		{
			return getLocalToWorldTransform(forceUpdate, output);
		}

		/**
		 * Return a copy of the projection matrix.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getProjection(output : Matrix4x4) : Matrix4x4
		{
			output ||= new Matrix4x4();

			return output.copyFrom(_cameraData.projection);
		}
	}
}

package aerys.minko.scene.node.camera
{
	import aerys.minko.scene.controller.camera.CameraController;
	import aerys.minko.scene.data.CameraDataProvider;
	import aerys.minko.scene.node.AbstractSceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.math.Frustum;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	public class AbstractCamera extends AbstractSceneNode
	{
		public static const DEFAULT_ZNEAR	: Number	= .1;
		public static const DEFAULT_ZFAR	: Number	= 500.;

		protected var _cameraCtrl	: CameraController;
		protected var _cameraData	: CameraDataProvider;

		protected var _enabled		: Boolean;

		protected var _activated	: Signal;
		protected var _deactivated	: Signal;

		public function get zNear() : Number
		{
			return _cameraData.zNear;
		}
		public function set zNear(value : Number) : void
		{
			_cameraData.zNear = value;
		}

		public function get zFar() : Number
		{
			return _cameraData.zFar;
		}
		public function set zFar(value : Number) : void
		{
			_cameraData.zFar = value;
		}

		public function get enabled() : Boolean
		{
			return _enabled;
		}
		public function set enabled(value : Boolean) : void
		{
			if (value != _enabled)
			{
				_enabled = value;

				if (_enabled)
					_activated.execute(this);
				else
					_deactivated.execute(this);
			}
		}

		public function get activated() : Signal
		{
			return _activated;
		}
		public function get deactivated() : Signal
		{
			return _deactivated;
		}

		public function get frustum() : Frustum
		{
			return _cameraData.frustum;
		}

		protected function get cameraController() : CameraController
		{
			return _cameraCtrl;
		}

		protected function get cameraData() : CameraDataProvider
		{
			return _cameraData;
		}

		public function AbstractCamera(zNear	: Number = DEFAULT_ZNEAR,
									   zFar		: Number = DEFAULT_ZFAR)
		{
			super();

			initializeCameraData(zNear, zFar);
		}

		override protected function initialize() : void
		{
			_enabled = true;

			super.initialize();
		}

		override protected function initializeSignals():void
		{
			super.initializeSignals();

			_activated = new Signal('Camera.activated');
			_deactivated = new Signal('Camera.deactivated');
		}

		override protected function initializeContollers():void
		{
			super.initializeContollers();

			_cameraCtrl = new CameraController();
			addController(_cameraCtrl);
		}

		override protected function initializeDataProviders():void
		{
			super.initializeDataProviders();

			_cameraData = _cameraCtrl.cameraData;
		}

		protected function initializeCameraData(zNear : Number, zFar : Number) : void
		{
			_cameraData.zNear = zNear;
			_cameraData.zFar = zFar;
		}

		public function unproject(x : Number, y : Number, out : Ray = null) : Ray
		{
			throw new Error('Must be overriden.');
		}

		/**
		 * Return a copy of the world to view matrix. This method is an alias on the
		 * getWorldToLocalTransform() method.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getWorldToViewTransform(forceUpdate	: Boolean	= false,
												output 		: Matrix4x4 = null) : Matrix4x4
		{
			return getWorldToLocalTransform(forceUpdate, output);
		}

		/**
		 * Return a copy of the view to world matrix. This method is an alias on the
		 * getLocalToWorldTransform() method.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getViewToWorldTransform(forceUpdate : Boolean	= false,
												output 		: Matrix4x4 = null) : Matrix4x4
		{
			return getLocalToWorldTransform(forceUpdate, output);
		}

		/**
		 * Return a copy of the projection matrix.
		 *
		 * @param output
		 * @return
		 *
		 */
		public function getProjection(output : Matrix4x4) : Matrix4x4
		{
			output ||= new Matrix4x4();

			return output.copyFrom(_cameraData.projection);
		}
	}
}

set AbtractCamera.getWorldToViewTransform() and AbstractCamera.getViewToWorldTransform() forceUpdate argument to be false by default


package aerys.minko.type.loader.parser
{
	import aerys.minko.render.effect.Effect;
	import aerys.minko.type.loader.ILoader;
	import aerys.minko.type.loader.SceneLoader;
	import aerys.minko.type.loader.TextureLoader;

	import flash.net.URLRequest;

	import spark.layouts.BasicLayout;

	/**
	 * ParserOptions objects provide properties and function references
	 * to customize how a LoaderGroup object will load and interpret
	 * content.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class ParserOptions
	{
		private var _loadDependencies			: Boolean	= false;
		private var _dependencyLoaderClosure	: Function	= defaultDependencyLoaderClosure;
		private var _mipmapTextures				: Boolean	= true;
		private var _meshEffect					: Effect	= null;
		private var _vertexStreamUsage			: uint		= 0;
		private var _indexStreamUsage			: uint		= 0;
		private var _parser						: Class		= null;

		public function get parser():Class
		{
			return _parser;
		}

		public function set parser(value:Class):void
		{
			_parser = value;
		}

		public function get indexStreamUsage():uint
		{
			return _indexStreamUsage;
		}

		public function set indexStreamUsage(value:uint):void
		{
			_indexStreamUsage = value;
		}

		public function get vertexStreamUsage():uint
		{
			return _vertexStreamUsage;
		}

		public function set vertexStreamUsage(value:uint):void
		{
			_vertexStreamUsage = value;
		}

		public function get effect():Effect
		{
			return _meshEffect;
		}

		public function set effect(value:Effect):void
		{
			_meshEffect = value;
		}

		public function get mipmapTextures():Boolean
		{
			return _mipmapTextures;
		}

		public function set mipmapTextures(value:Boolean):void
		{
			_mipmapTextures = value;
		}

		public function get dependencyLoaderClosure():Function
		{
			return _dependencyLoaderClosure;
		}

		public function set dependencyLoaderClosure(value:Function):void
		{
			_dependencyLoaderClosure = value;
		}

		public function get loadDependencies():Boolean
		{
			return _loadDependencies;
		}

		public function set loadDependencies(value:Boolean):void
		{
			_loadDependencies = value;
		}

		public function ParserOptions(loadDependencies			: Boolean = false,
									  dependencyLoaderClosure	: Function = null,
									  mipmapTextures			: Boolean = true,
									  meshEffect				: Effect = null,
									  vertexStreamUsage			: uint = 0,
									  indexStreamUsage			: uint = 0,
									  parser					: Class = null)
		{
			_loadDependencies			= loadDependencies;
			_dependencyLoaderClosure	= _dependencyLoaderClosure || _dependencyLoaderClosure;
			_mipmapTextures				= mipmapTextures;
			_meshEffect					= meshEffect;
			_vertexStreamUsage			= vertexStreamUsage;
			_indexStreamUsage			= indexStreamUsage;
			_parser						= parser;
		}

		private function defaultDependencyLoaderClosure(dependencyPath	: String,
														isTexture		: Boolean,
														options			: ParserOptions) : ILoader
		{
			var loader : ILoader;

			if (isTexture)
			{
				loader = new TextureLoader(true);
				loader.load(new URLRequest(dependencyPath));
			}
			else
			{
				loader = new SceneLoader(options);
				loader.load(new URLRequest(dependencyPath));
			}

			return loader;
		}
	}
}

package aerys.minko.type.loader.parser
{
	import aerys.minko.render.effect.Effect;
	import aerys.minko.type.loader.ILoader;
	import aerys.minko.type.loader.SceneLoader;
	import aerys.minko.type.loader.TextureLoader;

	import flash.net.URLRequest;

	/**
	 * ParserOptions objects provide properties and function references
	 * to customize how a LoaderGroup object will load and interpret
	 * content.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class ParserOptions
	{
		private var _loadDependencies			: Boolean	= false;
		private var _dependencyLoaderClosure	: Function	= defaultDependencyLoaderClosure;
		private var _mipmapTextures				: Boolean	= true;
		private var _meshEffect					: Effect	= null;
		private var _vertexStreamUsage			: uint		= 0;
		private var _indexStreamUsage			: uint		= 0;
		private var _parser						: Class		= null;

		public function get parser():Class
		{
			return _parser;
		}

		public function set parser(value:Class):void
		{
			_parser = value;
		}

		public function get indexStreamUsage():uint
		{
			return _indexStreamUsage;
		}

		public function set indexStreamUsage(value:uint):void
		{
			_indexStreamUsage = value;
		}

		public function get vertexStreamUsage():uint
		{
			return _vertexStreamUsage;
		}

		public function set vertexStreamUsage(value:uint):void
		{
			_vertexStreamUsage = value;
		}

		public function get effect():Effect
		{
			return _meshEffect;
		}

		public function set effect(value:Effect):void
		{
			_meshEffect = value;
		}

		public function get mipmapTextures():Boolean
		{
			return _mipmapTextures;
		}

		public function set mipmapTextures(value:Boolean):void
		{
			_mipmapTextures = value;
		}

		public function get dependencyLoaderClosure():Function
		{
			return _dependencyLoaderClosure;
		}

		public function set dependencyLoaderClosure(value:Function):void
		{
			_dependencyLoaderClosure = value;
		}

		public function get loadDependencies():Boolean
		{
			return _loadDependencies;
		}

		public function set loadDependencies(value:Boolean):void
		{
			_loadDependencies = value;
		}

		public function ParserOptions(loadDependencies			: Boolean = false,
									  dependencyLoaderClosure	: Function = null,
									  mipmapTextures			: Boolean = true,
									  meshEffect				: Effect = null,
									  vertexStreamUsage			: uint = 0,
									  indexStreamUsage			: uint = 0,
									  parser					: Class = null)
		{
			_loadDependencies			= loadDependencies;
			_dependencyLoaderClosure	= _dependencyLoaderClosure || _dependencyLoaderClosure;
			_mipmapTextures				= mipmapTextures;
			_meshEffect					= meshEffect;
			_vertexStreamUsage			= vertexStreamUsage;
			_indexStreamUsage			= indexStreamUsage;
			_parser						= parser;
		}

		private function defaultDependencyLoaderClosure(dependencyPath	: String,
														isTexture		: Boolean,
														options			: ParserOptions) : ILoader
		{
			var loader : ILoader;

			if (isTexture)
			{
				loader = new TextureLoader(true);
				loader.load(new URLRequest(dependencyPath));
			}
			else
			{
				loader = new SceneLoader(options);
				loader.load(new URLRequest(dependencyPath));
			}

			return loader;
		}
	}
}

remove never use import

remove never use import


/**
  * LzInputTextSprite.as
  *
  * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
  *            Use is subject to license terms.
  *
  * @topic Kernel
  * @subtopic AS2
  */

/**
  * @shortdesc Used for input text.
  *
  */
class LzInputTextSprite extends LzTextSprite {

    #passthrough (toplevel:true) {
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
    }#

    #passthrough  {

    function LzInputTextSprite (newowner = null, args = null) {
        super(newowner);
    }

    var __handlelostFocusdel;
    var enabled = true;
    var focusable = true;
    var hasFocus = false;
    var scroll = 0;

    override public function __initTextProperties (args:Object) {
        super.__initTextProperties(args);
        // We do not support html in input fields.
        if (this.enabled) {
            textfield.type = TextFieldType.INPUT;
        } else {
            textfield.type = TextFieldType.DYNAMIC;
        }
        textfield.mouseEnabled = false;

        /*
          TODO [hqm 2008-01]
          these handlers need to be implemented via Flash native event listenters:

          focusIn , focusOut

          change -- dispatched after text input is modified

          textInput  -- dispatched before the content is modified
                        Do we need to use this for intercepting when we have
                        a pattern restriction on input?

        */

        textfield.addEventListener(Event.CHANGE        , __onChanged);
        //textfield.addEventListener(TextEvent.TEXT_INPUT, __onTextInput);
        textfield.addEventListener(FocusEvent.FOCUS_IN , __gotFocus);
        textfield.addEventListener(FocusEvent.FOCUS_OUT, __lostFocus);

        this.hasFocus = false;

    }

    /**
     * @access private
     */
    public function gotFocus ( ){
        //Debug.write('LzInputTextSprite.__handleOnFocus');
        if ( this.hasFocus ) { return; }
        this.select();
        this.hasFocus = true;
    }

    function select (  ){
        textfield.setSelection(0, textfield.text.length);

    }

    // XXXX selectionBeginIndex    property

    function deselect (  ){
        textfield.setSelection(0,0);
    }

    /**
     * @access private
     */
    function gotBlur (  ){
        //Debug.write('LzInputTextSprite.__handleOnBlur');
        this.hasFocus = false;
        this.deselect();
    }

    /**
     * TODO [hqm 2008-01] I have no idea whether this comment
     * still applies:
     * Register for update on every frame when the text field gets the focus.
     * Set the behavior of the enter key depending on whether the field is
     * multiline or not.
     *
     * @access private
     */
    function __gotFocus ( event:Event ){
        // scroll text fields horizontally back to start
        if (owner) owner.inputtextevent('onfocus');
    }

    /**
     * Register to be called when the text field is modified. Convert this
     * into a LFC ontext event.
     * @access private
     */
    function __onChanged (event:Event ){
        if (owner) owner.inputtextevent('onchange', this.text);
    }

    /**
     * @access private
     * TODO [hqm 2008-01] Does we still need this workaround???
     */
    function __lostFocus (event:Event){
        __handlelostFocus(event);
        //trace('lost focus', event.target);
        //if (this['__handlelostFocusdel'] == null) this.__handlelostFocusdel = new LzDelegate(this, "__handlelostFocus");
        //lz.Idle.callOnIdle(this.__handlelostFocusdel);
    }

    /**
     * TODO [hqm 2008-01] Does this comment still apply? Do we still need this workaround???
     *
     * must be called after an idle event to prevent the selection from being
     * cleared prematurely, e.g. before a button click.  If the selection is
     * cleared, the button doesn't send mouse events.
     * @access private
     */
    function __handlelostFocus (evt ){
        if (owner == lz.Focus.getFocus()) {
            lz.Focus.clearFocus();
            if (owner) owner.inputtextevent('onblur');
        }
    }

    /**
     * Get the current text for this inputtext-sprite.
     * @protected
     */
    override public function getText():String {
            return textfield.text;
    }

    /**
     * Retrieves the contents of the text field for use by a datapath. See
     * LzDatapath.updateData for more on this.
     * @access protected
     */
    function updateData (){
        return textfield.text;
    }

    /**
     * Sets whether user can modify input text field
     * @param Boolean enabled: true if the text field can be edited
     */
    function setEnabled (enabled){
        this.enabled = enabled;
        if (enabled) {
            textfield.type = 'input';
        } else {
            textfield.type = 'dynamic';
        }
    }

    /**
     * Set the html flag on this text view
     */
    function setHTML (htmlp) {
        // TODO [hqm 2008-10] what do we do here?
    }

    override public function getTextfieldHeight ( ){
        return this.textfield.height;
    }

    /**
     * If a mouse event occurs in an input text field, find the focused view
     */
    static function findSelection() :LzInputText {
        var f:InteractiveObject = LFCApplication.stage.focus;
        if (f is TextField && f.parent is LzInputTextSprite) {
            return (f.parent as LzInputTextSprite).owner;
        }
        return null;
    }

    }#  // #passthrough

} // End of LzInputTextSprite

/**
  * LzInputTextSprite.as
  *
  * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
  *            Use is subject to license terms.
  *
  * @topic Kernel
  * @subtopic AS2
  */

/**
  * @shortdesc Used for input text.
  *
  */
class LzInputTextSprite extends LzTextSprite {

    #passthrough (toplevel:true) {
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
    }#

    #passthrough  {

    function LzInputTextSprite (newowner = null, args = null) {
        super(newowner);
    }

    var __handlelostFocusdel;
    var enabled = true;
    var focusable = true;
    var hasFocus = false;
    var scroll = 0;

    override public function __initTextProperties (args:Object) {
        super.__initTextProperties(args);
        // We do not support html in input fields.
        if (this.enabled) {
            textfield.type = TextFieldType.INPUT;
        } else {
            textfield.type = TextFieldType.DYNAMIC;
        }
        textfield.mouseEnabled = false;

        /*
          TODO [hqm 2008-01]
          these handlers need to be implemented via Flash native event listenters:

          focusIn , focusOut

          change -- dispatched after text input is modified

          textInput  -- dispatched before the content is modified
                        Do we need to use this for intercepting when we have
                        a pattern restriction on input?

        */

        textfield.addEventListener(Event.CHANGE        , __onChanged);
        //textfield.addEventListener(TextEvent.TEXT_INPUT, __onTextInput);
        textfield.addEventListener(FocusEvent.FOCUS_IN , __gotFocus);
        textfield.addEventListener(FocusEvent.FOCUS_OUT, __lostFocus);

        this.hasFocus = false;

    }

    /**
     * @access private
     */
    public function gotFocus ( ){
        //Debug.write('LzInputTextSprite.__handleOnFocus');
        if ( this.hasFocus ) { return; }
        this.select();
        this.hasFocus = true;
    }

    function select (  ){
        textfield.setSelection(0, textfield.text.length);

    }

    // XXXX selectionBeginIndex    property

    function deselect (  ){
        textfield.setSelection(0,0);
    }

    /**
     * @access private
     */
    function gotBlur (  ){
        //Debug.write('LzInputTextSprite.__handleOnBlur');
        this.hasFocus = false;
        this.deselect();
    }

    /**
     * TODO [hqm 2008-01] I have no idea whether this comment
     * still applies:
     * Register for update on every frame when the text field gets the focus.
     * Set the behavior of the enter key depending on whether the field is
     * multiline or not.
     *
     * @access private
     */
    function __gotFocus ( event:Event ){
        // scroll text fields horizontally back to start
        if (owner) owner.inputtextevent('onfocus');
    }

    /**
     * Register to be called when the text field is modified. Convert this
     * into a LFC ontext event.
     * @access private
     */
    function __onChanged (event:Event ){
        if (owner) owner.inputtextevent('onchange', this.text);
    }

    /**
     * @access private
     * TODO [hqm 2008-01] Does we still need this workaround???
     */
    function __lostFocus (event:Event){
        __handlelostFocus(event);
        //trace('lost focus', event.target);
        //if (this['__handlelostFocusdel'] == null) this.__handlelostFocusdel = new LzDelegate(this, "__handlelostFocus");
        //lz.Idle.callOnIdle(this.__handlelostFocusdel);
    }

    /**
     * TODO [hqm 2008-01] Does this comment still apply? Do we still need this workaround???
     *
     * must be called after an idle event to prevent the selection from being
     * cleared prematurely, e.g. before a button click.  If the selection is
     * cleared, the button doesn't send mouse events.
     * @access private
     */
    function __handlelostFocus (evt ){
        if (owner == lz.Focus.getFocus()) {
            lz.Focus.clearFocus();
            if (owner) owner.inputtextevent('onblur');
        }
    }

    /**
     * Get the current text for this inputtext-sprite.
     * @protected
     */
    override public function getText():String {
        // We normalize swf's \r to \n
        return this.textfield.text.split('\r').join('\n');
    }

    /**
     * Retrieves the contents of the text field for use by a datapath. See
     * LzDatapath.updateData for more on this.
     * @access protected
     */
    function updateData (){
        return textfield.text;
    }

    /**
     * Sets whether user can modify input text field
     * @param Boolean enabled: true if the text field can be edited
     */
    function setEnabled (enabled){
        this.enabled = enabled;
        if (enabled) {
            textfield.type = 'input';
        } else {
            textfield.type = 'dynamic';
        }
    }

    /**
     * Set the html flag on this text view
     */
    function setHTML (htmlp) {
        // TODO [hqm 2008-10] what do we do here?
    }

    override public function getTextfieldHeight ( ){
        return this.textfield.height;
    }

    /**
     * If a mouse event occurs in an input text field, find the focused view
     */
    static function findSelection() :LzInputText {
        var f:InteractiveObject = LFCApplication.stage.focus;
        if (f is TextField && f.parent is LzInputTextSprite) {
            return (f.parent as LzInputTextSprite).owner;
        }
        return null;
    }

    }#  // #passthrough

} // End of LzInputTextSprite

Change 20081025-hqm-q by hqm@badtzmaru.home on 2008-10-25 23:48:41 EDT
    in /Users/hqm/openlaszlo/trunk4/WEB-INF/lps/lfc
    for http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc

Summary: make swf9 treatment of newlines in inputtext match swf8

New Features:

Bugs Fixed: LPP-7221, LPP-5331

Technical Reviewer: hqm
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:

Tests:
see test case in bug report

git-svn-id: d62bde4b5aa582fdf07c8d403e53e0399a7ed285@11581 fa20e4f9-1d0a-0410-b5f3-dc9c16b8b17c


package htmlelements
{
	import flash.display.Sprite;
	import flash.events.*;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.media.Video;
	import flash.media.SoundTransform;
	import flash.utils.Timer;

	import FlashMediaElement;
	import HtmlMediaEvent;

	public class VideoElement extends Sprite implements IMediaElement
	{
		private var _currentUrl:String = "";
		private var _autoplay:Boolean = true;
		private var _preload:String = "";
		private var _isPreloading:Boolean = false;

		private var _connection:NetConnection;
		private var _stream:NetStream;
		private var _video:Video;
		private var _element:FlashMediaElement;
		private var _soundTransform;
		private var _oldVolume:Number = 1;

		// event values
		private var _duration:Number = 0;
		private var _framerate:Number;
		private var _isPaused:Boolean = true;
		private var _isEnded:Boolean = false;
		private var _volume:Number = 1;
		private var _isMuted:Boolean = false;

		private var _bytesLoaded:Number = 0;
		private var _bytesTotal:Number = 0;
		private var _bufferedTime:Number = 0;
		private var _bufferEmpty:Boolean = false;

		private var _videoWidth:Number = -1;
		private var _videoHeight:Number = -1;

		private var _timer:Timer;

		private var _isRTMP:Boolean = false;
		private var _isConnected:Boolean = false;
		private var _playWhenConnected:Boolean = false;
		private var _hasStartedPlaying:Boolean = false;

		private var _parentReference:Object;

		public function setReference(arg:Object):void {
			_parentReference = arg;
		}

		public function setSize(width:Number, height:Number):void {
			_video.width = width;
			_video.height = height;
		}

		public function get video():Video {
			return _video;
		}

		public function get videoHeight():Number {
			return _videoHeight;
		}

		public function get videoWidth():Number {
			return _videoWidth;
		}

		public function duration():Number {
			return _duration;
		}

		public function currentProgress():Number {
			if(_stream != null) {
				return Math.round(_stream.bytesLoaded/_stream.bytesTotal*100);
			} else {
				return 0;
			}
		}

		public function currentTime():Number {
			if (_stream != null) {
				return _stream.time;
			} else {
				return 0;
			}
		}

		// (1) load()
		// calls _connection.connect();
		// waits for NetConnection.Connect.Success
		// _stream gets created

		public function VideoElement(element:FlashMediaElement, autoplay:Boolean, preload:String, timerRate:Number, startVolume:Number)
		{
			_element = element;
			_autoplay = autoplay;
			_volume = startVolume;
			_preload = preload;

			_video = new Video();
			addChild(_video);

			_connection = new NetConnection();
			_connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
			_connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
			//_connection.connect(null);

			_timer = new Timer(timerRate);
			_timer.addEventListener("timer", timerHandler);

		}

		private function timerHandler(e:TimerEvent) {

			_bytesLoaded = _stream.bytesLoaded;
			_bytesTotal = _stream.bytesTotal;

			if (!_isPaused)
				sendEvent(HtmlMediaEvent.TIMEUPDATE);

			//trace("bytes", _bytesLoaded, _bytesTotal);

			if (_bytesLoaded < _bytesTotal)
				sendEvent(HtmlMediaEvent.PROGRESS);
		}

		// internal events
		private function netStatusHandler(event:NetStatusEvent):void {
			trace("netStatus", event.info.code);

			switch (event.info.code) {

				case "NetStream.Buffer.Empty":
					_bufferEmpty = true;
					_isEnded ? sendEvent(HtmlMediaEvent.ENDED) : null;
					break;

				case "NetStream.Buffer.Full":
					_bytesLoaded = _stream.bytesLoaded;
					_bytesTotal = _stream.bytesTotal;
					_bufferEmpty = false;

					sendEvent(HtmlMediaEvent.PROGRESS);
					break;

				case "NetConnection.Connect.Success":
					connectStream();
					break;
				case "NetStream.Play.StreamNotFound":
					trace("Unable to locate video");
					break;

				// STREAM
				case "NetStream.Play.Start":

					_isPaused = false;
					sendEvent(HtmlMediaEvent.LOADEDDATA);
					sendEvent(HtmlMediaEvent.CANPLAY);

					if (!_isPreloading) {

						sendEvent(HtmlMediaEvent.PLAY);
						sendEvent(HtmlMediaEvent.PLAYING);

					}

					_timer.start();

					break;

				case "NetStream.Seek.Notify":
					sendEvent(HtmlMediaEvent.SEEKED);
					break;

				case "NetStream.Pause.Notify":
					_isPaused = true;
					sendEvent(HtmlMediaEvent.PAUSE);
					break;

				case "NetStream.Play.Stop":
					_isEnded = true;
					_isPaused = false;
					_timer.stop();
					_bufferEmpty ? sendEvent(HtmlMediaEvent.ENDED) : null;
					break;

			}
		}

		private function securityErrorHandler(event:SecurityErrorEvent):void {
			trace("securityErrorHandler: " + event);
		}

		private function asyncErrorHandler(event:AsyncErrorEvent):void {
			// ignore AsyncErrorEvent events.
		}

		private function onMetaDataHandler(info:Object):void {
			_duration = info.duration;
			_framerate = info.framerate;
			_videoWidth = info.width;
			_videoHeight = info.height;

			// set size?

			sendEvent(HtmlMediaEvent.LOADEDMETADATA);

			if (_isPreloading) {

				_stream.pause();
				_isPaused = true;
				_isPreloading = false;

				sendEvent(HtmlMediaEvent.PROGRESS);
				sendEvent(HtmlMediaEvent.TIMEUPDATE);

			}
		}

		// interface members
		public function setSrc(url:String):void {
			if (_isConnected && _stream) {
				// stop and restart
				_stream.pause();
			}

			_currentUrl = url;
			_isRTMP = !!_currentUrl.match(/^rtmp(s|t|e|te)?\:\/\//);
			_isConnected = false;
			_hasStartedPlaying = false;
		}

		public function load():void {
			// disconnect existing stream and connection
			if (_isConnected && _stream) {
				_stream.pause();
				_stream.close();
				_connection.close();
			}
			_isConnected = false;
			_isPreloading = false;

			_isEnded = false;
			_bufferEmpty = false;

			// start new connection
			if (_isRTMP) {
				_connection.connect(_currentUrl.replace(/\/[^\/]+$/,"/"));
			} else {
				_connection.connect(null);
			}

			// in a few moments the "NetConnection.Connect.Success" event will fire
			// and call createConnection which finishes the "load" sequence
			sendEvent(HtmlMediaEvent.LOADSTART);
		}

		private function connectStream():void {
			trace("connectStream");
			_stream = new NetStream(_connection);

			// explicitly set the sound since it could have come before the connection was made
			_soundTransform = new SoundTransform(_volume);
			_stream.soundTransform = _soundTransform;

			_stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); // same event as connection
			_stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

			var customClient:Object = new Object();
			customClient.onMetaData = onMetaDataHandler;
			_stream.client = customClient;

			_video.attachNetStream(_stream);

			// start downloading without playing )based on preload and play() hasn't been called)
			// I wish flash had a load() command to make this less awkward
			if (_preload != "none" && !_playWhenConnected) {
				_isPaused = true;
				//stream.bufferTime = 20;
				_stream.play(_currentUrl, 0, 0);
				_stream.pause();

				_isPreloading = true;

				//_stream.pause();
				//
				//sendEvent(HtmlMediaEvent.PAUSE); // have to send this because the "playing" event gets sent via event handlers
			}

			_isConnected = true;

			if (_playWhenConnected && !_hasStartedPlaying) {
				play();
				_playWhenConnected = false;
			}

		}

		public function play():void {

			if (!_hasStartedPlaying && !_isConnected) {
				_playWhenConnected = true;
				load();
				return;
			}

			if (_hasStartedPlaying) {
				if (_isPaused) {
					_stream.resume();
					_timer.start();
					_isPaused = false;
					sendEvent(HtmlMediaEvent.PLAY);
					sendEvent(HtmlMediaEvent.PLAYING);
				}
			} else {

				if (_isRTMP) {
					_stream.play(_currentUrl.split("/").pop());
				} else {
					_stream.play(_currentUrl);
				}
				_timer.start();
				_isPaused = false;
				_hasStartedPlaying = true;

				// don't toss play/playing events here, because we haven't sent a
				// canplay / loadeddata event yet. that'll be handled in the net
				// event listener
			}

		}

		public function pause():void {
			if (_stream == null)
				return;

			_stream.pause();
			_isPaused = true;

			if (_bytesLoaded == _bytesTotal) {
				_timer.stop();
			}

			_isPaused = true;
			sendEvent(HtmlMediaEvent.PAUSE);
		}

		public function stop():void {
			if (_stream == null)
				return;

			_stream.close();
			_isPaused = false;
			_timer.stop();
			sendEvent(HtmlMediaEvent.STOP);
		}

		public function setCurrentTime(pos:Number):void {
			if (_stream == null)
				return;

			sendEvent(HtmlMediaEvent.SEEKING);
			_stream.seek(pos);
			sendEvent(HtmlMediaEvent.TIMEUPDATE);
		}

		public function setVolume(volume:Number):void {
			if (_stream != null) {
				_soundTransform = new SoundTransform(volume);
				_stream.soundTransform = _soundTransform;
			}

			_volume = volume;

			_isMuted = (_volume == 0);

			sendEvent(HtmlMediaEvent.VOLUMECHANGE);
		}

		public function getVolume():Number {
			if(_isMuted) {
				return 0;
			} else {
				return _volume;
			}
		}

		public function setMuted(muted:Boolean):void {

			if (_isMuted == muted)
				return;

			if (muted) {
				_oldVolume = (_stream == null) ? _oldVolume : _stream.soundTransform.volume;
				setVolume(0);
			} else {
				setVolume(_oldVolume);
			}

			_isMuted = muted;
		}

		private function sendEvent(eventName:String) {

			// calculate this to mimic HTML5
			_bufferedTime = _bytesLoaded / _bytesTotal * _duration;

			// build JSON
			var values:String =
							"duration:" + _duration +
							",framerate:" + _framerate +
							",currentTime:" + (_stream != null ? _stream.time : 0) +
							",muted:" + _isMuted +
							",paused:" + _isPaused +
							",ended:" + _isEnded +
							",volume:" + _volume +
							",src:\"" + _currentUrl + "\"" +
							",bytesTotal:" + _bytesTotal +
							",bufferedBytes:" + _bytesLoaded +
							",bufferedTime:" + _bufferedTime +
							",videoWidth:" + _videoWidth +
							",videoHeight:" + _videoHeight +
							"";

			_element.sendEvent(eventName, values);
		}
	}
}

Normalize line endings

Normalize line endings