Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Loading swf

  1. Mar 17, 2006 #1
    How do you display a trace bar which shows how much of the swf has loaded ?

    Thank you
  2. jcsd
  3. Mar 17, 2006 #2


    User Avatar
    Homework Helper

  4. Mar 17, 2006 #3


    User Avatar
    Science Advisor

    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 (Text):
    _root.onEnterFrame = function(){
       p = 100*_root.getBytesLoaded()/_root.getBytesTotal();
       _root.mytext.text = p+"% loaded";
            // finished, do something, like go to frame 5
            delete _root.onEnterFrame;
    To see how much of an SWF, THAT YOU"RE LOADING ON ANOTHER LEVEL, SUCH AS _level0, then:
    Code (Text):
    _root.onEnterFrame = function(){
       p = 100*_level0.getBytesLoaded()/_level0.getBytesTotal();
       _root.mytext.text = p+"% loaded";
            // finished, do something, like go to frame 5
            delete _level0.onEnterFrame;
    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 (Text):
        this.mode = "manual";
        this.indeterminate = false;
        this.minimum = 0;
        this.maximum = 100;
        this.onEnterFrame = function(){
            this.setProgress(_root.getBytesLoaded(), _root.getBytesTotal());
        delete this.onEnterFrame;
  5. Mar 18, 2006 #4
    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)
  6. Mar 18, 2006 #5


    User Avatar
    Science Advisor

    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.
  7. Mar 18, 2006 #6
    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 alot for the help
  8. Mar 18, 2006 #7


    User Avatar
    Science Advisor

    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.

    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.

    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: Mar 18, 2006
  9. Mar 19, 2006 #8
    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?

    Same Server

    Different files for each country

    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.

    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.

    No, but since Firefox and Opera are opening everything, I can't see how that could be the reason.
  10. Mar 19, 2006 #9
    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?
  11. Mar 19, 2006 #10
    This is the coding in the html file that is now not running even from my home computer on IE
    Code (Text):

    <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="http://www.macromedia.com/shockwave/download/" width="550" height="400"></embed>
    This is the coding which is running on IE atleast from my home computer
    Code (Text):

    <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" />
    I think the first one is directing IE to the wrong codebase. Could this be the problem?
  12. Mar 19, 2006 #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).
  13. Mar 19, 2006 #12


    User Avatar
    Science Advisor

    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?
  14. Mar 19, 2006 #13
    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.

    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)
  15. Mar 20, 2006 #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: Mar 20, 2006
  16. Mar 20, 2006 #15


    User Avatar
    Science Advisor

    So it was the HTML. Did you have Flash 8 generate the HTML via "Publish"?
  17. Mar 21, 2006 #16
    The HTML file which worked was generated via flash with "Publish". The one that didn't work was created through Dreamweaver.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Loading swf
  1. Loading a File in C++ (Replies: 15)

  2. Computer wont load XP (Replies: 44)

  3. XBL game Load failed (Replies: 0)