I have an object that I push onto the stage every 5 seconds called Rock, when the rock is added, I pull its speed from a function called globalSpeed, it then returns a random number, however, the first time this function is called, it gets an undefined number and causes my rock to freeze, but everything else after that works, trace looks like:
undefined
40
35
67
etc
what could be causing this
ActionScript Code:
[LEFT][COLOR=#000000]**var**[/COLOR] myRock:Rock = [COLOR=#000000]**new**[/COLOR] Rock[COLOR=#000000]([/COLOR]globalSpeed[COLOR=#000000]([/COLOR]myRock[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]function[/COLOR] globalSpeedCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR]thisObj is Rock[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]return[/COLOR] [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]random[/COLOR]COLOR=#000000[/COLOR]*[COLOR=#000080]40[/COLOR]+[COLOR=#000080]50[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]