actionscript question

  • Started
  • Last post
  • 3 Responses
  • nearestexit

    I have three MCs in my library. My main time line has one frame and one layer with only actionscript.

    The actionscript right now creates and empty movie clip on the stage. What I want next is to dynamically load the first movie clip in my library, play it, then load the second, play it, then load the third and play it.

    I can load one but after it loads and plays, I can't seem to get the next one to load.

    Keep in mind I'm trying to do this keeping all my script on the main timeline.

    Thanks in advance.

  • UndoUndo0

    create a function that loads the mcs and on the last frame of each of yr mcs call the function and pass through the id/name of the clip to load next (apart from the last clip)

    ie

    myLoadingFunc = function(clipName){
    // loading script
    }

    on last frame:
    myLoadingFunc("clipID");

  • joyride0

    what he said ^
    Don't forget to set the linkage id in the library.

    I make my functions different. but either way, same thing:
    function = myLoadingFunc (clipName) {
    // as
    }

  • nearestexit0

    Figured it out.

    Thanks for the other responses, but I was trying to keep all my actionscript on the main timeline -- not in the mc's.

    Here's how I did it. You'll need three movie clips with linkage names 'mc_1', 'mc_2', and 'mc_3'.

    Here's the actionscript. Add this to frame 1 of the main timeline.

    var mcArray:Array = new Array( 'mc_1', 'mc_2', 'mc_3' );
    var nIndex:Number = 0;
    function ShowNextClip() {
    var mcClip:MovieClip = _root.attachMovie( mcArray[nIndex], 'showMe', 10 );

    mcClip.onEnterFrame = function() {
    if( mcClip._currentframe == mcClip._totalframes ) {
    _root.ShowNextClip();
    }

    }

    nIndex ++;
    if( nIndex > mcArray.length -1 ) {
    nIndex = 0;
    }
    }

    ShowNextClip();
    stop();