Best Tutorials website


Moving From Flash AS2 To Flash AS3: Static vs. Const

Moving From Flash AS2 To Flash AS3: Static vs. Const

Constants come in very handy, mostly for code maintenance. A very simple example would be constant used in game for friction. Let's say that all on-screen objects will degrade their speed .02 pixels per frame because of friction on the ground. Since there may be be dozens of places that you might apply this value for friction, you would have to hard-code .02 . This is great, unless you want to change the value and have it apply globally in your class. In that case, it is easier to create a const and use it in your code. The problem with AS2 was that there was no support for constants. They are available in AS3 though, and we will explore their use in this tutorial.




Views: 579 | Rating star | by Isac




View this tutorial
Broken link Report broken link?