htmlText missing lines of text – autosize – AS3

If you've got htmlText, imported from, say, xml - you might lose some lines in bullet lists and things, just some real odd stuff like that. You can sort that out by assigning autosize to the textField, AFTER you've assigned the text to it. coursesField.autoSize = TextFieldAutoSize.LEFT; coursesField.wordWrap = true; coursesField.htmlText = whatever;

Character codes for ECMA based languages

\f matches form-feed. \r matches carriage return. \n matches linefeed. \t matches horizontal tab. \v matches vertical tab. \0 matches NUL character. [\b] matches backspace. \s matches whitespace (short for [\f\n\r\t\v\u00A0\u2028\u2029]). \S matches anything but a whitespace (short for [^\f\n\r\t\v\u00A0\u2028\u2029]). \w matches any alphanumerical character (word characters) including underscore (short for [a-zA-Z0-9_]). \W matches any... Continue Reading →

Retrieving attributes from XML in AS3

To return specific attributes of an xml node, you can use the @[attribute] reference - pretty handy. Eg, with this xml: <question file="test_file.swf"> You can call that file attribute using the below: myXMLList.question[0].@file; // returns test_file.swf

Adding embedded sounds via AS3

AS3 has this nasty habit of not playing sounds you put on timelines of embedded clips how you might like. They might start at random times when other things're playing, play on frames with no sound, no real end to all the crazy things it might do. Safer to use actionscript directly to add the... Continue Reading →

Popup code

Should put this into a class for use later. Uses 'btn0' and 'pop0' as the instance names. // popup code. should keep it somewhere. import com.greensock.TweenLite; import com.greensock.easing.*; var pop:Array = new Array(); var btn:Array = new Array(); var numItems:Number; var tweenSpeed:Number = 0.5; function init():void { for(var i:uint = 0;i< 200;i++) { if(this["btn" +... Continue Reading →

Duplicating an array

AS3: var array1:Array=[5,7,121,2434,5656,575]; var array2:Array = new Array(); array2=array1.concat(); trace(array2); AS2: little did you know, that you can't jsut go array_b = array_a; as that just refers to the same array isn't that annoying? I know you think so too. So you can use this to duplicate an array. Don't ask me how it works... Continue Reading →

forEach on arrays

forEach is a nice wee function to speed some bizzo up on particular arrays. myArray.forEach(myFunction); // for each item in this array, runs myFunction function. } public function myFunction(element:*, index:int, arr:Array):void { // element returns the current item (ie. myArray[0] etc. and the rest is clear) }

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