A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Synchronizing class behaviour with timeline behaviour

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    28

    resolved [RESOLVED] Synchronizing class behaviour with timeline behaviour

    I have been asking a lot of questions that tie into a jigsaw puzzle project I am working on. Here's another

    The user places the jigsaw puzzle pieces in their correct places. This is all done in frame 1 using Actionscript in the document class and the puzzle piece classes.

    After successful completion of the puzzle I issue the command this.gotoAndPlay(2) from the document class, and this starts in frame 2 a "congratulations" animation. This animation is created by animators, and I don't know how many frames long it will finally be.

    So in a way, you can think of it as two seperate worlds between frame 1 (which is my "programmer space", using the document class and piece classes) and frame 2 onwards (which is the "animator space", using the timeline).

    There will be various unused puzzle pieces strewn around the board when the user completes the puzzle. The requirement is that starting in frame 2 they fade out while the "congratulations" animation is playing, for the duration of the animation.

    Since this is to happen from frame 2 and beyond I wanted to leave it to the animators, but the problem is that they don't know where the pieces are going to be lying starting in frame 2. During the actual game (in frame 1) they may have moved the pieces anywhere.

    So I have two questions:

    1) (a non-Actionscript question) Is there a way to start fading out objects on the stage from a particular frame without knowing their positions on the stage, and without using Actionscript?

    and

    2) (an Actionscript + timeline question) If I do have to fade out the pieces using Actionscript, well, that in itself is easy enough by progressively changing the alpha value, but is there a way to sync it with the animation? Maybe if I just know how many frames long the "congratulations" animation is I should be able to space it out correctly.

    However I am not very knowledgeable about integration between what's happening in the timeline and what's happening in the document class. I do realize that the document class IS the timeline. So perhaps what I need is to be notified each time the playhead moves a frame using the ENTER_FRAME event? I suppose this would be a solution but as a newbie I'm wondering if there is a better way. I don't like the fact that I'd have to know in advance how long the "congratulations" animation is going to be.

  2. #2
    Junior Member
    Join Date
    Apr 2008
    Posts
    28
    Bump...

    Maybe the post was too verbose and scared people off? To just ask the question directly:

    I want to fade out jigsaw puzzle pieces lying on the stage. What is the standard way to sync it with another animation that is playing in the timeline? This other animation will be created by animators and does not use Actionscript. I am using a document class and piece classes for the pieces.

    This may actually be a newbie question (I'm too much of a newbie even to make that determination ), and perhaps belongs in that section.

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Either you need to fade out each piece separately or if you can separate the pieces in one Sprite and the animation in another Sprite, you fade out the whole sprite.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Apr 2008
    Posts
    28
    Quote Originally Posted by cancerinform
    Either you need to fade out each piece separately or if you can separate the pieces in one Sprite and the animation in another Sprite, you fade out the whole sprite.
    Thanks.

    Each piece is an instance of my piece class (which extends MovieClip) so I'll be fading them out separately by progressively changing their alpha property.

    This "progressively" is the problem. The other animation is another movie clip running in the timeline. I want to do this fading out in sync with the other animation.

    Would this be a solution?
    - Determine the frame count of that other animation and use the ENTER_FRAME event in each piece to fade it out a little bit (a ratio of the total frame count of the other animation).

    If so is there then a way to programmatically determine the length of the other animation? In other words is there a class somewhere that gives us properties and methods about a particular motion tween of a separate movie clip?

    (I suppose I can have the animator tell me the frame count, but there are 90 such puzzles and I'd rather automate this)

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You can write a class and make this the class for the other animation. The you can determine the frame count.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    Apr 2008
    Posts
    28
    Wow, reading this thread again after a month I realize how more knowledgeable I am now.

    Since then my solution has been to put all these animations in separate SWFs, I have a single AS file that they all use as their document class, and I've told the animators to put cues into the timeline of the general form.
    Code:
    DocClass( root ).doSomething()
    I load these animations dynamically as needed and am able to access their data from the loading class (which is my puzzle application).

    Works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center