Using MovieClip(root) Problem
im at frame 3.. i have text field on the stage name scoreTxt.. at frame 3 i added TryClass..
TryClass has function of updateScore.. so my code is
public function updateScore(amount:int):void
{
score += amount;
if(score < 0) score = 0;
realNumber = score;
setInterval(updateDisplayedScore, 10);
var displayedNumber:Number = 0;
function updateDisplayedScore():void
{
displayedNumber += Math.round((realNumber-displayedNumber)/5);
if (realNumber - displayedNumber < 5 && realNumber - displayedNumber > -5)
{
displayedNumber = realNumber;
}
addZeros();
}
function addZeros():void
{
var str:String = displayedNumber.toString();
MovieClip(root).scoreTxt.text = str; <------ i use MovieClip(root) as i saw from internet..its working fine.. but
}
}
but then if for example .. the user died or he reaches the required score.. im suppose to go a certain frame using this code..
MovieClip(this.root).gotoAndStop("Main");
its reaching the frame "Main" but its pointing errors to this --> MovieClip(root).scoreTxt.text
that "Main" frame is on frame 4.. which i did not yet added the TryClass.. should i add to all my frames the TryClass? and how is that?
Sorry for the question.. i dont know yet how to perfectly code in the class.. and accessing the timelines and other external class.. Please dont use deeper language of actionscript.. on a beginner way only..
