1. Actionscript 3.0: Rotate Around Center Point

    Posted on: July 21, 2008

    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;
     }
    (more…)

  2. Flash CS3: Images look jagged when rotating, scaling, etc…

    Posted on: June 12, 2008

    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:

    Flash CS3 Allow Smoothing for Bitmaps

  3. Actionscript 3: Event.target returns children of movieclip

    Posted on: June 11, 2008

    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;
    (more…)

  4. Resizing bitmap images with Actionscript 3.0

    Posted on: June 3, 2008

    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);
    }

  5. Can’t import fl.video.VideoPlayer?

    Posted on: May 30, 2008

    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


  6. APE Class Model

    Posted on: May 29, 2008

    Click above for a giant layout of all the APE classes and the way they inherit each other. Definitely helpful.


  7. Excellent APE Beginner’s Resources!

    Posted on: May 28, 2008

    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!


  8. Flash CS3 UIScrollBar Trouble

    Posted on: May 27, 2008

    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.

    (more…)

  9. The Flash vCam

    Posted on: February 27, 2008

    Any good animation changes camera angles from time to time. Unfortunately these is no easy way to do this in Flash… by itself.

    However, a fellow named Sham Bhangal wrote a little application using actionscript that allows us to have a virtual camera that can be animated within scenes.

    (more…)

  10. Keeping Sound in Sync with Long Flash Animations

    Posted on: February 3, 2008

    Whether you’re just starting out in Flash, or have been playing with it for some time, chances are you have run into problems with sound synchronization. If you’re new to Flash and have been experiencing problems in this area, chances are the solution is very simple as I will explain in a moment. However, if the following isn’t news to you and you’re still having problems, keep reading, the solution may follow.

    (more…)