Creating a Trace Bar to Track SWF Loading Progress

  • Thread starter Thread starter sid_galt
  • Start date Start date
  • Tags Tags
    Trace Track
Click For Summary

Discussion Overview

The discussion revolves around creating a trace bar to track the loading progress of SWF files in Flash. Participants explore various methods for implementing preloaders, address issues related to loading external data, and troubleshoot problems with Flash content not displaying correctly across different systems and browsers.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • Some participants suggest using the ProgressBar component or custom code with getBytesLoaded() and getBytesTotal() to display loading progress.
  • One participant inquires about starting the SWF file before it has fully loaded, particularly for a photo reel with music.
  • Another participant questions the necessity of preloader bars if frames can play as they load, expressing confusion about their purpose.
  • Concerns are raised about external data not loading for European countries when the SWF is accessed from a server, despite working locally.
  • Participants discuss issues with Flash content not loading on certain computers, noting differences in behavior between browsers and operating systems.
  • One participant mentions that the Shockwave player is attempting to load the movie instead of the Flash player, suggesting a possible format issue.
  • Technical details about HTML coding for embedding SWF files are shared, with comparisons between different object and embed tags that work or do not work in Internet Explorer.

Areas of Agreement / Disagreement

Participants express a mix of agreement and disagreement regarding the functionality and necessity of preloaders, as well as the technical challenges faced with loading content across different environments. The discussion remains unresolved on several technical issues, particularly regarding the loading of external data and compatibility across browsers.

Contextual Notes

Participants mention various limitations, including potential restrictions on loading data from different servers, browser compatibility issues, and the performance of Flash Player on different operating systems. Specific details about the setup and configurations of the SWF files and their hosting environments are also noted as relevant to the problems discussed.

sid_galt
Messages
503
Reaction score
1
How do you display a trace bar which shows how much of the swf has loaded ?

Thank you
 
Computer science news on Phys.org
It's pretty easy. You can use the ProgressBar component, or you can make your own. Use getBytesLoaded() and getBytesTotal().
For example to see how much of the current swf has loaded, do:
Code:
_root.onEnterFrame = function(){
   p = 100*_root.getBytesLoaded()/_root.getBytesTotal();
   _root.mytext.text = p+"% loaded";
   if(p>=100){
        // finished, do something, like go to frame 5
        delete _root.onEnterFrame;
        _root.gotoAndPlay(5);
   }
}

To see how much of an SWF, THAT YOU"RE LOADING ON ANOTHER LEVEL, SUCH AS _level0, then:
Code:
_root.onEnterFrame = function(){
   p = 100*_level0.getBytesLoaded()/_level0.getBytesTotal();
   _root.mytext.text = p+"% loaded";
   if(p>=100){
        // finished, do something, like go to frame 5
        delete _level0.onEnterFrame;
        _level0.gotoAndPlay(5);
   }
}
Where _root.mytext is a dynamic text field. This tells the user how much is loaded. As you can imagine it's easy to do some visual effects, like increment a bar.

With the ProgressBar Component, all you need is to drag an instance of the component onto the stage, select it, and in its actions type:
Code:
on(load){
	this.mode = "manual";
	this.indeterminate = false;
	this.minimum = 0;
	this.maximum = 100;
	this.onEnterFrame = function(){
		this.setProgress(_root.getBytesLoaded(), _root.getBytesTotal());
	}
}
on(complete){
	delete this.onEnterFrame;
	trace("complete");
}
 
Thank you for the replies.

BTW, is there any way to start the swf file before it has loaded fully (mine is basically a photo reel with music so its a bit hard to compartmentalize it into different files)
 
As long as a frame has loaded it can play, even if the whole movie has not. This is automatic if you don't have a stop() action in the first frame. On the other hand you can check if a frame has loaded, if it has you can play it, otherwise wait.
 
Thank you for the reply.
If the the swf file loads frame by frame, then what is the need of preloader bars in flash movies?I have a couple of other problems.

1) I have made an interactive tutorial in Flash which loads text externally from a file. It contains the statistics on countries around the world. The problem is that no data is appearing for the European countries if the web page is loaded from a server even though data is coming for the other countries. The method is the same in both cases.
Another problem is that the tutorial coding is not working at all on some computers (although it is worthwhile to note that these computers also freeze frequently or are otherwise very slow) while it is working on computers which have even lower configuration than the above computers.
The tutorial is in Flash 8. All the computers have Flash player 8.

2) My flash intro is loading in a few computers but is not loading in the same computers mentioned above. The computers just show a sign of Macromedia Flash Player and that's it.

Again Thanks a lot for the help
 
The point of preloader movies is to let the user know that things are happening. Without a loading bar you might get a blank screen while the first frames are loaded. Also most of the components you use in Flash are set to export on frame 1, this means that frame 1 sometimes is the heaviest frame and so, while it is loading, the user has no idea what is going on with the movie.

The problem is that no data is appearing for the European countries if the web page is loaded from a server even though data is coming for the other countries. The method is the same in both cases.
You have to be more specific. Is the text file in the same server as the .swf? Or from an external domain? Is data for each country loaded from the same text file, or from different ones? Is this your own server or a web host? There are some restrictions about loading data from other servers, it's not allowed unless you specifically set the site's domain as allowed.

