This will align your divs in the center for Internet Explorer if the old standard margin-left:auto etc. doesn't do the do. body { text-align:center; margin:0px; } #center_box { padding-top:200px; width:700px; margin:0 auto; text-align:left; }
draw gradient dynamically with AS3
Found this gem of an example for drawing dynamic gradients: /**************************** Import Classes ****************************/ import flash.display.*; import flash.geom.*; /**************************** Define Variables ****************************/ //Type of Gradient we will be using var fType:String = GradientType.LINEAR; //Colors of our gradient in the form of an array var colors:Array = [ 0xF1F1F1, 0x666666 ]; //Store the Alpha Values in... Continue Reading →
Hide UI scrollbar when there isn’t enough text
If you only want the scrollbar to show when there is enough text to warrant a scrolling, use the following: vScrollBar.visible = contentText.maxScrollV > 1; contentText.addEventListener(Event.CHANGE, function():void{ vScrollBar.visible = contentText.maxScrollV > 1; }); src: http://www.kirupa.com/forum/showthread.php?t=296865
ScrollBarUI not scrolling on text change
If the flash component scrollbar isn't moving when you change the text inside it, you can manually call the update function on the scrollbar after you resize / change the text so it'll know to update again. scrollbar1.update(); Massive!
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 stylesheets to an html page
This is something I always forget the syntax for since I rarely do it, doing more editing already present stylesheets than adding new ones. <link rel="stylesheet" type="text/css" href="style.css">
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 →
basic date in AS3
var date:Date = new Date(); var dateString:String = (date.date) + "-" + (date.month + 1) + "-" + date.fullYear; // traces 20-05-2010