A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 57

Thread: actionscript help for lipsync

  1. #1
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356

    actionscript help for lipsync

    Ok, the next program I want to create is for lipsync but I need some AS help. Here's what I would like to do...

    I would like to have a movie clip with multiple frames and be able to control it with AS, something like...

    play frame 3

    pause 3 seconds

    play frame 5

    pause 1 second

    play frame 1

    pause 7 seconds

    As you see, I would like to jump from frame to frame at different times. Each frame having a mouth shape.

    Frame 1.) "A,I"
    Frame 2.) "E"
    Frame 3.) "F, V"
    Frame 4.) "L"
    Frame 5.) "O"
    Frame 6.) "U"

    Frame 7.) "CL" (closed mouth)

    Frame 8.) "C1" (custom 1)
    Frame 9.) "C2" (custom 2)
    Frame 10.) "C3" (custom 3)
    Frame 11.) "C4" (custom 4)
    Frame 12.) "C5" (custom 5)

    The user will have to create his own mouth shapes in the 12 frames.

    So when I create the program, you'll be able to sync a wav file to an animation then export the AS, so it can be used in KM. Would be great if the AS could be one script.

    How does this sound? Any help would be great.

  2. #2
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    It might be better to have a movieclip with 12 movieclips within it so there could be motion between each mouth movement.

  3. #3
    Member
    Join Date
    Jan 2005
    Posts
    49
    C'mon somebody help this guy!!!! KM really needs this!!!!

    Todd

  4. #4
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Set the FPS value to 30.
    Now ... for each keyframe where do you need a pause,set this script:
    del =30;
    onEnterFrame = function(){
    del -= 1;
    if(del == 0){gotoAndPlay(x);}
    }
    stop();

    So ...
    for keyframe 3 you'll have: del = 90 , x = 5
    for keyframe 5 you'll have: del = 30 , x = 1
    and so on.

    try to do your best

  5. #5
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Thanks Remus, I'll start on this when I get home.

  6. #6
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Thanks again Remus but what I'm looking for is one script to go on the main movie clip that holds the 12 frames. So here's an example...

    onClipEvent
    goto frame 5
    wait a second or two
    goto frame 1
    wait a second or two
    goto frame 11
    wait a second or two
    and so on...

    Does that make any sense?

  7. #7
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Hi Joe,

    Can the code is posted a while ago be of some help ?
    http://www.flashkit.com/board/showth...hreadid=623645

    Regards,
    Wilbert

  8. #8
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Hello Wilbert, long time no talk. Thanks for the link, just have a couple questions.

    mySoundEvents.push ( { sp:1500, o:_root.mc1, f:'gotoAndStop', p:['eeks'] } );

    Looks like after 1.5 seconds something happens in mc1 that you goto and stop at. Not sure what eeks is for.

    Does this script sync audio with movieclips and does the main script go into frame 1?

    Thanks

  9. #9
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    This AS doesn't work but shows what I'm trying to do in one script. I'm sure it also needs some stop commands as well.

    onClipEvent(load){
    counter = getTimer();
    }
    onClipEvent(enterFrame){

    this.gotoAndPlay(frame 3);
    }
    if (getTimer() > counter+5000){

    this.gotoAndPlay(frame 11);

    counter = getTimer();
    }

    But I'll want to add as many "gotoAndPlay" frames and so forth.

  10. #10
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by FLASHPULSE
    Thanks again Remus but what I'm looking for is one script to go on the main movie clip that holds the 12 frames. So here's an example...

    onClipEvent
    goto frame 5
    wait a second or two
    goto frame 1
    wait a second or two
    goto frame 11
    wait a second or two
    and so on...

    Does that make any sense?
    Ahaaa ... so you're looking for a sequencer. OK.
    Create an empty movieclip in the first frame.
    Add the following script for it:

    onClipEvent(load){
    faz = 1;
    del = [0,30,90,60];
    jmp = [0,5,1,11];
    }
    onClipEvent(enterFrame){
    if( faz < 5){
    if(del[faz]>0){
    del[faz] -= 1;
    }else{
    _parent.gotoAndPlay(jmp[faz]);
    faz += 1;
    }
    }
    }


    note: copy and paste this movieclip in each keyframe of your main movie.
    That's all.

  11. #11
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    That's exactly what I'm looking for but can't seem to get it to work.

    I created a movieclip and entered the script. Added my 12 frames in the movieclip and put text in each frame so I could see if the script works but I get nothing.

  12. #12
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Here's the file if you want to look it over, unless you're at work.
    Attached Files Attached Files

  13. #13
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by FLASHPULSE
    Here's the file if you want to look it over, unless you're at work.
    That's because the sequencer and the main movie are two different things (movieclips).
    In your example is one and the same thing, and this is wrong !
    Replace _parent.gotoAndPlay(jmp[faz]); with this.gotoAndPlay(jmp[faz]);.
    Also, if you have a single keyframe animations, you have to add the stop(); action for each keyframe.
    Come on JOE, you can do better than that !

  14. #14
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    LOL! I've been trying to work on this all night. Brain is sleepy at the moment. It's 2:44am here, going to bed and will work on it tomorrow, thanks Remus.

  15. #15
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Ok, is this what you were talking about. The script seems to go through these frames in this order, 1,2,1,2,1,2,3, although that doesn't look like what it should do looking at the AS. Going to bed now.
    Attached Files Attached Files

  16. #16
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by FLASHPULSE
    Ok, is this what you were talking about. The script seems to go through these frames in this order, 1,2,1,2,1,2,3, although that doesn't look like what it should do looking at the AS. Going to bed now.
    Don't use tweens for AS keyframes !!!
    How many times I have to say it ?


  17. #17
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Hey Remus, after getting some sleep I got it to work both ways, with "_parent" and "this". The reason I was going with the "this" way, is so the main timeline could have all the animation (characters and so forth) and multiple movieclips could use your script for the lypsync.

    I understand the way you were going about it with "_parent" now and that would work well also.

    Thanks again! (just trying to stay in your black book, LOL)

    ARRRG!!! This $%#@ server is always busy. Been trying to post for a half an hour now

  18. #18
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Hey Remus, can del have values of 1.25, 2.5 and so forth and play properly? The reason is, is because I need to get down to the milliseconds in my lipsync program. One second intervals is not quick enough for mouth movments. Also, in my program you can choose a framerate between the values of 12 and 30. I had to add that in because I knew if I didn't some one would complain that they couldn't choose their own fps.

    Oh, the script is fine the way it is, no need to rewrite, just wondering if del will be able to use decimals? Thanks again.

  19. #19
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    As far as I can tell the routine Remus posted isn't accurate to the second but accurate to the frame. You can only display one mouth shape per frame so that should be enough.

    But if you want it to be accurate I doubt if this approach will work. The only accurate approach for syncing is using sound.position because a flash movie will never play exactly at the specified framerate.

  20. #20
    Senior Member FLASHPULSE's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    1,356
    Thanks for the information Wilbert. I knew that it wouldn't be acurate to the "T" or anything but I was wondering if I use a number that cotained a decimal if flash would accept it. In my test it worked but I wasn't sure if flash just saw it as (for example) 2 or 2.50? It was just a quick test to see if it would work. Not long enough of a test to see if timing went off down the line. That will be done later.

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