A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Get the _totalFrames of an external .swf?

  1. #1
    Member
    Join Date
    Mar 2001
    Posts
    44

    Get the _totalFrames of an external .swf?

    Hi, as the title suggests im loading a .swf into a mc using loadmovie, but i need to know when the movie has finished playing. But as the mc on my timeline is only 1 frame it thinks it has reached the end (even though the movie .swf plays till the end)

    dropZone is 1 frame but the mc being loaded into it is about 100, but this will be dynamic. Hope that makes sense. Any ideas?

    Code:
    if (dropZone._currentframe == _totalframes){
    	gotoAndStop("tester");
    }
    slammin

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    dropZone.loadMovie("a.swf"); // load the movie
    
    this.onEnterFrame = function(){ //loop at FPS
    if (dropZone._currentframe == dropZone._totalframes){ // note paths here
    gotoAndStop("tester");
    this.onEnterFrame = null; // end loop
    }
    };

  3. #3
    Member
    Join Date
    Mar 2001
    Posts
    44
    Hi, thanks for that but it doesnt seem to be quite right. It seems to think that the totalframes is 1 as as soon as it plays it skips to the "tester" even though the dropZone is playing a movie.

    Here is the code on the frame
    Code:
    stop();
    loadMovie("flvs/kitchen1.swf", "dropZone");
    this.onEnterFrame = function(){
    	if (dropZone._currentframe == dropZone._totalframes){ 
    	trace("TESTER HERE");
    	this.onEnterFrame = null; 
    	}
    }
    This does the trace as soon as it enters the frame. but if you change the if to

    Code:
    	if (dropZone._currentframe == 50){ 
    
    }
    it seems to work. Like its recognising its on the 50th frame, but it doesnt seem to recognice totalframes...

    Any ideas?
    slammin

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    hmm .. strange,
    try checking only the movieclip._totalframes property -
    Code:
    this.onEnterFrame = function(){
    total = dropZone._totalframes;
    trace(total); // what is the output ??
    };

  5. #5
    Member
    Join Date
    Mar 2001
    Posts
    44
    I tried tracing the total frames of the movie and it comes up as 0. I think this is because im asking flash for the total frames of a movie clip it hasnt had time to load. Its just too quick. As if i trace it after a few seconds it gets the correct amount.

    Is there a way of pausing mid function? ie:

    Code:
    function forwardFrames(roomNum){
    	loadMovie("flvs/"+[roomNum]+".swf", _root.mainContent.kitchenMovs.dropZone);
    	//PAUSE HERE FOR A SECOND?
            // do rest of function
    slammin

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    onEnterFrame is invoked at the FPS of the movie
    so if the movie is set at 30 FPS, onEnterFrame runs 30 times every second
    this method, and setInterval, is the standard way of looping to check the
    value of any changing variables.
    i tried this in a test file -
    Code:
    this.createEmptyMovieClip("dropZone",1);
    dropZone.loadMovie("trailer.swf"); // 496 frames
    
    this.onEnterFrame = function(){
    trace(dropZone._totalframes);
    }
    my output from the trace is -
    1
    496
    496
    496
    ....

  7. #7
    Member
    Join Date
    Mar 2001
    Posts
    44
    Hi, thanks for that. i have solved this by using the setTimeout() command which i found out about on live docs (its not in the flash help) does the job as it waits a second to check the number of frames.

    http://livedocs.macromedia.com/flash...=00001717.html

    Thanks for all your help!
    Neil
    slammin

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