dcsimg
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: help loading jpeg onto level

  1. #1

    help loading jpeg onto level

    Hi there,
    I am loading a background pic into my movie. I have this so far:

    loadMovieNum("url of pic", 9);

    However, I want to be able to load this picture below all the layers of the movie as I want them to show up; right now it loads on top of everything. Also, I would like the movie to not progress until this picture is loaded.
    I need a way to check if the picture is loaded, and when it is, go and play through the movie. Any ideas?

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    So why not include it in the movie from the start?

    Otherwise you would use a empty movieclip placed on the stage just for the purpose of loading a swf or jpg file into it. The advantage is that you can place it anywhere, manually ( as opposed to swf's in _levels) and also can control what of the objects should be on top or beneath.

    Usually you give the movieclip an instance name of container. ( you give a instance name by selecting the empty movieclip on stage and write the name in the Property Panel )

    //To load a external jpg into a target movieclip from a button ( both being on the main timeline ).

    on(release){
    container.loadMovie("myImage.jpg");
    }

    The external jpg's top left corner will place it self where the empty movieclip is.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Thanks for the reply. Right now I have it loaded in the "container" movieclip; and its underneath all the layers so that solves one of my problems. However, the picture loads way after my movie has started; I want the picture to load before playing the movie. How can I do this?

  4. #4
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Try this ....

    Make a stop action in the timeline and put this code ON the movieclip.

    onClipEvent (enterFrame) {
    tb = math.round(this.getBytesTotal()/1024);
    lb = math.round(this.getBytesLoaded()/1024);
    if (lb>=tb && lb > 2 && once!=1) {
    _parent.play();
    once=1;
    }
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  5. #5
    I did that, but right it now the movie stops until the bg is loaded, but the movie never starts up again. Just to clarify the code:

    In frame 1 of the main timeline I have:
    container.loadMovie("pic.jpg");
    stop();

    The movie clip "container" has the following code:
    onClipEvent (enterFrame) {
    tb = math.round(this.getBytesTotal()/1024);
    lb = math.round(this.getBytesLoaded()/1024);
    if (lb>=tb && lb > 2 && once!=1) {
    _parent.play();
    once=1;
    }
    }

    I don't think the MC code is working. See any reason why this wouldn't work?

  6. #6
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    It works here though. ( it wont if the image is less than 2 kb ).
    What does the output window say if you add ....


    trace(tb);

    ..right under the onClipEvent line.

    The code should be placed ON the movieclip ( not inside ). Select movieclip and then paste the code in the actionscript window.

    Do you use MX2004?

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  7. #7
    Ya I use MX 2004. I put the trace in and it comes out as 349.

  8. #8
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    MX2004 may need a declaration of the once var . Try this...

    onClipEvent (load) {
    once=0;
    }
    onClipEvent (enterFrame) {
    tb = math.round(this.getBytesTotal()/1024);
    lb = math.round(this.getBytesLoaded()/1024);
    if (lb>=tb && lb > 2 && once!=1) {
    _parent.play();
    once=1;
    }
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  9. #9
    Tried that too. Same thing happens. What does the 'once' variable do anyways? Sorry for the hassle with this problem.

  10. #10
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    The "once" variable ensures that the gotoAndPlay action only happens once, as it is withina onEnterFrame handler which will execute on every frame otherwise. You can take it away and see what happens...

    onClipEvent (enterFrame) {
    tb = math.round(this.getBytesTotal()/1024);
    lb = math.round(this.getBytesLoaded()/1024);
    if (lb>=tb && lb > 2 ) {
    _parent.play();
    }
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  11. #11
    Still no good. It seems we're running out of solutions here...

  12. #12
    Is this the end???

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