Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problem With _totalframes



Hi I'm having a nasty problem with this actionscript thing. I'm loading an external mc into this empty movieclip:


Code:
this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth());
logo_mc.createEmptyMovieClip("container_mc",0);
logo_mc.container_mc.loadMovie("load.swf");
This works perfectly, the swf is loaded and all the content is displayed correctly. But now I want to get the totalframes of this movieclip (I know there are 8 frames in the movie, but it should detect this automatically)

Do do this I tried this code:


Code:
trace(this.logo_mc.container_mc._totalframes);
Now Flash returns 1, while it should return 8. I know the path is correct, otherwise Flash should return undefined.
What am I doing wrong?

Thanks in advance,
Tijs



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 09-29-2004, 06:19 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

_totalFrames
Hey guys and gals

Is it possible to return the value of the total frames within a scene?

I know you can do it for the total movie but i need to do it by scene.

Any ideas?

Steve

_totalframes Of An External Swf
Hello,

I'm doing this:

loadMovie("intro.swf");

into a MC whose instance name is "holder". That seems to be working fine. But what I want to do now is set variable to however many frames are in "intro.swf". It seems that I would do something like:

the_count = _root.holder.intro._totalframes


...or something. I've tried everything I can think of. Can anyone tell me where I'm going wrong?

Thanks.

_framesloaded >= _totalframes?
_framesloaded >= _totalframes is the condition in the preloader showed by the reference. My question is how can _framesloaded ever be bigger than _totalframes?


And another question: how can I stop animation in a symbol?
I want the clip to play only once during a movie/layer, yet I want to continue to display the symbol at the last keyframe.

Changing _totalframes
Can anyone recommend how to change the "_totalframes" portion in this script to either read a percentage (10%) or a specific frame (60)?

if (_framesloaded>=_totalframes) {
gotoAndPlay (2);
} else {
gotoAndPlay (1);
}

I've tried:

if (_framesloaded>=60) {
gotoAndPlay (2);
} else {
gotoAndPlay (1);
}

if (_framesloaded>=10%) {
gotoAndPlay (2);
} else {
gotoAndPlay (1);
}

But neither way is working.

Thanks!

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");
}

Checking _totalframes ?
hi all, i dont know what's going on but i'm stuck on something really simple:

i want to check if a small tween within an MC has played and perform a function only if its at _totalframes??


ActionScript Code:
var _playing = (nav_devMC.?? < nav_devMC._totalframes)
    if (nav_devMC._playing == nav_devMC._totalframes) {
        //fadeIn();
        trace("nav_devMC loaded "+nav_devMC._totalframes)
}
any thoughts on this much appreciated.

Trying To Get _totalframes Of Several Swf Files
Hello folks,

I have a list of swf files and I need to know the amount of frames of each one of them. I tried the following:

1. I created a xml file called "data.xml" (an example with 5 files - lesson1.swf, lesson2.swf, lesson3.swf, lesson4.swf and lesson5.swf):
<?xml version="1.0" encoding="iso-8859-1" ?>
<course>
<lesson id="1"><name>lesson1</name></lesson>
<lesson id="2"><name>lesson2</name></lesson>
<lesson id="3"><name>lesson3</name></lesson>
<lesson id="4"><name>lesson4</name></lesson>
<lesson id="5"><name>lesson5</name></lesson>
</course>

2. I wrote this script on Flash:

System.useCodepage = true;
var MyXML:XML = new XML();
MyXML.ignoreWhite = true;

MyXML.onLoad = function($sucess){
if($sucess){
for($i=0; $i<MyXML.firstChild.childNodes.length; $i++){
lessonloaded = MyXML.firstChild.childNodes[$i].firstChild.firstChild.nodeValue;
loadMovieNum (lessonloaded + ".swf", 10); // loads lessonn.swf on _level10
_level10.stop();
trace (_level10._totalframes);
unloadMovieNum (10);
}
} else {
trace($sucess);
trace("Error!");
}
}
MyXML.load("data.xml");

The trace (_level10._totalframes) command results in undefined five times. So I tried the onEnterFrame function, believing that after some loops Flash would recognize the amount of frames of the lessonn.swf file loaded on _level10:

for($i=0; $i<MyXML.firstChild.childNodes.length; $i++){
lessonloaded = MyXML.firstChild.childNodes[$i].firstChild.firstChild.nodeValue;
loadMovieNum (lessonloaded + ".swf", 10);
_level10.stop();
onEnterFrame = function(){
if (_level10._totalframes != undefined) {
trace (_level10._totalframes);
unloadMovieNum (10);
delete this.onEnterFrame;
}
}
}

