Results 1 to 8 of 8

Thread: Detecting end of embedded .swf in AS3?

  1. #1
    Join Date
    Aug 2006
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Detecting end of embedded .swf in AS3?

    I have an old flash project that a client wants more stuff tacked on to the end of. Unfortunately, a different developer created the thing and we can't get the source files from him. So, he suggested embedding the original .swf into a new file and then just letting it play through, then adding more when it is finished. My question is this:

    1) I'm not actually our flash guru. So, does anyone know a good way in Actionscript 3 to detect when an embedded .swf hits its end so we can advance to the next keyframe automatically? (There's a way built in to the .swf to fast-forward and rewind, so there's no guarantee it'll always take the same amount of time. Else, I'd just set it to wait a certain number of frames/seconds)

    2) The .swf in question has looping music at the end. Is that going to be an issue?

    Thanks for any advice.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    I'm not actually our flash guru. So, does anyone know a good way in Actionscript 3 to detect when an embedded .swf hits its end so we can advance to the next keyframe automatically? (There's a way built in to the .swf to fast-forward and rewind, so there's no guarantee it'll always take the same amount of time. Else, I'd just set it to wait a certain number of frames/seconds)
    The MovieClip class has two properties that would be helpful here -- framesLoaded and currentFrame. Theoretically speaking, you should be able to do something like this:
    Code:
    if (mc1.currentFrame == mc1.totalFrames) {
        trace("We're at the end, folks.");
    }
    More information: Adobe LiveDocs

    The .swf in question has looping music at the end. Is that going to be an issue?
    Depends on how the audio is looped. If it's frame dependent, then yes it will be a problem. If it's not, then it shouldn't be. I'd suggest removing the audio (actually, you'll just be able to mute it) from the embedded SWF and adding it to the container SWF. That way, it'll be seamless. Otherwise, you'll probably have a bit of a rough seam when the old SWF ends and the new one begins.

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    The only problem with Medy's theory (which will work and you could even trace to have the file tell you frame number or label, etc..) is you would have to know the MC's name.

    If the original files were paid for then you should be able to get the .fla's from the original developer, or if he is just unreachable and the file is legit, you could always decompile it.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    The only problem with Medy's theory (which will work and you could even trace to have the file tell you frame number or label, etc..) is you would have to know the MC's name.
    No you wouldn't. AS3 allows you to traverse the timeline and use object references. You might be able to do it in AS2. I'm not sure as I've never had reason to try it.

    In AS3, though, you can do call the object at the top-most layer of the included MC like this (container would the MC that I load the external SWF into);

    Code:
    container.getChildAtIndex(0)
    It does require some prior knowledge of the embedded SWF. You could figure all of that out with some trial and error, though.

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    And what if MC in question didn't have linkage enabled, or an instance name (unlikely I know, but it could happen) ?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    And what if MC in question didn't have linkage enabled, or an instance name (unlikely I know, but it could happen) ?
    It doesn't matter. You're accessing the embedded timeline directly (more specifically, display list). As long as you can see those MC's, a reference to that object is available through the display list.

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    interesting.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi I have a similar problem.
    I have no way to detect which movie is playing on stage so that when I click on Btn2 it displays Movie2 while Movie1 is still playing in the background stacked behind Movie2.

    I have 8 buttons with 8 corresponding movies.
    On Btn1 click, play Movie1,
    on Btn2 click, play Movie2,
    on Btn3 click, play Movie3,

    problem is I don't know how to detect which movie is currently playing to
    tell it to play current movie out to targeted movie...
    HELP would be greatly appreciated.

Bookmarks

Posting Permissions

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