moockblog
http://www.moock.org/blog/
en-us2009-05-25T22:58:22-05:00get visible width/height of a display object
http://www.moock.org/blog/archives/000292.html
When it comes to the width and height variables of ActionScript's DisplayObject, what you see is not always what you get. For example, consider the following code, which draws a 50x75 rectangle at position (10, 10) in a Sprite, and then masks it with a 40-pixel-diameter circle: // The mask var maskShape:Sprite = new Sprite(); maskShape.graphics.beginFill(0); maskShape.graphics.drawCircle(20, 20, 20); addChild(maskShape); // The rectangle var rect:Sprite = new Sprite(); rect.graphics.beginFill(0xFF0000); rect.graphics.drawRect(10,...ActionScriptmoock2009-05-25T22:58:22-05:00can't enable gpu acceleration in flex builder/mxmlc
http://www.moock.org/blog/archives/000291.html
while working with a colleague at megaphone, it recently came to my attention that there is currently no way to enable hardware acceleration at the .swf level with flex builder 3 or the flex framework's standalone compiler, mxmlc. hence, a .swf file compiled via the flex framework or mxmlc currently cannot use hardware acceleration when running in the standalone version of flash player. i logged a bug as soon as...flex buildermoock2009-05-21T16:18:45-05:00Announcing USER1 and Union
http://www.moock.org/blog/archives/000290.html
three days ago at fitc, derek clayton and i announced the launch of USER1 Subsystems Corporation and the Union Platform, a platform for creating multiuser applications. Union Alpha 1 is now available for download. USER1 is working in an exclusive partnership with Play MegaPhone Inc to create a network of big-screen, multiuser applications you control with a phone call. like shoot 'em up in Times Square or trivia at an...flashmoock2009-05-01T01:17:52-05:00the lost actionscript 3.0 weekend
http://www.moock.org/blog/archives/000289.html
i finally decided to break the print tradition and make an actionscript training dvd with o'reilly. but it's not your average training video. we wanted to capture the energy of a programming session with a group of fun and passionate friends. so james paterson, hoss gifford, and i locked ourselves away in a cabin by the ocean for a three-day weekend to shoot an eleven-hour crash course on object-oriented programming....ActionScriptmoock2009-04-24T16:04:37-05:00get number of bytes in a UTF-8 string
http://www.moock.org/blog/archives/000288.html
Here's a handy little ActionScript function that reports the number of bytes in a UTF-8 encoded string (the default encoding for ActionScript): public function getNumBytesUTF8 (s:String):Number { var byteArray:ByteArray = new ByteArray(); byteArray.writeUTFBytes(s); return byteArray.length; } // Usage: trace(getNumBytesUTF8("automobile")); // 10 trace(getNumBytesUTF8("車")); // 3 Note: "number of bytes" is not the same thing as "number of characters". For "number of characters," use the String class's length variable: trace("車".length); // 1...ActionScriptmoock2009-04-05T20:39:05-05:00James Paterson's new work
http://www.moock.org/blog/archives/000287.html
dear james, thank you for reminding us all (or me at least) why we do this. >> view The Rotten Fruit Tardis >> read about Harvest at bitforms i'm looking forward to seeing this in person at fitc....flashmoock2009-03-25T16:21:22-05:00FITC toronto 2009
http://www.moock.org/blog/archives/000286.html
[UPDATE: Shawn Pucknell, founder of FITC, just gave me a discount code for all moockblog readers! Use code "moock" to get 20% off when you register for FITC.] fitc is coming up in april (25th-28th). in my presentation i'll officially be revealing what's kept me occupied for nearly every minute of the past 8 months. for a complete list of the always-inspiring sessions at the conference, visit FITC's presentation list....eventsmoock2009-03-17T00:16:52-05:00workaround for 127px font size limit
http://www.moock.org/blog/archives/000284.html
In ActionScript, text fields formatted via TextFormat, CSS, or HTML have an undocumented maximum font size of 127px. The limitation is based on historical requirements placed on Flash Player by the operating system. The limit also applies to dynamic and input text created in the Flash authoring tool, but not to static text. Fortunately, the 127 font-size limit can be overcome with an ugly little workaround: set the font size,...ActionScriptmoock2008-08-12T01:09:46-05:00ActionScript 3.0 String-concatenation error gotcha
http://www.moock.org/blog/archives/000283.html
Take a look at this code: trace(1 + + 2); // Output: 3 It may seem strange to us, but ActionScript considers it legal. It assumes you mean: trace(1 + (+2)); which produces the value 3. Now take a look at this code: // Oops! One too many + signs... trace("Hello" + + " world"); Once again, ActionScript assumes you mean: trace("Hello" + (+ " world")); which yields the following...ActionScriptmoock2008-08-01T04:39:30-05:00event-registration performance
http://www.moock.org/blog/archives/000282.html
In Flash Player 9, the time required to register a listener for a given event increases as the number of listeners already registered for that event increases. Here are the results of a simple event-registration test on a P4-2.6ghz machine running Windows XP: Registering 1000 listeners for an event took .06ms per registration (i.e., an average of .06ms to run addEventListener() once). Registering 20000 listeners for the same event took...ActionScriptmoock2008-07-24T20:05:29-05:00TextField.text Gotcha: \n becomes \r
http://www.moock.org/blog/archives/000281.html
Here's a little TextField quirk: when you assign the string "\n" (newline) to a TextField's text variable, ActionScript automatically converts it to a "\r" character. For example, var t:TextField = new TextField() t.text = "Hello\nworld"; trace(t.text.indexOf("\r")); // 5 trace(t.text.indexOf("\n")); // -1 So if you're hunting for a "\n" you've added to a text field, you'll need to search for "\r", not "\n". The docs for TextField's text variable actually point...ActionScriptmoock2008-07-17T12:52:10-05:00The Charges Against ActionScript 3.0
http://www.moock.org/blog/archives/000280.html
More than a year has passed since Flash CS3 was released to widely positive reviews, but many Flash users are still frustrated by some of the workflow changes introduced by ActionScript 3.0. The truly problematic changes are relatively few, but together they have a deep effect on the typical Flash user's daily job. In the spirit of working toward solutions, and of giving a formal voice to the collective grumbling...moock2008-07-16T00:14:42-05:00Things You Must Do Before Unloading a SWF File
http://www.moock.org/blog/archives/000279.html
If you load a .swf file into Flash Player 9 with ActionScript 3.0 and subsequently wish to remove it from memory, you must first deactivate it, and then dereference it. If you dereference the .swf without deactivating it, it will continue to consume resources and in some cases might never become eligible for garbage collection. Here is an unofficial list of tasks required to deactivate a .swf file: Tell any...ActionScriptmoock2008-07-15T21:18:45-05:00convert xml tags to lowercase
http://www.moock.org/blog/archives/000278.html
Here's a handy little function for converting all tag names and attribute names in an XML object to lower case. Useful for doing case-insensitive matching on tag names and attribute names. public function xmlTagsToLowerCase (xml:XML):XML { // Convert the root tag to lowercase xml.setName(xml.name().toString().toLowerCase()); for each (var attribute:XML in xml.@*) { attribute.setName(attribute.name().toString().toLowerCase()); } // Convert all descendant tags to lowercase for each (var child:XML in xml..*) { // If the...ActionScriptmoock2008-07-02T21:49:52-05:00free AS3 training; last chance, italy
http://www.moock.org/blog/archives/000277.html
over the last 8 months, in locations around the world, i've been holding a free crash course in ActionScript 3.0 and object-oriented programming. june 23 marks the last stop on the tour: milan, italy. if you haven't made it to one of the other cities, i hope to see you in milan. i hear there are still spots available. >> register for free ActionScript 3.0 training many thanks to adobe...ActionScriptmoock2008-05-29T19:18:11-05:00