cubical38
asked on
AS3: TypeError: Error #1009... Can someone look at my code and see where this error is coming from?
I know from the output window that it is on frame 2 yet I have been unable to find the source of this all-so-generic and seemingly pointless error. Code posted below:
The only thing I can see that looks suspicious is this piece of code that has no listener, yet it still functions properly:
initSite();
Can anyone see any discrepancies that my weary eyes are overlooking?
Thanks again...
The only thing I can see that looks suspicious is this piece of code that has no listener, yet it still functions properly:
initSite();
Can anyone see any discrepancies that my weary eyes are overlooking?
Thanks again...
stop();
try {
//TweenLite.to(pre_mc, .5, {y: "-100", ease:Back.easeIn});
trace("see ya pre");
var myTimer:Timer = new Timer(2500, 1);
myTimer.addEventListener(TimerEvent.TIMER, ToolGone);
myTimer.start();
function ToolGone(event:TimerEvent):void {
TweenLite.to(rotate_mc, .9, {alpha: 0, ease:Back.easeInOut});
}
var myTimer2:Timer = new Timer(2000, 1);
myTimer2.addEventListener(TimerEvent.TIMER, GetOut);
myTimer2.start();
function GetOut(event:TimerEvent):void {
trace("uh oh! the timer has begun");
var buttons:Array =[moreInfo_btn,rotate_btn,magnify_btn];
var links:Array =["HiltiCallouts.swf","Hilti-Rotation.swf","Hilti-Magnify.swf"];
var hotspotY:Array =[20,40,0];
var link = String(links[0]);
var currentBtn:MovieClip;
var previousBtn = MovieClip(buttons[0]);
var hotspot:Loader = new Loader();
addChild(hotspot);
function initSite():void {
for (var i:Number = 0; i < buttons.length; i++) {
buttons[i].id = i;
buttons[i].alpha = .2;
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.MOUSE_OVER, btnOver);
}
previousBtn.mouseEnabled = false;
previousBtn.alpha = 1;
hotspot.y = hotspotY[0];
hotspot.load(new URLRequest(link));
trace("link");
trace(link);
}
initSite();
trace ("initSite");
function btnOver(e:MouseEvent):void {
e.target.alpha = 1;
e.target.addEventListener(MouseEvent.MOUSE_OUT, btnOut);
e.target.addEventListener(MouseEvent.CLICK, btnClick);
}
function btnOut(e:MouseEvent):void {
e.target.alpha = .2;
}
function btnClick(e:MouseEvent):void {
try {
link = String(links[ e.target.id ]);
hotspot.y = Number(hotspotY[ e.target.id ]);
trace(link, hotspot.y);
e.target.removeEventListener(MouseEvent.MOUSE_OUT, btnOut);
e.target.removeEventListener(MouseEvent.CLICK, btnClick);
currentBtn = MovieClip(buttons[ e.target.id ]);
currentBtn.alpha = 1;
previousBtn.alpha = .2;
currentBtn.mouseEnabled = false;
previousBtn.mouseEnabled = true;
previousBtn = currentBtn;
hotspot.load(new URLRequest(String(link)));
} catch (error:TypeError) {
trace("IOTypeError catch: " + error);
} finally {
trace("Finally!");
}
}
}
} catch (error:TypeError) {
trace("IOTypeError catch: " + error);
} finally {
trace("Finally!");
}
ASKER
Yea I have done that until I am blue in the face. I guess the question I have is should there be a listener for initSite()? Such as this.addEventListener(e: ..... , initSite); not a mouse event but some other event...
If I comment out the function of initSite, the piece doesnt work. If I comment out initSite(); again it doesnt work, so I am unable to see an error.
Any thoughts?
If I comment out the function of initSite, the piece doesnt work. If I comment out initSite(); again it doesnt work, so I am unable to see an error.
Any thoughts?
Can u upload ur files?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Im not even really sure what I did, but the error is gone so... Thanks
the compiler will usually tell you where the error resides so if it is your initSite
go through and comment everything out and uncomment each one until you find what is throwing the error.
then put a if (whaterver != null)
stops the compiler error.
it's not tidy but this 1009 error seems to be the most common error ppl experience its just a case of making sure everything is ready and initialised before you try an access it.