Reputation: 21924
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?
Upvotes: 1
Views: 1422
Reputation: 4962
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.
Upvotes: 1
Reputation: 2103
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.
Upvotes: 2