But, onEnterFrame function is invoked just once, after the loading of lesson5.swf. So I get the amount of frames of the last file only.

Now, I'm a little bit lost... I don't know what to do to improve this script, and I'm wondering if there isn't a better way to get the _totalframes of a list of swf files...

Any suggestions will be very appreciated!

Thanks in advance,
Zenho

_totalframes Of External Swf
Is there a way to get the total frames and current frame of an externally loaded swf? The code I am using below does not work. My _root timeline has three objects: two dynamic text boxes and a container clip. Their instance names are myText_text, myText2_text, and loader_mc, respectively. I have two variables, "i" and "j", which populate myText_text.text and myText2_text.text, respectively.

The problem is that the values display "1" because they are getting the value of the container clip and not the movie loaded into the container clip. I need the _totalframes and _currentframe properties of the externally loaded clip, not the container clip. My code below doesn't work. Any ideas?


Code:
_root.loader_mc.loadMovie("loadedclip.swf");
var i = _root.loader_mc._totalframes;
var j = _root.loader_mc._currentframe;
_root.myText2_text.text= j;
_root.myText_text.text = i;
stop();

Can I See _totalframes On A Loaded Swf?
Hey guys!

I have a program where I am supposed to first load a swf in the first frame (i will not know how long that swf is), and when that has finished playing the main program i supposed to move on to the next frame. Now my question is, can I somehow figure out how long that swf is from within my main program or will I have to put a simple _root.gotoAndPlay(2); in the last frame of my loaded swf?

Thanks for looking!
/Joel

Problem With _totalframes
Hi I'm having a nasty problem with this actionscript thing. I'm loading an external mc into this empty movieclip:


Code:
this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth());
logo_mc.createEmptyMovieClip("container_mc",0);
logo_mc.container_mc.loadMovie("load.swf");
This works perfectly, the swf is loaded and all the content is displayed correctly. But now I want to get the totalframes of this movieclip (I know there are 8 frames in the movie, but it should detect this automatically)

Do do this I tried this code:


Code:
trace(this.logo_mc.container_mc._totalframes);
Now Flash returns 1, while it should return 8. I know the path is correct, otherwise Flash should return undefined.
What am I doing wrong?

Thanks in advance,
Tijs

Load NOT _totalframes
This is what we are familier with....

Code:
var loadAmount = _totalframes;
if (_framesloaded == loadAmount) {
gotoAndPlay("ShowTime");
}
but what needs to be if I want to load only 30 frames out of 300 and play the movie?

_totalframes And SWF Problems
Is there a way to get the total No. of frames from an SWF been loaded inside another main SWF ?

I don´t want to put any code inside the loaded one, everything must be handled by the main SWF.

I tried to use _totalframes and a holder movieclip, but it always return
the n. of frames from the holder, not the loaded one.

Is there any sollution to this ?

Thanks !

Getting The _totalframes Of An External SWF
Hi all,

I have a movie loading in a number of external SWF's.

It Gets the total number of SWF's from a PHP script and then.

It needs to load the first SWF and then when it has reached it's end it needs to load the next SWF file.

The catch being that the external SWF's can contain no actionScript!

I have tried this code:

stop();

currentFile = 0;
loadMovieNum( "banners/banner" + currentFile + ".swf", 2);

_global.end = function() {

number_txt.text = currentFile;
loadMovieNum( "banners/banner" + currentFile + ".swf", 2);
myTf = _level2._totalframes;


// myMovie is an empty MC on the stage
myMovie.onEnterFrame = function(){

myCf = myMovie._currentframe;

if (myCf == myTf){
_global.end();
}

}
currentFile = (currentFile + 1 < Number(fileCounter.files)) ? currentFile + 1 : 0;
};

fileCounter = new LoadVars();
fileCounter.onLoad = end;
fileCounter.load("filelist.php"); // gets the number of swf's in directory

I cannot get the totalframes of any of the external SWFs...

Anyone have any ideas?

I'm beat!

Nice one,

Neb

Finding _totalframes For A Scene...?
Does anyone know if it's possible to find the _totalframes or totalbytes for a scene. I know it's available for the entire movie, but what i would like to do is create a percentage bar preloader for each transition into a scene.
It would work something like this...
Scene1 -> Scene2Preloader%Bar -> Scene2 -> Scene3Preloader%Bar -> Scene3 -> etc.
I'm open to any suggestions... thanks!

Why Does _currentframe == _totalframes When I Load An Mc?
Hello everyone

