I have a problem with accessing an array from a function within a function in a custom class…I have a function that uses the array booths[]…the function calls a zoom function which runs on a tween…then there is a function for when the tween finishes…however…after the zoom completes tracing the booths[] array still returns the correct values…once I enter the tweenFinished function…the booths[] array returns undefined for all values…I have 7 traces strewn threw my code here and it shows exactly when the problem occurs…can anyone help me solve this?
function listClick(boothArr:Array)
{
var lowX:Number = booths[boothArr[0]].xValue;
var lowY:Number = booths[boothArr[0]].yValue;
var tarX:Number;
var tarY:Number;
var highX:Number = booths[boothArr[0]].xValue + booths[boothArr[0]]._width;
var highY:Number = booths[boothArr[0]].yValue + booths[boothArr[0]]._height;
var myPoint:Object = {x:0, y:0};
var myPoint2:Object = {x:0, y:0};
var centerWinX:Number;
var centerWinY:Number;
var tempX:Number;
var tempY:Number;
var boothX:Number;
var boothY:Number;
var boothOffsetX:Number;
var boothOffsetY:Number;
var moveX:Number;
var moveY:Number;
var zoomTo:Number;
for(var i=0; i<boothArr.length; i++)
{
var booth:Number = boothArr*;
var trans5:Transform = new Transform(booths[booth]);
var trans6:Transform = new Transform(miniBooths[booth]);
var myColor:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 255, -255, 50);
trans5.colorTransform = trans6.colorTransform = myColor;
booths[booth].boothLight = true;
trace("1 "+ booths[0].xValue+ " "+booths[0].yValue);
if(boothArr.length > 1)
{
if(booths[booth].xValue<lowX)
{
lowX = booths[booth].xValue;
}
if(booths[booth].yValue<lowY)
{
lowY = booths[booth].yValue;
}
if((booths[booth].xValue + booths[booth]._width)>highX)
{
highX = booths[booth].xValue + booths[booth]._width;
}
if((booths[booth].yValue + booths[booth]._height)>highY)
{
highY = booths[booth].yValue + booths[booth]._height;
}
}
else
{
lowX = highX = booths[booth].xValue;
lowY = highY = booths[booth].yValue;
}
}
if(lowX == highX && lowY == highY)
{
tempX = lowX;
tempY = lowY;
boothOffsetX = booths[booth]._width/2;
boothOffsetY = booths[booth]._height/2;
}
else
{
tempX = (highX + lowX)/2;
tempY = (highY + lowY)/2;
boothOffsetX = 0;
boothOffsetY = 0;
}
if(boothArr.length > 1)
{
var zoomArea:Number;
var tempVar:Number;
if((highX-lowX) > (highY-lowY))
{
zoomArea = highX-lowX;
zoomTo = (_root.hitAreaMain._width*70)/zoomArea;
}
else
{
zoomArea = highY-lowY;
zoomTo = (_root.hitAreaMain._height*70)/zoomArea;
}
}
else
{
zoomTo = (_root.hitAreaMain._width*10)/booths[boothArr[0]].zoomScale;
}
_root.hitAreaMain.localToGlobal(myPoint2);
centerWinX = myPoint2.x + (_root.hitAreaMain._width/2);
centerWinY = myPoint2.y + (_root.hitAreaMain._height/2);
trace("2 "+ booths[0].xValue+ " "+booths[0].yValue);
_root.scaleTo(zoomTo);
trace("3 "+ booths[0].xValue+ " "+booths[0].yValue);
//trace(zoomTo);
_root.tween_handler.onMotionFinished = function()
{
trace("4 "+ booths[0].xValue+ " "+booths[0].yValue);
//trace(zoomTo);
_root.container.localToGlobal(myPoint);
boothX = ((((tempX+boothOffsetX)/100)*zoomTo)+myPoint.x);
boothY = ((((tempY+boothOffsetY)/100)*zoomTo)+myPoint.y);
moveX = (centerWinX - boothX);
moveY = (centerWinY - boothY);
trace("5 "+ booths[0].xValue+ " "+booths[0].yValue);
_root.checkBounds(moveX, moveY, 1, 0);
trace("6 "+ booths[0].xValue+ " "+booths[0].yValue);
_root.tween_handler.onMotionFinished = function()
{
trace("7 "+ booths[0].xValue+ " "+booths[0].yValue);
_root.container.localToGlobal(myPoint);
for(var j=0; j<boothArr.length; j++)
{
//var b:Number = boothArr[j];
//trace("2 "+tAx[j]+ " " +tAy[j]);
//tarX = tAx[j]*(zoomTo/100)+myPoint.x;
//tarY = tAy[j]*(zoomTo/100)+myPoint.y;
//_root.placeTarget(tarX, tarY, j);
// _root.placeTarget((boothX+_root.actualMoveX-(boothOffsetX*(zoomTo/100))), (boothY+_root.actualMoveY-(boothOffsetY*(zoomTo/100))), i);
}
_root.numTargets = boothArr.length;
}
}
}
trace output:
1 2122.5 1110
2 2122.5 1110
3 2122.5 1110
4 undefined undefined
5 undefined undefined
6 undefined undefined
7 undefined undefined
any ideas?