Posts Tagged ‘AS3’
Learn Actionscript 3
Grant Skinner has released his “Introduction to Actionscript 3″ slideshow from one of his workshops. There is 167 jam-packed slides full to the brim of useful information for those transitioning from as2 to as3.
[ via The Flash Blog ]
Loading and Parsing XML in Actionscript 3 – Part 1
In this first example, I’m going to show you how to load an external XML file into flash using actionscript 3 (as3). I like using XML for external config files or when the client will need to edit the content without flash.
Read more »
How to get a DisplayObject’s BitmapData
There are many uses to using a DispalyObject’s (MovieClip, Sprite, Loader, etc…) BitmapData. The main reason I find myself using it for is for scaling an image I loaded smoothly. I load the image from an external source, then pull it’s BitmapData and set it’s smoothing to true. Then I can scale the new image without it getting too grainy or pixelated. This is the same effect as selecting the “Allow Smoothing” checkbox if you are using a Bitmap from the library.
In this example, we will get the BitmapData from our MovieClip (myMC) and create a new Bitmap (b), then add it to the stage:
var bd:BitmapData = new BitmapData(myMC.width, myMC.height, true,0xFFFFFFFF);
bd.draw(myMC);
var b:Bitmap = new Bitmap(bd);
addChild(b);
I used the BitmapData.draw() method to pull the movie clip’s (myMC) pixel information. I can then use that data when creating a new Bitmap. All that is left is to add the new Bitmap (b) to the display tree (addChild).
Jagged Bitmap Movement
Recently I was working with floating text that had filters applied to it and couldn’t figure out why it was moving on whole pixels. It caused the slower movement to look really jagged and not smooth at all. It turns out that the cacheAsBitmap attribute when set to true (which is the case when filters are applied) causes flash player to render the DisplayObject on whole pixels only. A quick hack that seemed to work was to alter the width and/or the height of said DisplayObject on each frame. This causes flash player to constantly re-render and cache the bitmap data.
Example:
var myClip:MovieClip = new MovieClip();
addChild(myClip);
myClip.filters = [new BlurFilter(10,10,3)]
myClip.addEventListener(Event.ENTER_FRAME, update);
function update(e:Event) {
e.target.width += Math.random()/100;
}
wModes and GPU for Flash Player explained
Working in HTML layout and CSS you will often come along issues with how flash player is rendered in the browser. This most commonly effects how some CSS elements will render below the flash. Most CSS gurus that I have spoken with will firstly go straight to altering the wmode of the flash player. This almost always works to solve the problem, but most who really know why it works? Understanding the both the problem and solution is key to becoming efficient in future problem solving.
Tinic Uro has written up a great post on the new wmodes of Flash Player 10. In explaining the new modes, he has a straight to the point description of each mode and why/when you would want to use them.
The post also goes into great depth of the new GPU rending mode and why you might not want to give your hopes up. Read on for the full story…
What the hell is Modulus?!

Grant Skinner has started a great series of posts related to core functionality. Each post will discuss methods that are less than 5 lines of code. These “Core AS3″ snippets can be HUGE time savers when used properly. Grant does a great job at fully explaining what you need to do, and why you would want to do it.
This week: Modulus (%)
Google Maps API for Flash
It’s finally here! I have yet to really dig into it, but Google claims it does everything the Javascript version does.
Adobe AIR NativeMenu and NativeMenuItem(s)
I have dabbled a bit in AIR for sometime and really love the ability to make an “official” feeling app for Windows while working in flash. How much more official can you get than altering the NativeMenu of the window with whatever you want (rendered in text that is). You are at the mercy of the OS, but still, I can even place line separators if I want! Read on for the code…
Fade Flash DisplayObjects without the overlay!
Problem: Having DisplayObjects overlap and fading alpha. The result is the two objects alphas combining in the overlapping regions. This creates a nasty overlay that will show all the layers below the top most. This is because flash fades all the clips inside the DisplayObject, not the container clip as a whole.
Solution: All you need to do is set the container clip BlendMode to LAYER (BlendMore.LAYER). The Zedia Flash Blog has put up a straight forward example of the problem/solution.
[ via Zedia Flash Blog ]
FIVe3D: Flash Vector Based 3D Engine

There has been so much propoganda around Papervision, that I was unaware of other options. I was reading Zeh Fernando’s blog and he has been praising FIVe3D since it’s roots in AS2. According to Zeh, the difference with this engine is that it is vector based. As far as I can tell, this engine is only worth while when you don’t need to use a bitmap fill. I really can’t think of a time that I have/would need a vector only engine. If I do though, FIVe3D would be the way to go. It is a faster approach to text and vector textures than Papervision. It also seems there isn’t any online documentation either. Bummer…
[ via Zeh Fernando ]
Alternativa3D 5.0

Move aside Papervision, Alternativa3D is here and it is amazing. It will soon be available for public use.
Handy AS3 FPS Box
![]()
More and more I need a framerate display for a flash project I’m working on. The guys over at Squidder have put together the perfect tool for doing just this. Get the source from Google Code.
UPDATE: Check out this even better AS3 FPS tool that is more informative and still simple to use.
Papervision Video Plane
UPDATE: I’ve uploaded the source for this project as is. I’ve got nothing for comments in the code, so your on your own. Feel free to leave a comment with questions and I’ll try and answer them. Get the Papervision Video Plane Source
There is a possible upcoming project that may involve video with perspective. I have been using Papervision for a couple of other projects and figured I would put together a demo to see how well it handles. Enjoy