My flash intro is loading in a few computers but is not loading in the same computers mentioned above. The computers just show a sign of Macromedia Flash Player and that's it.

What operating System and browser? Flash player is not the same for all browsers and OSs. Mac OSs have really poor flash players and there are often some browser incompatibilities. Are you sure the movie is downloading? Check you Temporary Internet Files to see if your .swf is there. Have you ruled out security settings as the cause of this?
 
Last edited:
-Job- said:
The point of preloader movies is to let the user know that things are happening. Without a loading bar you might get a blank screen while the first frames are loaded. Also most of the components you use in Flash are set to export on frame 1, this means that frame 1 sometimes is the heaviest frame and so, while it is loading, the user has no idea what is going on with the movie.

So that means that I should set the preloader bar to play the swf file when say the first few seconds of file has loaded?

-Job- said:
You have to be more specific. Is the text file in the same server as the .swf? Or from an external domain?
Same Server

-Job- said:
Is data for each country loaded from the same text file, or from different ones?
Different files for each country

-Job- said:
Is this your own server or a web host? There are some restrictions about loading data from other servers, it's not allowed unless you specifically set the site's domain as allowed.
It's a web host. The problem is that most other countries outside of Europe are loading. Although, I have just discovered that a few countries like China are not loading either.
I have set pictures to appear dynamically along with the text too. Pictures are no problem. Only the text is.


-Job- said:
What operating System and browser?
Now that I am checking again, the problem is coming with Internet Explorer browsers which have Flash Player 8 installed.
The page loads and instead of the intro the logo of macromedia shockwave player appears for a while and then that too goes. As if the shockwave can't load the file. With Flash Player 7 in Internet Explorer, there was no problem. This problem is not there for Firefox nor for Opera.

The movie is not downloading. It's not there in the temporary internet files.

-Job- said:
Have you ruled out security settings as the cause of this?
No, but since Firefox and Opera are opening everything, I can't see how that could be the reason.
 
Another problem is that it is the shockwave player which is attempting to load the movie not the flash player. In mozilla firefox and opera, it is the flash player and the movie loads perfectly. Should put the movie in another format or something?
 
  • #10
This is the coding in the html file that is now not running even from my home computer on IE
Code:
<object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,0,0" width="550" height="400">
    <param name="src" value="intro7.swf" />
    <embed src="intro7.swf" pluginspage="[PLAIN]http://www.macromedia.com/shockwave/download/"[/PLAIN]  width="550" height="400"></embed>
  </object>

This is the coding which is running on IE atleast from my home computer
Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="intro7" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="intro7.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="intro7.swf" quality="high" bgcolor="#000000" width="550" height="400" name="intro7" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

I think the first one is directing IE to the wrong codebase. Could this be the problem?
 
Last edited by a moderator:
  • #11
Allright, the loading from external txt files problem is now resolved. Turns out that although my school administrator (they are the one's who are running the site) uploaded all the files, some files were apparently left out. So that's resolved.

The only problem left is that the text files are not loading on some computers. Their configs are like 2.8 GHz P4, 768 MB Ram (freezes frequently), Windows XP and 2.8 GHz P4, 512 Ram (freezes frequently), Very Slow and AMD Sempron 2200 128 Ram, Windows XP (extremely slow).
 
  • #12
Are you 100% sure these PCs have flash 8? If you right click on the movie do you see, in the bottom entry in the menu "About Macromedia Flash Player 8..."?
Can you view other flash 8 movies, from other sites, correctly, or is it that they can't view anything at all?
 
  • #13
-Job- said:
Are you 100% sure these PCs have flash 8? If you right click on the movie do you see, in the bottom entry in the menu "About Macromedia Flash Player 8..."?
The computers all have Flash 8. However when the intro is viewed in IE, on right clicking, instead of "About Macromedia Flash Player 8", there is "About Shockwave Player". That is what made me think that there might be a problem in the way the swf file was being called into the html file.

-Job- said:
Can you view other flash 8 movies, from other sites, correctly, or is it that they can't view anything at all?

Yes, they can. The problem is only with my intro movie.

One more query: My intro movie is 1.34 MB but starts playing only when the first 800 kilobytes have been downloaded. Is there a way to start the movie when say only the first 400 kilobytes have been downloaded? (say by using the bytesLoaded function and instructing the player to play from frame 2 when the first 400,000 bytes are loaded)
 
  • #14
Allright, Everything is working now. :smile: The swf problem was as I suspected, a problem in the html coding.
And the files in the flash tutorial were not opening because the server is linux based and therefore case-sensitive. I hadn't respected case sensitivity in the naming of some txt files.

Thanks for the help everyone especially -Job-!
 
Last edited:
  • #15
So it was the HTML. Did you have Flash 8 generate the HTML via "Publish"?
 
  • #16
-Job- said:
So it was the HTML. Did you have Flash 8 generate the HTML via "Publish"?

The HTML file which worked was generated via flash with "Publish". The one that didn't work was created through Dreamweaver.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
935
Replies
7
Views
2K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K