Copy link to clipboard
Copied
I had written a script a while ago, that I got to work with no problems, I wanted to make it a bit better/dynamic (boxes can transition left to right or top to bottom), but Im having a problem. I start the script and the tweens start, but I get the error waring me the script wil slow down my computer. I hadn't change the script that drastically so Im not sure why its not working. I tried removing clips, different test but I can't see/trace the problem.
can anybody help?
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
Block = new Array();
var Xposition:Number = 0;
var Yposition:Number = 0;
var verticalCount:Number=Math.ceil(Stage.height/30);
var horizontalCount:Number=Math.ceil(Stage.width/30);
var fadeit:Tween;
var scaleitx:Tween;
var scaleity:Tween;
var n:Number = 0;
var valueFromArray:Number
var arrayToRandom:Array = new Array();
var nextSet:Number = 0;
this.createEmptyMovieClip("mcholder", this.getDepth());
//mcholder.swapDepths(1000);
/////places them onto the stage this configuration is sky skyscraper/ reverse for leader
function leftToright ()
{
for (r=0; r<(verticalCount); r++)
{
for (c=0; c<(horizontalCount); c++)
{
var particle = mcholder.attachMovie("block","block_"+r+c ,mcholder.getNextHighestDepth());
particle._y = Yposition
particle._x = Xposition
Block
//trace(particle._name)
Xposition = Xposition + 30;
n++
}
Xposition = 0;
Yposition=Yposition+30;
}
for(var i:Number = 0; i<=horizontalCount-1; i++)
{
arrayToRandom.push(i);
}
//RandomArrayToTween ()
}
////////////////////////
function topTobottom ()
{
for (r=0; r<(horizontalCount); r++)
{
for (c=0; c<(verticalCount); c++)
{
var particle = mcholder.attachMovie("block","block_"+r+c ,mcholder.getNextHighestDepth());
particle._y = Yposition
particle._x = Xposition
Block
//trace(particle._name)
Yposition = Yposition + 30;
n++
}
Yposition = 0;
Xposition=Xposition+30;
}
///builds an array with a given number of empty pockets to use as a recrence for random numbers
//not repeating
for(var i:Number = 0; i<=verticalCount-1; i++)
{
arrayToRandom.push(i);
}
RandomArrayToTween ()
}
//leftToright ()
topTobottom ()
trace(arrayToRandom.length)
trace(arrayToRandom[2])
function randomarray (u)
{
for(var i:Number = 0; i<=numOfChoices-1; i++)
{
arrayToRandom.push( (i+u));
}
RandomArrayToTween ()
}
///////////////////////////
function RandomArrayToTween ()
{
if (arrayToRandom.length > 0)
{
var randomPos:Number = Math.floor( Math.random() * arrayToRandom.length );
var valueFromArray = arrayToRandom.splice(randomPos, 1);
var numberRand = parseInt(valueFromArray);
tweenblock(numberRand);
}
else
{
nextSet=nextSet+arrayToRandom.length
stop();
randomarray(nextSet);
}
}
function tweenblock(n):Void
{
var fadeit = new Tween(Block
var scaleitx = new Tween(Block
var scaleity = new Tween(Block
fadeit.onMotionChanged = function() {
onEnterFrame = function ()
{
if (n !== Block.length)
{
delete onEnterFrame;
//removeMovieClip.Block
RandomArrayToTween ()
}
//else
//{
//delete onEnterFrame;
//stop();
//gotoAndPlay(2);
//}
}
}
}
Kglad...I figured it out (yea for me). that was one of three of four improper variables working at the wrong time.
using trace statement after trace statement I found the problem(s)
Thank you for looking/helping!
Copy link to clipboard
Copied
where's numOfChoices defined?
Copy link to clipboard
Copied
Kglad...I figured it out (yea for me). that was one of three of four improper variables working at the wrong time.
using trace statement after trace statement I found the problem(s)
Thank you for looking/helping!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now