Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorclayton
    • CommentTimeMay 12th 2008
     
    I am working on a custom player of swf content. Some of the content the player loads and plays is custom Flash content (swf files) such as learning games. Depending on how the external content is built, sometimes the pause button for the player will not pause everything in the loaded content swfs - for example, things not on the main timeline, or clips created dynamically.

    Does anyone know of a standard approach to such a problem?
    • CommentAuthorphilip
    • CommentTimeMay 12th 2008
     
    you need to target both the stage and the container movieclip.

    assuming you loaded your content into a container (movieclip/sprite/moviecliploader, etc.), you'd need to invoke stop() in the container, too. something along the lines of:


    //stop the main timeline (stage)
    stop();

    //stop the timeline of the loaded SWF
    container.stop();


    things get more complicated if you're loading content that requires custom controls, such as a Captivate SWF or FLV video, or if you have really deeply nested movieclips (a movieclip loaded in a movieclip loaded in a movieclip).

    - philip
    • CommentAuthorclayton
    • CommentTimeMay 12th 2008
     
    The reason I ask is precisely for problems more complicated than the one you list. The player does handle flv and Captivate swf, neither of which are a problem. The problem is with complicated games, sims, and third-party content created according to the standards and methods of other teams.

    One path might be to try to handle ANY content that comes into the player - how does the actual Flash player 9, or a robust custom content player, handle all those nested clips, for example, when some are playing and some not during a pause attempt?

    The other approach is to set specs for developers of content, and to be prepared to quickly re-engineer content from third parties to meet these specs. Of course, it is asked that these steps are not restrictive to the developers of content, and therein lies the dilemma.

    Do you have any recommendations as to a good approach?

    - clayton
    • CommentAuthorphilip
    • CommentTimeMay 12th 2008
     
    I think we need to define "pause"; in ActionScript, there's no pause(), only stop() and play().

    If you want to give a blanket order to stop all movieclips, without any regard for being able to starting them again, you could try something like this (from ActionScript.org):

    function getAllMc(mc) {
    for (var i in mc) {
    if (typeof mc[i] == "movieclip") {
    mc[i].stop();
    getAllMc(mc[i]);
    }
    }
    }

    getAllMc(_level0);


    It basically uses a recursive loop to go through every movieclip on the stage.

    If you want to be able to resume playing them, you could try using the same loop and swap 'stop' for 'play'. In that case, it would be a good idea to abstract the function so it's usable in both situations; maybe something like this:

    //ActionScript 2

    function stopMCs(state:Boolean, mc:MovieClip):Void {

    if(!mc){ return false; }

    for (var i in mc) {
    if (typeof mc[i] === "movieclip") {
    if(state){
    mc[i].stop();
    } else {
    mc[i].play();
    }
    stopMCs(state, mc[i]);
    }
    }

    }

    //stops all nested MCs in SWF
    stopMCs(true, _root);

    //plays all nested MCs in SWF
    stopMCs(false, _root);

    //stops all nested MCs in movieclip named "container"
    stopMCs(true, container);


    Note: I haven't tried this code at all! I don't know for sure that it works, but the theory is sound. It should work in AS3 with some minor tweaks, too.

    If you're talking about creating a custom playback controller API that you want other developers to use, you're gonna have a lot of work on your hands! :bigsmile:

    With so many issues to deal with (documentation, dev team coordination issues, AS2-AS3 communication issues, and dealing with custom navigation used by 3rd party software such as Captivate and Articulate), something like this can get incredibly complex and time-consuming.

    I suggest keeping it simple; maybe sometimes instead of stopping a loaded SWF you can just unload it?

    - philip
    • CommentAuthorclayton
    • CommentTimeMay 13th 2008
     
    You are correct to clarify the "pause" - in this context, I mean to effectively pause and unpause a playing swf, using as2 play and stop commands. The content pieces can be complex games and sims, with variable states for play and performance, so unloading is not an option.

    As to your suggested approach, I have considered it, but, unless I am wrong, this would cause everything to play, even things (like the main timeline or a nested clip) that are meant to be stopped - all audio, for example, would be launched, wouldn't it? Won't work. I also am living with your statement "With so many issues to deal with..."

    Modifying your suggested code to check for whether the current clip is playing or not or not seems the only solution, if a solution strictly on the player-side is possible. I have not yet tried this.

    Alternatively, setting a requirement on the development side to "register" and "unregister" with the player, any MCs within a swf, that are not on the main timeline, and to require that no stop() actions are used on the main timeline to control playing of the piece (which is precisely how a great deal of content is built)...

    And so you see. I will try the solution mentioned, and, as always, I appreciate your consideration - such in-depth problems are not so well addressed on the mega-forums.
    • CommentAuthorclayton
    • CommentTimeMay 13th 2008
     
    I found the problem addressed in sufficient detail on the mega-forums after all.

    http://www.actionscript.org/forums/showthread.php3?t=48337&page=3

    As far as finding a solution for doing this with third party content, doesn't look good. This functionality is simply not built into Flash.