A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Problems with loadMovie function

Hybrid View

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    129

    Problems with loadMovie function

    Hello,

    When a user clicks a button on my website, I want a movieclip to appear (graphically designed as a popup window) and inside this "popup" I'd like an external .swf file to be loaded inside it. It contains a large file (a song) so I'd like to do it this way instead of giving my site a huge loading time.

    Here's the code I've got on the button:

    Code:
    on (release) {
    	setProperty(_root.pages.hmhsong, _visible, "1");
    	loadMovie("holdmehostage.swf", this._parent.hmhsong.hmhsong2);	
    }
    "hmhsong" is the popup MC and "hmhsong2" is the empty movieclip that will, of course, hold the external file.

    Just in case you need to know, here's the code in the external .swf file (this code is placed on a MC on the stage:

    Code:
    onClipEvent (load) {
    	total = _root.getBytesTotal();
    }
    onClipEvent (enterFrame) {
    	loaded = _root.getBytesLoaded();
    	percent = int(loaded/total*100);
    	txt = "Loading song "+percent+"%";
    	//trace(percent)
    	this.gotoAndStop(percent);
    	if (loaded == total and total>380 and a<> 1) {
    		a=1;
    		_root.gotoAndPlay("s7");
    	}
    }
    The problem that I'm having is that nothing happens when the button is clicked. "hmhsong" (the popup MC) doesn't become visible (whereas my coding clearly states it should!) and the song doesn't play. I'm getting nothing!

    Can anyone tell me where I've gone wrong?

    Thanks.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Here is one mistake:
    this._parent.pages.hmhsong.hmhsong2

    I don't know why you put the onLoad code into the movie, because it would not do anything.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Quote Originally Posted by cancerinform
    Here is one mistake:
    this._parent.pages.hmhsong.hmhsong2

    I don't know why you put the onLoad code into the movie, because it would not do anything.
    That's the correct path to the MC, how is that a mistake?

    Also, that onLoad code is in the external SWF file, as stated. How is it not doing anything?

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok, I understand your movie now, worked for me. On mouse click the movieclip became visible.

    You should change your habits and not associate code with any movieclips or buttons but place all scripts in a frame on the main timeline. That makes debugging easier for you and others.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Hmm yes, the popup does seem to be visible now. I don't know why that might have happened before.

    However, the external .swf is still not being played within it.
    Here's something peculiar: If I change loadMovie to loadMovieNum I can see the external .swf inside the popup now, but it's stuck on the first frame and doesn't play.

    I shouldn't really use loadMovieNum anyway, should I? I understand it's for global use, not for within a MC.

    Does this help anyone understand what I should do?

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Use this preloader component instead of the preloader script you have in the child movie:

    http://www.flashscript.biz/component...preloader.html
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Thanks, that's a much more efficient and nicer-looking preloader!

    Sadly, I still have a problem. And I've investigated a little further into the matter.

    This time I was patient enough to wait 4 minutes for the child movie to load, and once it's loaded, it does actually play, I can see it and hear it. The odd thing is that, even with the new preloader you gave me, the preloading is invisible! This is a bit of a pain because it takes ages to load and people will probably have closed it before they bothered waiting :P

    Any ideas on this? Seems really strange to me.

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    What is the filesize of your movie? If you have a large audio file, it is no wonder. You should do streaming instead.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    It is, in fact, an audio file inside the child .swf. I can't have it as an mp3 on the server because it needs to be secure.

    But surely the preloader should still be visible, despite the large file size?

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The preloader should be visible and I have not experienced that it was not. Do you have a stop() in that frame, where the preloader is?
    - The right of the People to create Flash movies shall not be infringed. -

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