Tuesday, November 10, 2009

AS3: Adding a Sprite as a child to a Flex Container for example a Canvas

From http://www.sebastiaanholtrop.com/archives/3 use:


import mx.core.*;

var my_canvas:Canvas = new Canvas();
var my_uic:UIComponent = new UIComponent();
var my_sprite:Sprite = new Sprite();

my_canvas.addChild(my_uic);
my_uic.addChild(my_sprite);

Sunday, November 8, 2009

Flex 3: Adding you custom component sources in the compiler

Rather then copying custom or external code libraries to your source, it is better to add it using mxmlc compiler option "--source-path=/your/path/here".

Thursday, November 5, 2009

AS3: Enabling scaling in AS3 for your games or movies

By default AS3 set scaling to NO_SCALE. If you want to override this so that your games or movies scale properly use:

stage.scaleMode = StageScaleMode.SHOW_ALL;
once your stage has been initialized.

Tuesday, October 27, 2009

AS3: Opening a window in the users browser

Use navigateToURL if you want to open a window in the users browser. For example:

 navigateToURL(new URLRequest("http://www.lazysquirrelgames.com"),  
"_blank");


Adobe documentation:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html

Sunday, October 25, 2009

AS3: Customizing the preloader

By default Flash player displays a simple bar for loading progress. A little code snippet at http://www.flexdeveloper.eu/forums/actionscript-3-0/download-progress-bar-(downloadprogressbar)/ shows how to start modifying this initial screen. The code does not generate anything pretty but is a good start towards understanding what needs to be done.

The relevant adobe documents:
http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_4.html
http://livedocs.adobe.com/flex/3/langref/mx/preloaders/DownloadProgressBar.html

Thursday, October 22, 2009

AS3: Latency aka delay in playing sound

Encountered a problem where I am trying to play short sounds in response to key presses and noticing a considerable delay. Googling for stuff other people seem to have encountered it. Need to test the swf on a windows box to see if what I am seeing is specific to my Linux box.

Some usefull threads on this:


http://stackoverflow.com/questions/227674?sort=oldest#sort-top

This thread indicates it may be specific to Pulseaudio: http://ubuntuforums.org/archive/index.php/t-1146361.html

No solution here but describes the problem well: http://forums.tigsource.com/index.php?topic=7927.0;wap2

EDIT: So tested this on windows XP, the lag still exist but is small enough that I can work around it.