Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem migrating onClipEnter frame and angle property in as 3.0

Status
Not open for further replies.

clemcrock

Programmer
Dec 17, 2006
63
US
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:
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;
}

In this section, I need to find an as 3.0 equivelent to the this.angle property:
Code:
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);
}

Any ideas?

Thanks,
Eric
 
I'm a bit closer w/ the on enter frame which looks like this:
Code:
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);
};

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

Code:
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;
}

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?

 
I have solved the problem of passing parameters to the addEventListener function
it's not truly passing params but it gives me the ability to reference the object that called the eventListener function.

Code:
function mover(event:Object)
{
var clip_name:Object = event.currentTarget; // this gives me the reference to the object that called the mover function I was looking for
}

Now if I could figure out how to find an equivelant to the angle property I would be home free!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top