A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Controlling a movie clip in an external swf

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    6

    Controlling a movie clip in an external swf

    I'm working from main.swf and I need to call another swf to display one of four flvs once the appropriate button is clicked.

    main.swf = my main content
    player.swf = contains mc_playMovie
    mc_playMovie = embedded in player.swf and contains four frames, each with a different flv movie.

    My code so far:

    butDelmar_thumb.onRelease = function() {
    createEmptyMovieClip("targetMC", this.getNextHighestDepth())
    targetMC._x = 0
    targetMC._y = 0

    loadMovie("player.swf","targetMC");

    //I need to specify which frame of mc_playMovie I land on here. This particular button needs frame 2, for instance.

    };

    AS2 btw
    Last edited by bmasar; 11-04-2010 at 05:44 PM.

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I suggest using a movieClipLoader() instance instead of the older loadMovie() method..

    it gives you more control over the states of the loading process..

    what you'll want to do, is use the onLoadInit() call back..and change your target clip to the appropriate frame then.


    example:
    actionscript Code:
    // create an empty movieClip on the stage to hold our content...(this can be any target you want though)
    var containerClip:MovieClip = this.createEmptyMovieClip("containerClip", this.getNextHighestDepth());


    // create our MovieClipLoader instance (called: contentLoader)
    var contentLoader:MovieClipLoader = new MovieClipLoader();
    //create an object to handle the data available form the MovieClipLoader() object.
    var contentListener:Object = new Object();
    // create function that fires/executes when the content starts loading
    contentListener.onLoadStart = function(target_mc:MovieClip):Void  {
        trace(">> contentListener.onLoadStart()");
    };
    // create function that fires/executes each time a byte/potion is loaded (preloader)
    contentListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void  {
        trace(">> contentListener.onLoadProgress()");
    };
    // create function that fires/executes when the content is complete
    contentListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void  {
        trace(">> contentListener.onLoadComplete()");
    };
    // create function that fires/executes when the content has initialized and is ready for manipulation
    contentListener.onLoadInit = function(target_mc:MovieClip):Void  {
        trace(">> contentListener.onLoadInit()");
        target_mc._x = 0
        target_mc._y = 0
        //jump to specific frame inside of target_mc contents
        target_mc.mc_playMovie.gotoAndStop(2);
    };


    // add our 'listener' object to our MovieClipLoader instance
    contentLoader.addListener(contentListener);

    butDelmar_thumb.onRelease = function() {
        // finally, make the call to load whatever content we want.. this is just an on-line image (but can be whatever, .swf, .jpg, clips in library..etc)
        contentLoader.loadClip("player.swf",containerClip);
    };

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