I'm looking at the Hello World fla. I can see that the three visuals in the library are linked to physics classes. I can also see that the blocks are instantiated in the HelloWorld.as class. My dumb question is:
Where is the initialization of the HelloWorld class occuring in the HelloWorld.fla?
Thanks
Hi canstein,
Not a dumb question at all.
The 'Document class' in HelloWorld.fla is set to 'HelloWorld', so the HelloWorld class in HelloWorld.as is used as the main class for the document, so when the application is run the 'Document class's constructor (HelloWorld() function) is called.
Hopefully that makes sense, and answers your question (there are way too many HelloWorld's in that sentence :P).
I found it! and that makes total sense. I started making the transition to actionscript 3.0 this past weekend (assuming that's a new as3 feature and I'm not talking out of my ass 🙂) and I had yet to use this option.
Thanks for the help and great work on this port. I'm so excited to play with it.
variables declared inside loops don't have a separate scope from the function scope. AS3 shouldn't be throwing any compile errors on your code though, just "Warnings"
I usually declare my looping integers outside my for loops
Ah, thank you, that makes sense (apart from the motivation - I can't see how from a language design point of view getting rid of block scope would be preferable, as block scoping allows loop optimizations that should be more difficult if inner variables stay "live" outside the block, but I assume the have their reasons; besides, what do I know, anyways, I'm not a JIT designer!). And yes, you're right, it was just a warning, but I'm shooting for zero-warning compiles as a general rule, at least until I know the language well enough to know when not to be concerned.
Another issue that bit me was that AS3 does not appear to allow constructor overloading, another choice that I can't for the life of me understand, but luckily (like the above issue) it's not too difficult to work around, esp. since they do allow default values to be passed. More just an issue when trying to port code from other languages...
In any case, thanks for the explanation!