1

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?

redconservatory
  • 21,438
  • 40
  • 120
  • 189

2 Answers2

2

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.

DexTer
  • 2,043
  • 1
  • 22
  • 45
  • Thanks, this is great. I am trying to teach someone who knows only timeline code to write code in the Document class, but it's been a long time so I've forgotten the differences... – redconservatory Feb 06 '11 at 18:34
1

When writing code in a Class file, the person you're teaching may be tempted to write code that looks like this:

gotoAndStop(2);
movieclipOnFrame2_mc.stop(); // <-- uh oh...

This of course will trip them up because they are expecting that assets that exist on frame 2 will be available immediately after calling gotoAndStop(2), especially if they came from an AS2 background. They'll need to learn ways to handle this quirky behavior.

scriptocalypse
  • 4,942
  • 2
  • 29
  • 41