Actionscript 3.0: Rotate Around Center Point
Problem:
You need to rotate a movieclip/sprite around it’s center point, but its registration point is at (0,0) and you can’t and/or don’t feel like putting this object in the center of a container movieclip and rotating that.
Solution:
Use the transform matrix and show it who’s boss.
If you want to get this done simply and quickly, you can use this rotateAroundCenter function:
private function rotateAroundCenter (ob:*, angleDegrees:Number, ptRotationPoint:Point) { var m:Matrix=ob.transform.matrix; m.tx -= ptRotationPoint.x; m.ty -= ptRotationPoint.y; m.rotate (angleDegrees*(Math.PI/180)); m.tx += ptRotationPoint.x; m.ty += ptRotationPoint.y; ob.transform.matrix=m; }
Flash CS3: Images look jagged when rotating, scaling, etc…
Problem:
Bitmap images in Flash look like crap when animated to rotate or scale.
Solution:
Right-click on the image in the library, select Properties and check Allow Smoothing
Here’s a screenshot:
Actionscript 3: Event.target returns children of movieclip
Problem:
You’ve added a listener to a movieclip, but the target returned is another movieclip or sprite within that movieclip.
Solution:
myMovieclip.mouseChildren = false;
If I were on Wheel of Fortune…
Ryan: I’d like to buy a vowel… a “B” please…
Pat Sajak: “B” isn’t a vowel.
Ryan: Oh really? Well why don’t you just go ahead and give that to me then Pat?
Resizing bitmap images with Actionscript 3.0
Hey, I just did a quick experiment with bitmaps in AS3. Nothing fancy, I just loaded in an external JPEG, resized it into 3 different sizes and then drew them to stage. I’m sure someone can use this. For now, everything is hard-coded and the code is right in the .FLA. Maybe I’ll try and make a nice class out of this, although I’m sure there’s already one out there. Anyway, check out the code or download the FLA.
var mediaLoader:Loader = new Loader(); var bmFullsize:Bitmap; var bmHalfsize:Bitmap; var bmThumbsize:Bitmap; mediaLoader.load(new URLRequest("ostrich.jpg")); mediaLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, resizeImages); function resizeImages(e:Event):void { bmFullsize = new Bitmap(e.target.content.bitmapData.clone()); bmHalfsize = new Bitmap(e.target.content.bitmapData.clone()); bmThumbsize = new Bitmap(e.target.content.bitmapData.clone()); bmFullsize.width = 300; bmFullsize.height = 300; bmFullsize.smoothing = true; bmHalfsize.width = 150; bmHalfsize.height = 150; bmHalfsize.x = bmFullsize.width; bmHalfsize.smoothing = true; bmThumbsize.width = 75; bmThumbsize.height = 75; bmThumbsize.x = (bmFullsize.width + bmHalfsize.width); bmThumbsize.smoothing = true; showImages(); } function showImages():void { addChild(bmFullsize); addChild(bmHalfsize); addChild(bmThumbsize); }
Can’t import fl.video.VideoPlayer?
Just now I ran into a problem when trying to use to VideoPlayer class for the first time. Dang.
Problem:
When doing this:
import fl.video.*;I get this:
1172: Definition fl.video:VideoPlayer could not be found.
Solution:
I dragged an “FLVPlayback” component onto my stage, and then deleted it. I guess that forced flash to load in the needed classes. I’m not sure if this is a bug of if I’m missing something. I found my answer at the Actionscript.org forums, where it looks like a few other people may have had the same problem. I think there’s some people there that have posted speculations on why this might happen. If you care to read, the link is below.
http://www.actionscript.org/forums/showthread.php3?t=153762
Flock is great for blogging!
I just discovered how great the browser Flock is for blogging! I managed to set it up to work with my Wordpress blog (the one your reading). Now I can simply right-click on any page, and select “blog this“. A nice, fast, GUI editor pops up within Flock and I can write my post, format the text how I’d like and even drag images off of web pages in Flock right into my post. I had been meaning to try this out for a few months now, and I’m glad I finally did.
Flock uses the Gecko rendering engine, and is set-up to work a lot like Firefox. If you’re a Firefox fan, give Flock a try.
Note: As I’m writing this post I just discovered that this editor doesn’t use very good XHTML. When making the text italic it used a span tag with an inline style instead of an em. Oh well.. it’s still cool.
APE Class Model
Click above for a giant layout of all the APE classes and the way they inherit each other. Definitely helpful.
Excellent APE Beginner’s Resources!
If you have any interest in Flash + Math/Physics, I recommend you try out APE (the Actionscript Physics Engine) library by Alec Cove. It’s a set of AS3 classes that will easily let you create a world of particles that are affected by physics. If you’ve ever thought about making an action-type game, this might be the place for you to start.
Just today I stumbled upon some great examples by a guy named Andrew Garrahan that were posted to Google Group called APE General.
Follow this link to see the examples: APE Cornerstones: Basic Examples
(Thanks Andrew, these should really help me get started)
There’s also some other great examples in this group and I imagine it will grow as well. I hope this helps someone out there!
Flash CS3 UIScrollBar Trouble
I had some trouble with the CS3 UIScrollbar properly latching onto a dynamic textbox earlier this week. I found a solution and I thought I’d share.
Read more



