dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: how do you check to see if a dynamically loaded jpg is finished loading?

Hybrid View

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Posts
    316

    Post

    hey everyone,
    basically, i want to change a few properties, such as position and size of my dynamically loaded jpg. but supposodly i cant change these properties unless the jpg is fully loaded, this makes sense.
    i have a blank movie clip called 'forGpic' (for gallery pic) and i do a loadMovie("pic/pic1.jpg",forGpic);
    now, that works fine, but if i try and do a forGpic._width = 10; or something like that, it wont work.
    how do i check and wait for the jpg to load? maybe is there another way that i should load the jpg? or a on(success) or something?
    i did a trace(forGpic.getBytesLoaded+" of "+forGpic.getTotalBytes) and in my output window i get the perfect output, but how would i write the code after the loadMovie function so that it keeps cheking the the bytes loaded == total bytes until they equal and then it sets my properties?
    any replys are greatly appreciated. thanks in advance.

  2. #2
    Place an onData event handler into the forGpic MC

    onData = function()
    {
    //place all your changes that you want done to the MC here
    forGpic._width = 10;

    }

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Posts
    316
    i thought onData was used for XML data??
    http://www.macromedia.com/support/fl...pt_dictionary/

  4. #4
    MX also supports this in MCs look

    you can find this in the MX local referance:

    myMovieClip.onData = function () {
    trace ("onData called");
    };

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Posts
    316
    well, ill have to try this when i get home. i hope that works, it will solve many of my problems haha. thank you for the help.

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Posts
    316
    well, it doesnt seem to work, it just adds the picture like its supposed to, without changing the alpha property. here is my code:
    Code:
    function forGallery(param){
    	argumentArray = new Array;
    	argumentArray = param.split(",");
    	loadMovie("pics/"+argumentArray[0]+"/"+argumentArray[1]+".jpg", forGpic);
    	forGpic.onData = function(){
    		forGpic._alpha = 70;
    	}
    }
    i call the function through an asfunction url link from my text box.. that works i know cause the picture does show up, my alpha effect just doesnt happen.
    any ideas? Thanks in advance.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Location
    Hong Kong
    Posts
    171
    If you add an "on" function using ActionScript to forGpic before loadMovie, then it seems to be wiped out by loadMovie. Presumably as you are replacing the MC it replaces functions as well.

    Code:
    this.attachMovie("PictureHolder", "Pic1", 1); // using library linkage
    Pic1.onRollOver = function() {
    	trace("hello");
    }; // this works if you don't do the next line
    loadMovie("c:/temp/cat22.jpg", Pic1);
    // after this, the onRollOver doesn't work
    But, it works fine if you simply use the onClipEvent (Data) inside the forGpic MC:

    Code:
    onClipEvent (data) {
        this._alpha = 78;
    }
    but I don't understand why I can't make it work when you set the event function programmatically.

  8. #8
    Senior Member
    Join Date
    Nov 2000
    Posts
    316
    oh jeeze... actually, i think i screwed up... that function is supposed to go on the movieclip isnt it?? maybe ill try moving the function there instead of my actions layer... = / sorry.. if that doesnt work ill try a this.onData and then the onMovieClip(data). thanks... ill post later today.

  9. #9
    Senior Member
    Join Date
    Nov 2000
    Posts
    316
    excellent!!! here is my code... it works great... thanks everyone:
    Code:
    onClipEvent(data){
    	this._alpha = 70;
    	this._width = 384;
    	this._height = 288;
    }
    i had also posted in a thread about corrupted jpgs in my movie... seems liek they arent corrupted anymore.. haha.. well, im pretty happy, yet again FlashKit is the best community. thanks again!

  10. #10
    you can use a similar code as a webcam viewer

    i posted it b4 here

    http://board.flashkit.com/board/show...hreadid=301557

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