Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
RottenOgre
Posts: 274
Registered: ‎11-01-2010
My Device: PlayBook?

Re: Rotating objects

This thread makes me shudder as I recall the hours I've spent on this issue wondering why everything I tried to do was getting so screwed up. Tried all the tricks with the containers and matrixes but nothing worked.

 

An easy fix is to set the registration point to center when you import the image to your library (should be able to just manipulate the properties in Flash Pro, not sure how it works in Flash Builder), but that means you're stuck with the registration in the center now, and you may want to actually change the registration dynamically for some reason.

 

Here's a nice class: http://www.oscartrelles.com/archives/dynamic_movieclip_registration_with_as3

 

Not sure what the pros and cons are between it and Peter's link, though I imagine they're pretty much the same.

 

This was probably one of the most annoying issues I've had.

Developer
biggerCC
Posts: 270
Registered: ‎12-13-2010
My Device: PlayBook 16GB, BB10 Dev Alpha

Re: Rotating objects

Thanks a lot guys!

 

I got it fixed fast with your ideas and am now pretty unsure which solution i should "accept" since all were useful and I had more than one problem in my code:

 

1) the image needs to be loaded first in order to avoid deformation issues - I now embed it as suggested

2) using the Rotator class makes your life a lot easier.

 

I've attached an screenshot showing my 4-layer-compass. Now let's all hope, that the PlayBook will get GPS and an magnetical compass built in...

 

compass.png

- - -
My approved apps @ App World
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Rotating objects

 


RottenOgre wrote:

Here's a nice class: http://www.oscartrelles.com/archives/dynamic_movieclip_registration_with_as3

 

Not sure what the pros and cons are between it and Peter's link, though I imagine they're pretty much the same.


 

Good find.  This is not a thorough list, but:

 

 

  1. the Rotator class makes a separate instance rather than requiring you to subclass something, so it can be applied to any DisplayObject but you have an extra object to manage, while the other (as written) gives you just one instance but it has to be a MovieClip
  2. the one above "fixes" scaling as well as rotation, and provides fixed mouse pos properties as mouseX2/Y2
Both appear to have their uses.  I'm curious why the Rotator has so much math involved, where the other one gets by without.  Possibly there's room for improvement in one or both.

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!