Hey, I was wondering if they found a better way of allowing the use of variables outside of an on function. For example in the script below I can use the variable bounds inside the target.onEnterFrame function because it’s declared inside the constructer. However I can’t use m_Bounds even though it’s declared in the class.
[AS] private var m_mcTarget:MovieClip;
private var m_Bounds:BoundsData;
function MotionHandler(target:MovieClip, bounds:BoundsData)
{
m_mcTarget = target;
m_Bounds = bounds;
m_mcTarget.onEnterFrame = function()
{
this._x = bounds.current.x;
this._y = bounds.current.y;
}
}[/AS]
I find it annoying and unorganized to redeclare variables from my own class just to use them in the onClick/onRelease/onEnterFrame etc.
If I were to move that onEnterFrame to a different function, I would have to provide a copy of the bounds var inside that function.
[AS] private var m_mcTarget:MovieClip;
private var m_Bounds:BoundsData;
function MotionHandler(target:MovieClip, bounds:BoundsData)
{
m_mcTarget = target;
m_Bounds = bounds;
}
public function Initialize():Void
{
var bounds:BoundsData = m_Bounds;
m_mcTarget.onEnterFrame = function()
{
this._x = bounds.current.x;
this._y = bounds.current.y;
}
}[/AS]
In AS3.0 will they let us use class variables in on functions or are there any other methods?