Movieclip(root) doesn't work inside a function
Hey everyone,
I'm having this problem.
In fact, when i publish my FLA with player 9, there is no prob.
When i publish with selecting player 10, there is this problem.
I paste my code :
var leng:int = MovieClip(root).program.websiteXML.pages.titlePage.length();
trace ("leng"+leng);
setInterval(function () : void {
if (MovieClip(root).program.autoCh==true){
trace("CHANGE");
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s4");
if (MovieClip(root).program.linkPic < int(leng-1)){
MovieClip(root).program.linkPic++;
}else{
//MovieClip(root).allContent.play ();
MovieClip(root).program.autoCh=false;
MovieClip(root).program.linkPic=1;
}
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s4");
for (var z:uint=1; z<(MovieClip(root).program.linkPic+1); z++) {
var tempMC:MovieClip = MovieClip(MovieClip(root).allContent.controllMenu2)["itemButton_"+z];
Tweener.addTween(tempMC, { x:(z-1)*(45+1)-353, time:1} );
}
for (var j:uint=(MovieClip(root).program.linkPic+1); j<7; j++) {
var tempMC2:MovieClip = MovieClip(MovieClip(root).allContent.controllMenu2)["itemButton_"+j];
Tweener.addTween(tempMC2, { x:(j-1)*(45+1)+352, time:1} );
}
MovieClip(root).allContent.controllMenu2['itemButton_' + MovieClip(root).program.linkPic].gotoAndPlay("s3");
}}, 4000);
For leng variable, there is no problem, the value is taken.
But it's inside SetIntervall, at
MovieClip(root).program.autoCh
it tells me that :
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
at Function/<anonymous>()[main6_cs3_fla._00button_136::frame1:32]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
And if I put the value outside the function :
var autoChtest = MovieClip(root).program.autoCh;
And use it :
if (autoChtest==true)
There is no errors but my function doesn't work correctly, as autoCh can be "false" in another action.
Well, I hope this will not scare you, and someone will try to help me, please.
If someone know anything about this issue or having same problem please tell me.
Thanks!