SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2002
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    test to see if a jpg is loaded in flash mx?

    hey there.

    i know it's possible to check how much of a loaded swf is loaded, but how would i do the same thing with a jpg? (i've not done it with a swf, but i know it is possible)

    any suggestions?

  2. #2
    SitePoint Enthusiast B00MER's Avatar
    Join Date
    Mar 2002
    Location
    Ft. Worth, Tx.
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    using loadMovie, loadMovieNum, or loadVariables, loadVariablesNum you can use onData.

    Code:
    myMovieClip.onData = function () {
    trace (myMovieClip.getBytesLoaded());
    };


    hth.

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BOOMEr did you test that? In my experience MX has a hard time applying the onData handler to loaded jpgs. I cannot get it to work.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Enthusiast B00MER's Avatar
    Join Date
    Mar 2002
    Location
    Ft. Worth, Tx.
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    MovieClip.prototype.loadjpg = function(picName) {
            this.createEmptyMovieClip("holder", 1);
            this.holder.loadMovie(picName);
            this.activateChecking();
    }
    
    MovieClip.prototype.activateChecking = function () {
            this.onEnterFrame = function() {
                    if (this.holder.getBytesLoaded() > 1 && this.holder.getBytesLoaded() >= this.holder.getBytesTotal()) {
                            this.stopChecking();
                            this.onComplete();
               }
            }
    }
    
    MovieClip.prototype.stopChecking = function() {
            this.onEnterFrame = null;
    }
    
    // function to execute when loading is done
    function rotateMe() {
    	// this is whatever you want to have happen
    	// on load (could be just play(), eg)
            loadTarget.onEnterFrame = function() {
                    this._rotation += 5;
            }
    }
    
    // only need this if creating from scratch
    this.createEmptyMovieClip("loadTarget", 1);
    loadTarget.onComplete = rotateMe;
    loadTarget.loadjpg("pic.jpg");

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that works, but come on, don't you feel like macromedia should fix the onData event handler to recognize loaded jpgs? I sure do
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    SitePoint Enthusiast B00MER's Avatar
    Join Date
    Mar 2002
    Location
    Ft. Worth, Tx.
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wasn't aware of the problem until I started testing myself. Sorry for the mis-information. Btw, that prototypes aren't mine they are helen triolos of http://actionscript-toolbox.com/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •