A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: _totalFrames and externally loaded swfs.

  1. #1
    Junior Member
    Join Date
    Sep 2004
    Posts
    19

    _totalFrames and externally loaded swfs.

    Im working on a cd-rom application in Flash for my portfolio which will feature heavy video (enhanced music cd)

    Using Sorenson Squeeze I have exported mpeg video directly to a swf.
    I have about 10 swfs and each are circa 30mb.

    As such they are brought in using loadMovie when requested and attached to movie_mc (a placeholder).

    Because I used sorenson I have no ability to add functions (preloader to pass back a totalFrames variable to the main timeline)to these external swfs.

    I need to determine the totalFrames in a loaded swf in order to determine when it has finished playing so that it can be replaced with a standard mc.

    using a combination of this code:

    enteredTrack = audioFields_mc.songInput;
    loadMovie("musicVids/"+enteredTrack+".swf", moviePlayer_mc.movie_mc);
    dynamicTitle = enteredTrack+".swf";
    dynamicTitleFrames = moviePlayer_mc.movie_mc.dynamicTitle._totalframes;
    Im having no luck.
    I know for a fact that this line is wrong
    moviePlayer_mc.movie_mc.dynamicTitle._totalframes;
    and it is infact reading "dynamicTitle" as part of the path instead of adding its value to the path. How to fix this, I dont know.

    Im also concerned that requesting the _totalframes immediately after loading the video in wont work because it will not be fullyloaded from the CD when the function is called.

    Help!

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    You should target the placeholder, as the external swf is ragarded as the movieclip its loaded into.

    You can check like this ...

    if( moviePlayer_mc.movie_mc._currentframe ==moviePlayer_mc.movie_mc._totalframes &&moviePlayer_mc.movie_mc._totalframes >100){
    // It has reached its last frame. Do something
    }

    ..then at least 100 frames has to be loaded before it checks if the swf has reached the last frame.

    This code of course has to be repeated, either in a frameloop or have the code ON the placeholder in a onClipEvent handler.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Junior Member
    Join Date
    Sep 2004
    Posts
    19
    I cant thank you enough!

    I have got it working to some extent now in a for loop., shouldnt take too much longer to figure out how to get it doing exactly what I want.

    Thank you.

  4. #4
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Dont use a for loop for this......( a for loop just checks once )

    Just make the timeline go between 2 frames ( frameloop ) so the code can check wether the condition is tru or not.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  5. #5
    Junior Member
    Join Date
    Sep 2004
    Posts
    19
    It is working using this code:

    for (i=1; i<1000; i++) {
    if (moviePlayer_mc.movie_mc._currentframe == moviePlayer_mc.movie_mc._totalframes && moviePlayer_mc.movie_mc._totalframes>100) {
    // It has reached its last frame - Do something
    trace("Loaded");
    }
    }
    };
    This is in the main timeline on the first frame on a level with all of my other functions etc.

    I then use a pause / play button function in the same place (called from the buttons who pass the currentFrame to the function)

    pauseMovie = function(frameNum){
    trace("paused Movie at num ="+frameNum);
    moviePlayer_mc.movie_mc.gotoAndStop(frameNum+1);
    }
    If i was to do this using two frames, I would have to put the code onto the movie_mc holder wouldnt I? I would also have to make this holder instance have two frames with no stops?

    I appreciate using

    for (i=1; i<1000; i++) {
    is the most unpractical way ever. (1000 loops makes baby jesus cry)

    Thanks for your help fella.

  6. #6
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    A loop performs all its actions in the time of ONE frame. Thats why you can not animate with loops.

    You could use this ON the holder clip...

    code:

    onClipEvent(enterFrame){
    if (this_currentframe == this._totalframes && this._totalframes>100) {
    // It has reached its last frame - Do something
    trace("Loaded");
    }
    }




    Note that the action you later will put in there is regardes as if its inside the movieclip, so be shure to make the right paths.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  7. #7
    Junior Member
    Join Date
    Sep 2004
    Posts
    19
    Firstly, I would sincerely like to thank you for you efforts in helping me so far.

    As for your last reply.

    onClipEvent(enterFrame){
    if (this_currentframe == this._totalframes && this._totalframes>100) {
    // It has reached its last frame - Do something
    trace("Loaded");
    }
    }
    The movie_mc (holder clip) is a single frame empy movie clip.
    The entire application exists on one fram across multiple layers.
    Alot of content is pulled in dynamically.
    As such the movie_mc is on stage from application launch and so the code you suggested above would be executed literally when the the user first loads the application and not when each external swf is loaded in.

    It might also be worth pointing out that when that code was placed ON the movie_mc and the app was published, ..the trace did not run.

  8. #8
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    The code will run only when there is at least 100 frames of an swf loaded already. Thats what ....

    this._totalframes>100


    ...does. This as you dont want it to execute the actions all the time.

    It does not matter how many frames the movieclip has. The code is independent of and frames.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  9. #9
    Junior Member
    Join Date
    Sep 2004
    Posts
    19
    You sir, rock.

    Cant believe i didnt see that sooner, all is working fine now., much obliged sir.

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