Joke: What would it be like to have thirty dogs?
Question: What do you think it would be like to have thirty dogs?
Answer: Ruff!
Only you would bark that answer at the person before they really had any time to think about it.
I made that up a couple weeks ago, I thought it was pretty funny. Tell everybody.
Actionscript 3.0: Scale Object from Center Point
Note: This is almost exactly the same solution I posted earlier for rotating an object around its center point (Actionscript 3.0: Rotate Around Center Point). I thought I’d post this slightly altered solution for people who need it.
Problem:
You need to scale a movieclip/sprite from its 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:
TCBWMO (Take care of business with the matrix object).
Flash/Actionscript: Innaccurate math results
Problem:
You’re working some math equations with Actionscript and tracing the results when you notice some results are off by a very small value.
output:2 2.1 2.2 2.3 2.4 2.5000000001 2.6 2.7000000001 2.8 2.9 3
Solution:
This is called a floating point error and is apparently a normal computing error that affects all aspects of computing, not just flash. You can fix this by running the values through the correctFloatingPointError function I’ve posted below.
Using the free Flex 3 SDK with Flash Develop
Recently I got back into Flash and began to learn Actionscript 3.0. Things have definitely come a long way in the last few years, and I’ve become interested in Adobe’s quest to turn the Flash format into a full fledged rich internet application framework of sorts. I’m surprised, and personally impressed on how far all this has come. Here’s a couple things I’ve come to realize (or knew about, but never dived into) in the last year or so:
Read moreActionscript 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

