actionscript-3document-class

Differences between timeline code vs Document class code


I'm trying to explain the differences between writing timeline code vs Document Class code, so far I have:

Timeline code:
- doesn't require a package and class declaration

Document Class code:
- requires a package and class declaration

Timeline code:
- starts working on the top-most line

Document Class Code:
- starts working from the constructor function

Timeline code:
- loops, conditionals and event listeners can be **outside** of a function

Document Class Code:
- loops, conditionals and event listeners must be **inside** a function

Are these correct, and is there anything else that would trip up people who are making the transition?


Solution

  • Time line code is old and not recommended way as it is not structured way to code. still,

    Timeline code: - you can not define access control modifier to functions or variables, by default, everything is public(as far as I know)

    Document Class Code: - you can define access control modifier

    Timeline code: - code runs every time control come in that frame

    Document Class Code: - document class being initialized only once

    Timeline code: - Variable's lifetime is only while control is in that frame

    Document Class Code: - Member variables are stay alive until application ends.

    EDIT

    Timeline code: - Same as code written in ENTER_FRAME event in document class.

    Document Class Code: - Can achieve functionality of frame code using ENTER_FRAME event.