I have an mc that on a clipEvent LoadFrame I have an if statment that compare the _currentframe to the _totalframes. When currentframes == _totalframes I want an action to occure. The action always occures when the mc is loaded. WHy is this????? How can the current frame be at the end. DOes any one know why??

Thank you all in advance.

onClipEvent (enterFrame) {
if ( _currentframe == _totalframes) {
do the following;
}
}

_totalframes On Loaded Movie?
I'm working on an EXE which loads video SWFs into a movie clip called vidScreen. I'm trying to automate my video fade ups and downs using vidScreen._alpha. I've got the fade ups working no problem. However, for the fade downs (at the end of the video clips), I need to calculate "vidScreen._totalframes" (so that I can start and end the fades on the appropriate frames). vidScreen._totalframes returns the number of frames in the original movie clip, however, not the number of frames of the SWF loaded into it. I see that loadMovie has "get" & "post" variable parameters, but that only works with HTML pages, correct? Is there any way to communicate the _totalframes of a loaded SWF to its parent movie clip?

Thanks in advance for any help.

Is There A Way To See How Many Frames Are In A Scene? (not Using _totalframes)
I'm doing some video work up in flash and I have the section broken off into 4 scenes. Everything works fine for a little bit and then it just gets really out of sync progressively.

My problem is that the component that I'm using to control the video uses _totalframes instead of detecting the amount of frames in the current scene. When I test each scene independently the syncing is perfect so I know that it has something to do with the fact that the long video is messing things up.

Does anyone have a quick work around for this as I'm in a pretty tight spot now.

Thanks

_totalframes Problem When Used With MovieClipLoader
Hi there,

I'm having a problem with using _totalframes (and also _currentframe) to control a movieclip that I've loaded using the MovieClipLoader class.

I have a holder mc ("_root.contentClip") that I'm loading a .swf into (in this case, I'm loading "1.swf").

I also have a button with a trace function to determine _totalframes of "contentClip". When I use this button to determine _totalframes of contentClip before loading anything, it works fine, returning a number of "80". However, after loading the .swf, it will only return "1" (even though there are 600 frames in "1.swf")

Incidently, the myMCL.onLoadInit function traces "_level0.contentClip" - I've tried using this filepath to access the movie clip, but it doesn't work either.

Any help would be appreciated.

Source code below:


Code:
stop();

var myMCL = new MovieClipLoader();

myMCL.onLoadProgress = function (targetMC, loadedBytes, totalBytes) {
_root.total = totalBytes;
_root.loaded = loadedBytes;
}

myMCL.onLoadInit = function (targetMC) {
trace ("Movie clip:" + targetMC + " is now initialized");
}

function loadSection (contentNo:Number){
var contentName:String = (contentNo+".swf");
myMCL.loadClip(contentName,"_root.contentClip");
index=contentNo;
}

navigation.section1Button.onRelease = function(){
loadSection(1);
}

testButton.onRelease = function(){
trace(_root.contentClip._totalframes);
}
Thank you to anybody who can help.

_totalframes Doesn't Work In AS 3.0
How do I get _totalframes of a movieclip? I want to go to a random frame based on how many frames there are total.

in AS 2.0 you could do


Code:
gotoAndStop(random(_totalframes)+1);

In AS 3.0 I tried


Code:
var whatFrame:int = Math.random() * _totalframes + 1;
But it gives me an error.

I'm doing this inside a class.

I set the linkage for a movieclip so it looks like...

Class: com.game.BadGuy
Base Class: flash.display.MovieClip

BTW: why do you need a "Base Class" if I'm already extending movieclip in the BadGuy class anyway?

Anyway here's the error I get

1120: Access of undefined property _totalframes.

So how can I get that?

Thanks in advance...

Here's my code from my class in case you want to see the whole thing.


Code:
package com.game
{
import flash.display.MovieClip;
public class BadGuy extends MovieClip
{
public function BadGuy()
{
var whatFrame:int = Math.random() * _totalframes + 1;
gotoAndStop(whatFrame);
trace("I'm here");
}
}
}

_totalframes Count In MC In Library
It is possible to check the number of frames in a movieclip that is in the library or must I use attachMovie(); before I can do it? I would like to be able to not load it before I need it.

Read _totalframes From LoadMovie
Hello,

Ik have a player and a movie both .swf files.
the movie is loaded in the player with loadMovie.

I want to read the _totalframes from the movie and show this in the player with a timeline.

I have it working in the movie but there i have percent shown.
Code from the movie

