Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple problem - Error 1046

Explorer ,
Nov 30, 2011 Nov 30, 2011

Hi,

So when I publish my flash I have this error "1046: Type was not found or was not a compile-time constant: objectifs_btn."

Here's my small code...

import flash.display.*;
import flash.events.MouseEvent;

objectifs_btn.addEventListener(MouseEvent.CLICK, ouvrirPopup, false, 0, true);

function ouvrirPopup(evt:MouseEvent):void{
popup_mc.gotoAndPlay("on");
}

(objectifs = objective and ouvrirPopup = openPopup in English)

I went into my AS3 parameters to uncheck "declare automatically every instances on the stage" (might be written a bit differently, litteral translation here).

My movieclip instances are really named "objectifs_btn" and "popup_mc", no mispelling.

I looked into different forums telling me to add the first two lines (the "import" ones), which I did. But the problem is still there.

I'm pretty sure it's an obvious problem, but I just can't see it.

Thank you very much.

TOPICS
ActionScript
5.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Dec 01, 2011 Dec 01, 2011

Thank you for your advice.

Here's the code I had when I removed completely my instance name (but I'm pretty sure it leads nowhere to tell, since it's obvious that the code can't work with no instance name) : "1120: Access of undefined property objectifs_btn."

Plus, I'm 100% sure my instance were named right since I was copy-pasting them from one place to the other. And futhermore, I overlooked them more then once to be sure. The code is so small it's not as if it was hard to check.

I made some more

...
Translate
LEGEND ,
Nov 30, 2011 Nov 30, 2011

There is nothing wrong with the code you show, and the import statements are likely unnecessary but won't hurt to include.  Go into your Flash Publish Settings and select the option to Permit Debugging.  Then run the file again and see what line number shows up after the frame number in the error message.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2011 Dec 01, 2011

If I check "permit debugging", it ain't giving more info.

But I tried something else : removing my instance name. Obviously the code doesn't work (at least that's normal), but I do not have the 1046 error anymore! What should I conclude of this?

Thank you for giving me some of your time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2011 Dec 01, 2011

Ok ok weird. I put back my instance name but remove the underscore, only keeping "objectifs" and... it WORKS!

But weird, I never noticed before that instance names didn't like the underscore character. Is that new to AS3...?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2011 Dec 01, 2011

You should always include the entire error message in your postings if you are asking about error messages you are getting.  I would bet the new info is there but you didn't know what to look for.

There is nothing wrong with using underscores.  You probably missed using it where you named your object, or had some other typo that got fixed when you retyped the name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2011 Dec 01, 2011
LATEST

Thank you for your advice.

Here's the code I had when I removed completely my instance name (but I'm pretty sure it leads nowhere to tell, since it's obvious that the code can't work with no instance name) : "1120: Access of undefined property objectifs_btn."

Plus, I'm 100% sure my instance were named right since I was copy-pasting them from one place to the other. And futhermore, I overlooked them more then once to be sure. The code is so small it's not as if it was hard to check.

I made some more test, just to "find out why" (it's nice that it's working, but it's even better to know why it wasn't working in the first place). I put back the "_btn" at each place, and the code did not work again. When I removed it again : it worked. If I tried another name : it worked. And most amazingly, if I tried another name + "_btn" it worked too!

So here's another speculation : can it be because my instance name was exactly the same name than the movieclip that it didn't work? Changing it even the smallest (removing the plural form for example) made the code works!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines