Be a Supporter!

Document Class

  • 256 Views
  • 2 Replies
New Topic Respond to this Topic
Momo-the-Monkey
Momo-the-Monkey
  • Member since: Oct. 15, 2005
  • Offline.
Forum Stats
Member
Level 45
Musician
Document Class 2012-04-30 19:06:57 Reply

So I'm stretchin my feet in the document class feature, and I was wondering...

Lets say I want to run a certain code when I enter specific frames, just like if my code were on the timeline. How would I do that? So far I have found to use an ENTER_FRAME event and detect for the frames I want, but what is the best method about implementing that? Since I want to emulate "timeline code," I only want the code to run once when I enter a new frame. ENTER_FRAME would run the code over and over again unless I set a flag or something.

Any thoughts? Thanks


Hello, from the past!
[ PHP: Main ]

BBS Signature
Spysociety
Spysociety
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to Document Class 2012-04-30 19:09:06 Reply

With a non-documented function called addFrameScript(keyframe, function).

In the init section of your document class you can do something like for example:

addFrameScript(0, framePreloader, 1, frameMenu, 2, frameCredits);

function framePreloader()
{
}

       etc ....

So everytime you are in the specified keyframe, the function will run once. Also note that the keyframe number is always subtracted by 1.

Kirk-Cocaine
Kirk-Cocaine
  • Member since: Aug. 17, 2003
  • Offline.
Forum Stats
Moderator
Level 38
Programmer
Response to Document Class 2012-04-30 19:51:46 Reply

addFrameScript is undocumented for a reason you know! You shouldn't be try to emulate "timeline" code. Unless you're making an animation (i.e. not a game/interactive work) there's no need for more than one frame.


The water in Majorca don't taste like what it oughta.

| AS3: Main | AS2: Main | Flash Tutorials |

BBS Signature