A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: When a picture is loaded?

  1. #1
    Member
    Join Date
    Apr 2002
    Posts
    76

    Unhappy

    Hi Flash World;

    I'm trying to do one simple thing... I'm trying to load a picture and when this it's loaded I want to mask that loaded picture.

    When I load the picture... for instance pressing a button and the next sentence is loaded_movie_image.setMask(myMask) it doesn't work... but if I create this button to load and another button to mask ... it works properly. I think the error is that if I write both sentences together the computer goes to the second and the picture isn't loaded yet. So... this is my question.... is it possible to know when a picture is loaded? or is it my error?

    Thank you very much!!!

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    yeps,

    you can build a preloader wich checks it , it works something like this ..


    loadMovie("movie.swf","container",1) // load the movie inside container (a mc on stage)

    first get the totalbytes of the movie:

    total = container.getBytesTotal()

    and then check in a loop( frameloop or onenterframe) how much is loaded and to be loaded :

    loaded = container.getBytesLoaded()
    if(loaded>=total) gotoFinish()

    You could check out the movies section for a preloader

    succes Nyls



  3. #3
    Member
    Join Date
    Apr 2002
    Posts
    76

    thank you!!!

    Hi again,

    Thank you very much for your quick answer and the last thing... you said something about preloaders in movies section.... but what's the sub section because I'm not able to see it :-)

  4. #4
    Member
    Join Date
    Apr 2002
    Posts
    76

    I've seen it....

    I've seen it.... ok.... so thank you

  5. #5
    Junior Member
    Join Date
    Mar 2001
    Posts
    5
    Originally posted by nyls
    yeps,

    you can build a preloader wich checks it , it works something like this ..


    loadMovie("movie.swf","container",1) // load the movie inside container (a mc on stage)

    first get the totalbytes of the movie:

    total = container.getBytesTotal()

    and then check in a loop( frameloop or onenterframe) how much is loaded and to be loaded :

    loaded = container.getBytesLoaded()
    if(loaded>=total) gotoFinish()

    You could check out the movies section for a preloader

    succes Nyls


    Don't forget to also go to finish if getBytesTotal() eq -1
    In that case the file isn't there...stolen, wrong name etc.


  6. #6
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    myImageHolder = new MovieClip();
    myImageHolder.loadMovie("image.jpg");
    myImageHolder.onData = whatever.... //loading has started
    myImageHolder.onLoad = whatever.... //loading has finished


  7. #7
    Junior Member
    Join Date
    Mar 2001
    Posts
    5
    Originally posted by dave toland.com
    myImageHolder = new MovieClip();
    myImageHolder.loadMovie("image.jpg");
    myImageHolder.onData = whatever.... //loading has started
    myImageHolder.onLoad = whatever.... //loading has finished

    you're right, what am i doing in the mx forum..?

  8. #8
    Member
    Join Date
    Apr 2002
    Posts
    76

    it doesn't work!!!

    Hi again... I'm fighting with it... but I'm not able to know when a picture is loaded and when it isn't...

    Please.... could someone send me an easy and short example of this working properly?

    Please I needed desperately!!!

  9. #9
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    Originally posted by dave toland.com
    myImageHolder = new MovieClip();
    myImageHolder.loadMovie("image.jpg");
    myImageHolder.onData = whatever.... //loading has started
    myImageHolder.onLoad = whatever.... //loading has finished

    did you try that??

  10. #10
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    I,ve tried getting that to work but nut succeeded .
    I,ve been having the problem that when I load a picture inside a movieclip the methods not seem to work .. so I loaded it inside a container and It worked ..

    I think I,m doing something wrong .. so any help would be appreciated .. underneath is my code wich works .. but I rather use the new Movieclip() .... but for me it seems that when there is not really a real "movieclip" invalved I can't get it to work for example:
    Code:
    myImageHolder = new MovieClip(); 
    myImageHolder.onEnterFrame = function() {trace("test")}
    does nothing !! but the
    following does
    Code:
    this.createEmptyMovieClip("container",1);
    this.container.loadMovie("receptie.jpg"); 
    this.init = false;
    this.onEnterFrame = function(){
    	this.loadedBytes = this.container.getBytesLoaded();
    	
    	if (this.loadedBytes>0) {
    		if (!this.init) {
    			this.totalBytes =  this.container.getBytesTotal()
    			this.init=true
    		}
    		this.percentage=Math.floor(this.loadedBytes/this.totalBytes*100);
     		if(this.percentage==100) {
    this.onEnterFrame = null;
    this.finished()}
    	} 
      	else {
    		this.percentage=0
    	}
     }
    this.finished = function(){}
    If anyone could shine some light I would be thankfull..

    Nyls



  11. #11
    Member
    Join Date
    Apr 2002
    Posts
    76
    Yes I tried this way... about onData and so on... but it doesn't work.... post or send me an example, please!!! I'm going mad!!! :-)

  12. #12
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    You have to read and look !! I posted an example !!!
    Code:
    this.createEmptyMovieClip("container",1);
    this.container.loadMovie("receptie.jpg"); 
    this.init = false;
    this.onEnterFrame = function(){
    	this.loadedBytes = this.container.getBytesLoaded();
    	
    	if (this.loadedBytes>0) {
    		if (!this.init) {
    			this.totalBytes =  this.container.getBytesTotal()
    			this.init=true
    		}
    		this.percentage=Math.floor(this.loadedBytes/this.totalBytes*100);
     		if(this.percentage==100) {
          this.onEnterFrame = null;
          this.finished()
        }
      } 
      else {
    	  this.percentage=0
    	}
    }
    
    this.finished = function(){ }

  13. #13
    have a look here:

    its like the webcam viewer for webcam32, sitecam or coolcam works. but you have to remove the unload movie and set up an array inst of loading the same pic!

    http://board.flashkit.com/board/show...7&pagenumber=3

    cheers
    http://www.symbionts.de

  14. #14
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    ok, heres a well easy way.

    drag an instance of the UI2 component 'FProgressBar' onto the stage and call it 'myBar', create an empty movie clip called myHolder:

    myHolder.loadMovie("http://www.chapter3.net/imgs/hori/wjdg_01.jpg", 1);
    myBar.setLoadTarget(myHolder);
    [Edited by dave toland.com on 06-12-2002 at 09:51 AM]

  15. #15
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    Originally posted by dave toland.com
    ok, heres a well easy way.

    drag an instance of the UI2 component 'FProgreeBar' onto the stage and call it 'myBar', create an empty movie clip called myHolder:

    myHolder.loadMovie("http://www.chapter3.net/imgs/hori/wjdg_01.jpg", 1);
    myBar.setLoadTarget(myHolder);
    dear Dave,

    You know why this is not working (seeing my post above ??)

    myImageHolder = new MovieClip();
    myImageHolder.onEnterFrame = function() {trace("test")}

    and this is:

    myImageHolder = createEmptyMovieClip("container",1);
    myImageHolder.onEnterFrame = function() {trace("test")}

    thnx in advange ..

    Nyls



  16. #16
    Senior Member
    Join Date
    Jun 2002
    Posts
    145
    myImageHolder = createEmptyMovieClip("container",1);
    myImageHolder.onEnterFrame = function() {trace("test")}



    what you are doing here is creating a function called 'onEnterFrame'.

    you need to call it.

    onEnterFrame();

    what exactly are you trying to do anyway? if you want to display a preloader for the image you are loading use the example i have just posted above

  17. #17
    Senior Member
    Join Date
    Jan 2001
    Posts
    221
    no problems with anything .. just trying to figure stuff out ..

    when I paste this in FlashMX.. it's tracing non stop ..

    Code:
    myImageHolder = createEmptyMovieClip("container",1); 
    myImageHolder.onEnterFrame = function() {trace("test")}
    what I don't understand is why

    Code:
    myImageHolder = new MovieClip()
    myImageHolder.onEnterFrame = function() {trace("test")}
    isn't doing the same thing ??

    Because I thought that both createMC and new MC are to instantiate Movieclips ..

    Nyls

    ps I've done a new post with this Question, no need to bug the other guys who posted here ..

  18. #18
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I know this works:
    Code:
    //function to preload one slide
    function loadSlide (slide) {
           _root.slideHolder.loadMovie(slide);
          _root.createEmptyMovieClip("loader", 1);
       _root.loader.onEnterFrame = function() {
      var loadedBytes = _root.slide.getBytesLoaded();
      var totalBytes = _root.slide.getBytesTotal();
      if (loadedBytes == totalBytes) {
      this.removeMovieClip();
        }
      }
    }
    
    //function to preload a series of slides
    function loadAll(firstSlide,lastSlide,slideName,introSlide) {
         i = firstSlide;
         while (i <= lastSlide) {
                _root.loadSlide(slideName + i + ".jpg");
                _root.loadSlide(introSlide);
                i++;
            }
    }
    You can see it working:
    http://geocities.com/cooldood47_2000...lide_show.html

  19. #19
    Member
    Join Date
    Apr 2002
    Posts
    76

    THANK YOU!!!!

    Thank you to everyone!!! Finally mixing something from your code and knowing what I wanted to do I've been able to do it.... thank you and a million more thankx because I thought I was going by a wrong way but now it's done.


  20. #20
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    thecrow556,

    let us know!!!!

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