Code:
var nTotalFrames:Number = this._totalframes;
//frames.text = nTotalFrames;
onEnterFrame = function() {
var loader = Math.round((this._currentframe / this._totalframes)*100);
pecent_txt.text = loader+"%";
}
how can i put this in the player?

Movieclip - _currentframe | _totalframes
Hi!

I have use that code when someone press on a button.
First i start a movieclip - start_hide

I check with if(), if the movieclip has been finished and if it has finished, the visitor will be sent to a fram that is named - tjanster.

NOW

MC - start_hide, starts but i never comes to "tjanster", so i think the if(), it's wrong,

I'm just a beginner so I think I did a "easy" wrong but please help me!


Code:
on(release) { _root.start_hide.gotoAndPlay(1); if(_root.start_hide._currentframe == _root.start_hide._totalframes) { _root.gotoAndPlay('tjanster'); }

_totalframes And _currenframe Undefined
Hi All,

I'm new to Flash (and actionscript) and could really use some help.

I'm trying to read through an array of FLV movies and play each one in sequence in a MediaPlayback component and am using the setInterval function to check when one movie ends (in order to start the next one).

So far, I got the first movie to load and play, but that's where it ends.

I think I have to have a condition in my function that checks for when _totalframes = _currentfarme (when equal, load the next movie).

But before I can do that, I have to be able to see those attributes. When I print them out in my textBox, I get them as undefined.

movieName itself prints out fine, but the frame attributes come out as undefined.

Here's the code:

playMovies = function (){
var movieName = moviesArray [loopcounter];
mediaPlayback.setMedia(movieName , "FLV");
moviesText.text = moviesText.text + " Now Playing: " + movieName + " Total Frames: " + movieName._totalframes + " Frame Loaded: " + movieName._frameloaded + " Current Frame: " + movieName._currentframe;
loopcounter = loopcounter + 1;
clearInterval (timer);
}
timer = setInterval (playMovies, 50);


Any help on this and/or how to do the condition/loop check after, would be greatly appreciated.

thanks again,
john...


_totalFrames Property Of External Movies?
I´m having problems with _totalFrames.
I´m trying to build a music player using flash. The songs that I´m using for the player are all external .swf´s that load when the user requests it.
I´m trying to build a display that shows the time of the current song(minutes, seconds,etc.) and I´m having problems accessing the _totalFrames property of the loaded movieclip.
I´m able to use trace() to get _totalFrames, but I´m having problems attaching _totalFrames to a variable. I´m loading the external .swf´s into level2 of my movie.

this works and I get a value in the output window:
trace (_level2._totalFrames);

but this doesn´t work
totalFramesOfSong = level2._totalFrames;

Any Ideas? Is this possible?

thanks
S.G

_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:


Quote:




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!

_totalframes Is Larger Than My Number Of Frames
I have an MC with exactly 4 frames showing in the timeline. However, _totalframes reports 16 frames!

I tried selecting (in the Flash 8 Prof. GUI) those "virtual" non-existing frames and deleting them, by selecting a number of frames after my 4th frame (although they already show up empty). HOwever, I seem to be getting even more, yesterday I only had 3 frames more visible, today it's 12...

Is it possible frames once created in the GUI are never deleted? Anyway, how do I get those non-visible (in the GUI) frames deleted?

UPDATE: Just found out when I select "Select all frames" from the timlines context menu those unwanted additional frames are selected, so this way I now CAN see how many there really are. Still, attempting to delete them is unsuccessful!

ANOTHER UPDATE: I just selected all those additional frames in the GUI (first made visible using the above method), and converted them to "real" frames. Now I ended up with even more non-existing and unwanted frames, my timeline now had 80(!!!) frames when I selected "select all frames"!!!





























Edited: 04/30/2007 at 06:19:24 AM by Hasenstein

[F8] LoadMovie Causes Different _totalframes Compared To Same File From Library
Using AS2


If I do

a=r.attachMovie("library.x.swf","a",pile());

then a._totalframes == 222

If I do the same thing but then load a movie after

a=r.attachMovie("library.x.swf","a",pile());
a.loadMovie("x.swf"); //actually the very same file stored locally!

I get

a._totalframes == 4500


What's the deal?

[Dare] Find _totalframes Of SWF Loaded Via LoadClip(): Is It Possible?
Can someone post an example of how one would get _totalframes of a multi-frame swf loaded via MovieClipLoader/loadClip()?

I do not think it is possible. But, then again, I am noob... please prove me wrong.

Copyright © 2005-08 www.BigResource.com, All rights reserved