using widgetfactory, you can access captivate items on the stage - and if you can do that, you can do ANYTHING with ANYTHING - very exciting! override protected function enterRuntime():void { var mc:MovieClip = getSlideObjectByName("item"); mc.addEventListener(Event.ENTER_FRAME, function() {mc.rotation++}); } src:http://www.infosemantics.com.au/widgetking/2010/10/slip-sliding-away/
adding commas to big number counts in AS3
Just a handy snippet I pinched: function addCommaInNumber (number : Number) : String { var integer : String = "" ; var fraction : String = "" ; var string : String = number.toString(); var array : Array = string.split("."); var regex : RegExp = /(\d+)(\d{3})/; integer = array[0]; while( regex.test(integer) ) { integer =... Continue Reading →
Getting TextField to show latest additions / last lines
Pretty straightforward: debugField.scrollV = debugField.maxScrollV;
Move rows up and down in DataGrid / List AS3
If you create two buttons, 'itemUpBtn' and 'itemDownBtn', and a datagrid of name 'itemGrid', with a column of ID's in it, you can move items up and down using this code. Fairly user friendly, as it re-selects the moved item once it's moved (just relies on that ID column to move them around). Below is... Continue Reading →
Ampersand in Flash
You can use %26. This came up when someone had a & symbol in an email address field. %26
Rescale Module Wrapper
This is a pretty handy wee class, for if you make something you want to scale down, but not scale up when the screen size is bigger. So all you need to do is wrap your module into a .swf built off this class, and in the HTML set the width/height of the flash box... Continue Reading →
Dynamic Scaling in Flash
If you're making your movie do it's own rescaling dynamically (ie. the stage is 100% of window size etc and the flash movie is moving some shell clip around to center etc.) need to remember to put this in, else it won't be hearing any of the stage resize events and your rescaling won't fire.... Continue Reading →
try / catch
Try and catch is most handy for handling files with AIR etc. Pretty straightforward, but just incase you forget the syntax: try { // statements } catch (error:ArgumentError) { trace('An argument error has occured'); } catch (error:Error) { trace('An error has occured which is not argument related'); } src: (ty) http://www.foundation-flash.com/tutorials/tryandcatch/
DataGrid data to XML AS3
Probably not the prettiest method to do this, but it'll do for just before I go home. This is to change datagrid objects back into XML - this is only for my case and needs custom coding, but the method is there! var newXML:XML = new XML(<coaches></coaches>); for (var i:int = 0; i < dataGrid.length;... Continue Reading →
Datagrid – delete selected row
Again, this is all just SelectableList behaviours but how often does anyone use datagrids to remember this?! dataGrid.removeItemAt(dataGrid.selectedIndex); http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/SelectableList.html
Get frame number from label AS3
function getFrameByLabel(yourMovieClip:MovieClip, frameLabel: String ):int { var scene:Scene = yourMovieClip.currentScene; var frameNumber:int = -1; for( var i:int ; i < scene.labels.length ; ++i ) { if( scene.labels[i].name == frameLabel ) frameNumber = scene.labels[i].frame; } return frameNumber; } Src: http://stackoverflow.com/questions/4846858/as3-simple-way-to-get-the-frame-number-of-a-frame-label
DataGrid select a particular row
Not much to this snippet haha, but I had trouble finding it. It's part of the SelectableList class. dataGrid.selectedIndex = 0;