Copy link to clipboard
Copied
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. ![]()
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
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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. ![]()
Copy link to clipboard
Copied
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...?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more