Skip to main content
Inspiring
December 24, 2007
Question

Strict Mode

  • December 24, 2007
  • 3 replies
  • 2649 views
I'm working in a book (Visual Quickpro Guide Flash CS3 Professional Advanced). Many of the examples throw errors (all the examples are in AS3). However, I've found that if I uncheck the "strict mode" box in the publish settings the errors go away. I've downloaded the example .flas from the books website to confirm this and indeed they have the box unchecked and their code is identical to mine. Whenever I create a new Flash file the strict mode box is checked by default. So I'm wondering, what exactly does the "strict mode" indicate and is it best to always leave it unchecked. To my thinking, examples in a published book should not throw errors, even in "strict mode." This indicates to me that something is wrong with the code. But, not knowing enough about what "strict mode" indicates maybe I'm being too harsh on the author. Any insight would be greatly appreciated. Thanks.
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
December 25, 2007
you're welcome. and yes, that could be true.
Participant
May 26, 2010

I am having a similar issue, except the book I'm using has all examples in strict mode and tells me throughout examples to

check my code. I constantly get "access to undefined property" or "type was not found or compile-time constant."

When I change to standard mode, I get thrown a "package not reflect location..."

What do I do?

I am in CS3 and I am on a Mac, but I doubt that has anything to do with these complications.

Can someone help me?

Thanks!

kglad
Community Expert
Community Expert
May 26, 2010

fix your code.  you have errors that are not the fault of an overly picky, forgetful compiler.

click file/publish settings/flash and tick "permit debugging".   use the line numbers mentioned in the error message(s) to quickly find your problematic code.

if you have any issues, start your own thread.

backpagesAuthor
Inspiring
December 25, 2007
OK, thanks, that's helpful information. However, it brings up the obvious question for a relative beginner: if the Flash player is going to throw "inappropriate errors" how do I know if I've made a mistake in my code or if Flash has lost track of an object's data type? I could spend a long time trying to figure out what is wrong when in reality nothing is wrong and I could simply turn of strict mode and the file would work perfectly. It seems a little strange to me. Maybe my best bet until I learn more is to simply leave strict mode off.
kglad
Community Expert
Community Expert
December 25, 2007
strict mode enables strict data typing by the flash compiler which means the compiler checks that you are using the correct data types (objects, sprites, arrays, numbers, booleans, localconnections etc).

this is a good thing and can help you spot errors before you would otherwise notice a problem. however, the flash compiler isn't very smart and it can (and does) easily lose track of an object's data type and throw an inappropriate error.

for example, if you use the loader class to load a swf, the content property of that loader is the main timeline of the swf - a movieclip. however, if you try and use that loader's content property like it's a movieclip, the strict mode compiler will throw an error.

you must either disable strict data typing or explicitly cast the content property as a movieclip to prevent this error from interfering with your swf's publication.