DYNAMIC MOVIECLIP REGISTRATION WITH AS3

THURSDAY, MARCH 15 2007 @ 04:59 PM

So, you wanna change the registration point of a MovieClip at runtime? Here is some piece of code that allows you to do just that.

Based on an old AS2 class written by Darron Schall, this AS3 class extends MovieClip and adds a new set of properties (x2, y2, rotation2, scaleX2, scaleY2, mouseX2, mouseY2) that allow you to manipulate the sprite based on a contextual registration point that can be set using the setRegistration method.

Here is how it works:

  1. // Create a new instance
  2. var square:DynamicMovieClip = new DynamicMovieClip();
  3. addChild(square);
  4.  
  5. // Change registration coordinates at runtime
  6. square.setRegistration(20, 20);
  7.  
  8. // From this point on, instead of using 'rotation'
  9. // we use 'rotation2'
  10. // Same principle applies for 'x', 'y', 'scaleX' and 'scaleY'
  11. square.rotation2 = 45;

Here's a simple application.



Sources

Archived under: Flash, ActionScript 3.0. | Permalink | google | del.icio.us Is it delicious? | digg Do you digg it?


ERIC D

MARCH 15 2007 @ 05:20 PM

TypeError: Error #1010: A term is undefined and has no properties.
at map_fla::MainTimeline/setUpdate()
at map_fla::MainTimeline/onUserTimelineResult()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at twitter.api::Twitter/::userTimelineLoadHandler()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

OSCAR TRELLES

MARCH 15 2007 @ 06:22 PM

I think that's from the map/twitter widget. I'll check it out, thanks for the heads up!

BASHAR

JULY 14 2007 @ 07:38 PM

it is a very weird error. i am getting the same error for very simple drag and drop in actionscript 3.

545454

JULY 17 2007 @ 03:49 AM

fdfdf