[Tweener] Tween around circular path

Zeh Fernando zeh at zehfernando.com
Mon Nov 2 12:31:10 PST 2009


"whatever" is the name of the object that contains the getter/setter. Since
your class is the one who contains it, you can get rid of that "whatever"
object in your code and instead do

Tweener.addTween(this, {objectAngle: 50, time:1});

But notice that it changes the position of "myObject" which should be a
sprite, a movieclip, or something.

Remember that the code basically assumes that setting .objectAngle changes
the position of one of the object's children along an ellipsis. If you want
.objectAngle to change the position of the object itself, you'd have to
change the code to reflect that, by setting its own x/y instead.

Zeh


On Mon, Nov 2, 2009 at 3:20 PM, Fred Naude <info at headspacemedia.co.za>wrote:

>  Thanks Zeh,
>
>
>
> I still seem to be missing some point though.
>
> I have created a class with this code:
>
>
>
> package
>
> {
>
>                 import flash.display.*;
>
>                 import caurina.transitions.*;
>
>
>
>                 public class CircularTest extends MovieClip
>
>                 {
>
>                                                 var myObject:Object;
>
>                                                 var whatever:Whatever = new
> Whatever();
>
>                                                 protected var
> _objectAngle:Number
>
>
>
>                                                 public function
> CircularTest()
>
>                                                 {
>
>
> addChild(whatever);
>
>
> Tweener.addTween(whatever, {objectAngle: 50, time:1});
>
>                                                 }
>
>
>
>                                                 public function get
> objectAngle(): Number
>
>                                                 {
>
>                                                                 return
> _objectAngle;
>
>                                                 }
>
>
>
>                                                 public function set
> objectAngle(__value:Number): void
>
>                                                 {
>
>                                                                 if
> (_objectAngle!= __value) {
>
>
> _objectAngle= __value;
>
>
>
>                                                                 // Redraw
> object
>
>                                                                 var
> radiusX:Number = 10;
>
>                                                                 var
> radiusY:Number = 20;
>
>                                                                 var
> px:Number = Math.cos((_objectAngle / 180) * Math.PI) * radiusX;
>
>                                                                 var
> py:Number = Math.sin((_objectAngle / 180) * Math.PI) * radiusY;
>
>                                                                 myObject.x
> = px;
>
>                                                                 myObject.y
> = py;
>
>                                                 }
>
>                                 }
>
>
>
>                 }
>
> }
>
>
>
> But I get the following error:
>
>
>
> ## [Tweener] Error: The property 'objectAngle' doesn't seem to be a normal
> object property of [object Whatever] or a registered special property.
>
>
>
> What should the property be that I should be using?
>
>
>
> Thanks,
>
>
>
> Fred
>
>
>
> *From:* tweener-bounces at lists.caurinauebi.com [mailto:
> tweener-bounces at lists.caurinauebi.com] *On Behalf Of *Zeh Fernando
> *Sent:* 02 November 2009 09:24 PM
> *To:* tweener at lists.caurinauebi.com
> *Subject:* Re: [Tweener] Tween around circular path
>
>
>
> Oops, the setter should be
>
> public function set objectAngle(__value:Number): void {
>
> instead of just "angle".
>
> Also, you'd use it like...
>
> Tweener.addTween(whatever, {objectAngle: 50, time:1});
>
> Etc.
>
> Zeh
>
> On Mon, Nov 2, 2009 at 2:22 PM, Zeh Fernando <zeh at zehfernando.com> wrote:
>
> That's a way, but personally I believe it's way too wacky.
>
> Personally, independently of the tweening engine used, I'd create a
> function that allowed you to project an object on the ellipse then create a
> getter/setter and just tween it. Something like
>
>
> protected var _objectAngle:Number
>
> public function get objectAngle(): Number {
>     return _objectAngle;
> }
>
> public function set angle(__value:Number): void {
>     if (_objectAngle!= __value) {
>         _objectAngle= __value;
>
>         // Redraw object
>         var radiusX:Number = 10;
>         var radiusY:Number = 20;
>         var px:Number = Math.cos((_objectAngle / 180) * Math.PI) * radiusX;
>         var py:Number = Math.sin((_objectAngle / 180) * Math.PI) * radiusY;
>         myObject.x = px;
>         myObject.y = py;
>     }
> }
>
>
> Something like that. You may need additional transformation if you want to
> rotate the ellipsis itself instead of using simple x/y radius.
>
> Zeh
>
> On Mon, Nov 2, 2009 at 2:09 PM, Fred Naude <info at headspacemedia.co.za>
> wrote:
>
>   HI there list,
>
>
>
> How would I go about tweening an object around an ellipse with tweener?
>
> Is using Bezier points the only way?
>
>
>
> Thanks,
>
>
>
> Fred
>
>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
>
>
>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20091102/531112f8/attachment.htm>


More information about the Tweener mailing list