00:00
00:00
Newgrounds Background Image Theme

novaruah just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Error 1046: AS3

2,012 Views | 3 Replies
New Topic Respond to this Topic

Error 1046: AS3 2012-01-02 16:24:10


It's my first time using AS3, and I'm having a bit of trouble migrating from AS2. I've found some guides that have got me by so far, but I've got a weird error I can't seem to fix. It says "1046: Type was not found or was not a compile-time constant: TimerEvent." and this is the piece of code it is referring too:

var loadTimer:Timer=new Timer(5000);
loadTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener(e:TimerEvent):void {

Strange thing is, it works in a new flash document, but not the one I'm working on (with external AS files and that), but there's no reused variables/mismatches or anything like that, so I don't see what the problem is. Another one is trying to get a loaded image to centre, In AS2 I could just use something like:

_root.image._x=((stagewidth-image._width)/2)

but AS3 doesn't like it (with the new property names of course). I think it's because I had to create a bunch of different variables and objects to load the image. Tracing image.width just returns 0, I think because it's just a placeholder for the actual image. I tried creating another variable to get the image width from the server where the image is hosted, but it didn't work out too well. Any help would be great.


BBS Signature

Response to Error 1046: AS3 2012-01-02 18:24:53


Have you imported the timeevent?

import flash.events.TimerEvent;

You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.

Response to Error 1046: AS3 2012-01-02 18:33:59


At 1/2/12 06:24 PM, ProfessorFlash wrote: Have you imported the timeevent?

import flash.events.TimerEvent;

No, I just tried that and I now get 6 errors, 3 1046s and 3 1180s all related to that bit of code. The thing is, it works on its own in another flash file (same flash player/version and everything).

One thought though, could it be because I'm using external .as files and code on the frame?


BBS Signature

Response to Error 1046: AS3 2012-01-02 18:43:42


With external .as files, you have to import everything that you are using. What are all the 1046s that you got? It means you have to import stuff or declare variables. 1180 probably comes from the lack of imports, cuz it doesn't know what "Timer" is.