Fairly simple. I have an instance of a movieclip (facial expressions) on every frame. 10 keyframes. On each frame I named the instance ‘myFace’. myFace has 3 keyframes. Why would this throw an error saying ‘myFace’ does not exist?
Basically every 8 seconds the facial expression changes to a random one.
import flash.utils.*;
import flash.display.*;
import flash.events.*;
var rn:int = 1
var myChar:MovieClip = new MyChar();
addChild(myChar);
myChar.x = 287;
myChar.y = 305;
addEventListener(Event.ENTER_FRAME, loop);
var t1:Timer = new Timer(8000,50);
t1.addEventListener(TimerEvent.TIMER, tf1);
t1.start();
function tf1(e:TimerEvent):void
{
rn = (Math.floor(Math.random() * (3 - 1 + 1)) + 1);
trace(rn);
}
function loop(e:Event):void
{
myChar.myFace.gotoAndStop(rn); //<- null object ref error
}