Problem migrating onClipEnter frame and angle property in as

  • clem_c_rock
  • Novice
  • Novice
  • clem_c_rock
  • Posts: 20

Post 3+ Months Ago

Hello,
I'm trying to migrate a simple actionscript 2.0 app to 3.0 and I'm having some problems finding equivelents of the onEnterFrame methods and the angle property in as 3.0.

In this section, I need to have the t movieClip variable onEnterFrame method call the mover function:

Code: [ Select ]
for(var i:Number = 0; i < numberOfItems; i++)
{
    var t = attachMovie("icon", "icon"+i, i+1);
    t.angle = i * ((Math.PI*2)/numberOfItems);
    t.onEnterFrame = mover;
}     
  1. for(var i:Number = 0; i < numberOfItems; i++)
  2. {
  3.     var t = attachMovie("icon", "icon"+i, i+1);
  4.     t.angle = i * ((Math.PI*2)/numberOfItems);
  5.     t.onEnterFrame = mover;
  6. }     


In this section, I need to find an as 3.0 equivelent to the this.angle property:
Code: [ Select ]
function mover()
{
    this._x = Math.cos(this.angle) * radiusX + centerX;
     this._y = Math.sin(this.angle) * radiusY + centerY;
    var s:Number = this._y/(centerX + radiusY);
    trace("**** angle: " + this.angle);
    
    this._xscale = this._yscale = s * 100;
    this.angle += this._parent.speed;
    trace( "this: " + this);
    
    this.swapDepths(Math.round(this._xscale) + 100);
}
  1. function mover()
  2. {
  3.     this._x = Math.cos(this.angle) * radiusX + centerX;
  4.      this._y = Math.sin(this.angle) * radiusY + centerY;
  5.     var s:Number = this._y/(centerX + radiusY);
  6.     trace("**** angle: " + this.angle);
  7.     
  8.     this._xscale = this._yscale = s * 100;
  9.     this.angle += this._parent.speed;
  10.     trace( "this: " + this);
  11.     
  12.     this.swapDepths(Math.round(this._xscale) + 100);
  13. }


Any ideas?

Thanks,
Eric
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • clem_c_rock
  • Novice
  • Novice
  • clem_c_rock
  • Posts: 20

Post 3+ Months Ago

I'm a bit closer w/ the on enter frame which looks like this:
Code: [ Select ]
for(var i:Number = 0; i < numberOfItems; i++)
{
    var t:Object = attach_movie("icon", "icon"+i, {x:10, y:10} );
    reflect_this_object(t);
    t.angle = i * ((Math.PI*2)/numberOfItems);
    t.addEventListener(Event.ENTER_FRAME, mover);
};
  1. for(var i:Number = 0; i < numberOfItems; i++)
  2. {
  3.     var t:Object = attach_movie("icon", "icon"+i, {x:10, y:10} );
  4.     reflect_this_object(t);
  5.     t.angle = i * ((Math.PI*2)/numberOfItems);
  6.     t.addEventListener(Event.ENTER_FRAME, mover);
  7. };


I would like to have the mover function be able to send parameters like this:

Code: [ Select ]
t.addEventListener(Event.ENTER_FRAME, mover(t));

function mover(clip_name:Object)
{
     clip_name.x = Math.cos(clip_name.angle) * radiusX + centerX;
     clip_name.y = Math.sin(clip_name.angle) * radiusY + centerY;
     var s:Number = clip_name.scaleX/(centerX + radiusY);
     clip_name.scaleX = clip_name.scaleY = s * 100; 
     clip_name.angle += clip_name.speed;
}
  1. t.addEventListener(Event.ENTER_FRAME, mover(t));
  2. function mover(clip_name:Object)
  3. {
  4.      clip_name.x = Math.cos(clip_name.angle) * radiusX + centerX;
  5.      clip_name.y = Math.sin(clip_name.angle) * radiusY + centerY;
  6.      var s:Number = clip_name.scaleX/(centerX + radiusY);
  7.      clip_name.scaleX = clip_name.scaleY = s * 100; 
  8.      clip_name.angle += clip_name.speed;
  9. }


I also still don't know how to translate the angle property. Do I need to include the bevel package in order to do this?

Thanks again for your help

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.