    /*
     * Sample Animation one can use to insert scrolling texts in their web pages
     * Written by Alexis Wilke for Made to Order Software Corp (c) 2002-2007
     */
    /* This samples shows how to use an external parameter, a font and a gradient */

    /*

    Copyright (c) 2002-2007 Made to Order Software Corp.

    Permission is hereby granted, free of charge, to any
    person obtaining a copy of this software and
    associated documentation files (the "Software"), to
    deal in the Software without restriction, including
    without limitation the rights to use, copy, modify,
    merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom
    the Software is furnished to do so, subject to the
    following conditions:

    The above copyright notice and this permission notice
    shall be included in all copies or substantial
    portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
    ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
    LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
    EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

    */

    // Some parameters can be defined on the command line at
    // generation time:
    //
    // MUST HAVE:
    //	... -Dscreen_width=<value> -Dscreen_height=<value> ...
    //					the size of the final movie in
    //					pixels
    //
    // The following are parameters you can define in your HTML
    // page so as to be able to re-use this button multiple times.
    // Note that they all are optional.
    //
    //	... msg=<string> ...		the message to be scrolled; spaces
    //					must be noted as %20 and equals as
    //					%3D
    //
    //	... bgcolor=#<RRGGBB> ...	defines the background color; each
    //					of the R, G and B letters must be an
    //					hexadecimal digit;
    //
    //	... limit=600 ...		defines the maximum value for the
    //					position counter; this is an integer
    //					and most probably will need to be at
    //					least 500; it depends on the length
    //					in pixels of your message
    //
    //	... speed=3 ...			defines the speed; the larger the value
    //					the slower the movement; use 1 to have
    //					a one pixel scroll; use 0.5 to have a
    //					two pixel scroll; use 3 to have 1/3rd
    //					of a pixel scroll per frame
    //
    // The following is an example of a URL used to display the button in the
    // SSWF web page. Note that I wrote it on multiple line for the sake of
    // clarity, but in the real page it has to be on a single line:
    //
    //	SRC="scroller.swf?
    //		msg=This%20is%20the%20scroller%20sample.
    //			%20Yet%20another%20example%20of%20how%20to%20use%20the%20SSWF%20tool!
    //			%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20
    //			Written%20by%20Alexis%20Wilke%20(c)%202002-2007
    //		&bgcolor=#FFFF00
    //		&limit=600
    //		&speed=0.5"
    //

    rectangle "screen" { 0, 0, screen_width, screen_height };

    edges "inside" {
    	screen_width, 0;
    	0, screen_height;
    	-screen_width, 0;
    	0, -screen_height;
    };

    fill style "fill_white" { sswf.col.white; };

    shape "bck" {
    	rect { -1, -1, screen_width + 1, screen_height + 1 };
    	//show_bounds: true;
    	fill_white; inside;
    };
    shape "fade" {
    	rect { -1, -1, 150, screen_height + 1 };
    	fill style {
    		gradient {
    			matrix { scale: 0.03; translate: 25, 0; };
    			0.0, sswf.col.white;
    			1.0, color { 1, 1, 1, 0 };
    		};
    	};
    	screen_width = 150;
    	inside;
    };

    ////////////////////////////////////////////////////
    // The text is put in a dynamic text object (Edit Text)
    // so it can be changed in the HTML reference to this
    // SWF movie
    //
    // Note that I'm also showing the use of the Blue Highway
    // Condensed font and you won't be able to use HTML tags
    // which reference other font stylers such as italic and
    // bold; thus, by default I turned off the HTML feature
    ////////////////////////////////////////////////////
    edit text "message" {
    	rect { 0, 0, 1000, 100; };
    	word_wrap: false;
    	multiline: false;
    	password: false;
    	readonly: true;
    	no_select: true;
    	border: false;
    	outline: true;
    	variable: "the_msg";
    	html: false;
    	init: "<no message>";
    	align: "left";
    	text setup {
    		sswf.col.black;
    		id: sswf.fnt.Blue_Highway_Condensed.insert.fnt, 22 / 20.0;
    	};
    };
    sprite "msgobj" {
    	place object {
    		id: bck;
    		depth: 1;
    	};
    	show frame;
    	do action {
    		action "stop";
    	};
    };
    sprite "color_msg" {
    	replace object {
    		"background";
    		id: msgobj;
    		depth: 1;
    	};
    	do action {
    		// function to transform one character to a value from 0 to 15
    		// the expression goes like this:
    		//	v = (ord(bgcolor[index++]) - 0x30) & 0x1F;
    		//	if(v >= 16) v += 10 - 17;
    		//	return v;
    		// note: the index register is incremented automatically
    		//	 the '#' character(s) are silently skipped
    		// register 1 holds bgcolor
    		// register 2 holds index (starts at 0)
    		function "hex" {
    			action  "push data" {
    				register: 1;
    				integer: 1;
    				register: 2;
    			};
    			action "increment";
    			action "store register" { 2 };
    			action "swap";
    			action "substring";
    			action "duplicate";
    			action "push data" {
    				string: "#";
    			};
    			action "equal";
    			action "if true" { "zero" };
    			action "ord";
    			action "push data" { integer: -0x30; };
    			action "add";
    			action "push data" { integer: 0x1F; };
    			action "and";		// convert a-f to A-F!
    			action "duplicate";
    			action "push data" {
    				integer: 16;
    			};
    			action "less than";
    			action "if true" { "done" };
    			action "push data" {
    				integer: 0x0A - 0x11;
    			};
    			action "add";
    			action "branch" { "done" };
    			label { "zero" };
    			action "pop";
    			action "push data" {
    				integer: 0;
    			};
    			label { "done" };
    			action "return";
    		};

    		action "push data" {
    			null: 0;
    			string: "/:bgcolor";
    		};
    		action "get variable";
    		action "store register" { 1 };	// r1 = $(/:bgcolor);
    		action "equal";			// if bgcolor is null -> keep default color
    		action "if true" { "done" };

    		action "push data" {
    			string: "hex";
    			integer: 0;
    			register: 1;
    		};

    		action "string length";
    		action "store register" { 3 };	// r3 = strlen($/:bgcolor);
    		action "pop";
    		action "store register" { 2 };	// r2 = 0
    		action "swap";
    		action "call function";		// . = hex();

    		// the following transform the bgcolor=#RRGGBB in an integer
    		label { "next_char" };
    		action "push data" {
    			integer: 4;
    		};
    		action "shl";			// . <<= 4
    		action "push data" {
    			integer: 0;
    			string: "hex";
    		};
    		action "call function";
    		action "or";			// . |= hex()

    		action "push data" {
    			register: 2;
    			register: 3;
    		};
    		action "less than";		// if r2 < r3 -> next char
    		action "if true" { "next_char" };

    		// put that color in the result now
    		action "push data" {
    			integer: 1;
    			string: "setRGB";
    			string: "background";
    			integer: 1;
    			string: "Color";
    		};
    		action "new";
    		action "swap";
    		action "call method";		// (new Color("area"))->setRGB(...)
    						// where the ... is the integer generated
    						// from the /:bgcolor string

    		label { "done" };
    		action "stop";
    	};
    	show frame;
    };
    sprite "sprite_message" {
    	place object {
    		id: message;
    		depth: 1;
    	};
    	do action {
    		action "push data" {
    			string: "the_msg";
    			string: "/:msg";
    		};
    		action "get variable";
    		action "set variable";		// the_msg = msg
    		action "stop";
    	};
    	show frame;
    };
    sprite "the_message"
    {
    	place object {
    		id: color_msg;
    		depth: 1;
    	};
    	replace object {
    		"m";
    		id: sprite_message;
    		depth: 2;
    		matrix { translate: screen_width, 0; };
    	};
    	place object {
    		id: fade;
    		depth: 3;
    	};
    	place object {
    		id: fade;
    		depth: 4;
    		matrix { translate: screen_width, screen_height; rotate: pi; };
    	};
    	do action {
    		action "push data" {
    			string: "m";
    			property: "_x";
    			integer: screen_width;
    			string: "i";
    			integer: 0;
    		};
    		action "set variable";		// the index
    		action "set property";		// reset the position to the right place (probably useless)
    	};
    	show frame "repeat";
    	show frame;
    	do action {
    		action "push data" {
    			string: "i";
    			integer: 1500;
    			null: 0;
    			string: "/:limit";
    			string: "m";
    			property: "_x";
    			float: screen_width;
    			string: "i";
    			float: -1.0;
    			integer: 3;
    			null: 0;
    			string: "/:speed";
    		};
    		// . = /:speed == null ? 3 : /:speed
    		action "get variable";
    		action "store register" { 1 };
    		action "equal";
    		action "if true" { "default_speed" };
    		action "pop";			// remove the default speed
    		action "push data" { register: 1 };
    		label { "default_speed" };

    		// . = -1 / .
    		action "divide";

    		// . = . * i + screen_width
    		action "swap";
    		action "get variable";
    		action "multiply";
    		action "add";

    		// m._x = .	( == screen_width - i / speed)
    		action "set property";

    		// . = /:limit == null ? 500 : /:limie
    		action "get variable";
    		action "store register" { 1 };
    		action "equal";
    		action "if true" { "default_limit" };
    		action "pop";
    		action "push data" { register: 1 };
    		label { "default_limit" };

    		// i = i++
    		action "swap";
    		action "duplicate";
    		action "duplicate";
    		action "get variable";
    		action "increment";
    		action "set variable";
    		action "get variable";

    		// if i < . then previous frame + play else goto repeat + play
    		action "less than";
    		action "if true" { "next" };
    		action "previous frame";
    		action "branch" { "previous" };
    		label { "next" };
    		action "goto" { "repeat" };
    		label { "previous" };
    		action "play";
    	};
    	show frame;
    };

    sequence "main"
    {
    	frame_rate = 30;
    	screen;

    	set background color { sswf.col.white };

    	// The shapes
    	bck;
    	fade;

    	// The font & text
    	sswf.fnt.Blue_Highway_Condensed.insert;
    	message;

    	// The sprites
    	msgobj;
    	color_msg;
    	sprite_message;
    	the_message;

    	replace object {
    		"master";
    		depth: 1;
    		id: the_message;
    	};

    	// there isn't a way to stop this animation since it's
    	// all happening in the sprite object - thus the main
    	// movie doesn't need more than one frame
    	show frame;
    };