Help! Dropdown and preloader not working

  • gany9
  • Born
  • Born
  • gany9
  • Posts: 4

Post 3+ Months Ago

Hey there,

I'm almost finished a project and I came across this problem. I have a "master" file that has all the buttons in it in order to call a preloader movie clip for loading an external swf. It works fine with single buttons. However, when I try to code the buttons inside my drop-down movie clip it doesn't call the preloader nor loads the external swf at all. It's like the drop-down movie clip doesn't understand the coding in the master file. Any idea on how to solve this problem?

Here's my code so far:
In the master file's actionscript layer:
Code: [ Select ]
var loader_mcl = new MovieClipLoader();
loader_mcl.addListener(this);
function startPreload(url){
    
    // use loadMovie to load the swf url into container_mc
    loader_mcl.loadClip(url, container_mc);
}
//calling the preloader animation to specific location
function onLoadStart(target){
    attachMovie("preloader anim","preloader_mc",500,{_x:500, _y:500});
}
function onLoadProgress(target, bytes_loaded, bytes_total){
    // stop and hide movie
    target.stop();
    target._visible = false;
    
    // assign value to preloader
    preloader_mc.value = bytes_loaded/bytes_total;
}

// when loading is complete for loader_mcl
function onLoadComplete(target){
    // show and play loaded clip
    target.play();
    target._visible = true;
    
    // remove the preloader animation
    preloader_mc.removeMovieClip();
}

// if there is an error, this event handler will
// be called and the preloader will be removed
function onLoadError(target, error_code){
    preloader_mc.removeMovieClip();
    trace(error_code);
}
  1. var loader_mcl = new MovieClipLoader();
  2. loader_mcl.addListener(this);
  3. function startPreload(url){
  4.     
  5.     // use loadMovie to load the swf url into container_mc
  6.     loader_mcl.loadClip(url, container_mc);
  7. }
  8. //calling the preloader animation to specific location
  9. function onLoadStart(target){
  10.     attachMovie("preloader anim","preloader_mc",500,{_x:500, _y:500});
  11. }
  12. function onLoadProgress(target, bytes_loaded, bytes_total){
  13.     // stop and hide movie
  14.     target.stop();
  15.     target._visible = false;
  16.     
  17.     // assign value to preloader
  18.     preloader_mc.value = bytes_loaded/bytes_total;
  19. }
  20. // when loading is complete for loader_mcl
  21. function onLoadComplete(target){
  22.     // show and play loaded clip
  23.     target.play();
  24.     target._visible = true;
  25.     
  26.     // remove the preloader animation
  27.     preloader_mc.removeMovieClip();
  28. }
  29. // if there is an error, this event handler will
  30. // be called and the preloader will be removed
  31. function onLoadError(target, error_code){
  32.     preloader_mc.removeMovieClip();
  33.     trace(error_code);
  34. }


I tried both these methods for the buttons within the dropdown:
1.) in the master's actionscript
Code: [ Select ]
AppSolMC.btn1.onPress = function() {
    startPreload("ContentBox.swf");
}
  1. AppSolMC.btn1.onPress = function() {
  2.     startPreload("ContentBox.swf");
  3. }

2.) That didn't work so I tried the button itself
Code: [ Select ]
on (press) {
    startPreload("ContentBox.swf");
}
  1. on (press) {
  2.     startPreload("ContentBox.swf");
  3. }
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • gany9
  • Born
  • Born
  • gany9
  • Posts: 4

Post 3+ Months Ago

gany9 wrote:
Hey there,

I'm almost finished a project and I came across this problem. I have a "master" file that has all the buttons in it in order to call a preloader movie clip for loading an external swf. It works fine with single buttons. However, when I try to code the buttons inside my drop-down movie clip it doesn't call the preloader nor loads the external swf at all. It's like the drop-down movie clip doesn't understand the coding in the master file. Any idea on how to solve this problem?

Here's my code so far:
In the master file's actionscript layer:
Code: [ Select ]
var loader_mcl = new MovieClipLoader();
loader_mcl.addListener(this);
function startPreload(url){
    
    // use loadMovie to load the swf url into container_mc
    loader_mcl.loadClip(url, container_mc);
}
//calling the preloader animation to specific location
function onLoadStart(target){
    attachMovie("preloader anim","preloader_mc",500,{_x:500, _y:500});
}
function onLoadProgress(target, bytes_loaded, bytes_total){
    // stop and hide movie
    target.stop();
    target._visible = false;
    
    // assign value to preloader
    preloader_mc.value = bytes_loaded/bytes_total;
}

// when loading is complete for loader_mcl
function onLoadComplete(target){
    // show and play loaded clip
    target.play();
    target._visible = true;
    
    // remove the preloader animation
    preloader_mc.removeMovieClip();
}

// if there is an error, this event handler will
// be called and the preloader will be removed
function onLoadError(target, error_code){
    preloader_mc.removeMovieClip();
    trace(error_code);
}
  1. var loader_mcl = new MovieClipLoader();
  2. loader_mcl.addListener(this);
  3. function startPreload(url){
  4.     
  5.     // use loadMovie to load the swf url into container_mc
  6.     loader_mcl.loadClip(url, container_mc);
  7. }
  8. //calling the preloader animation to specific location
  9. function onLoadStart(target){
  10.     attachMovie("preloader anim","preloader_mc",500,{_x:500, _y:500});
  11. }
  12. function onLoadProgress(target, bytes_loaded, bytes_total){
  13.     // stop and hide movie
  14.     target.stop();
  15.     target._visible = false;
  16.     
  17.     // assign value to preloader
  18.     preloader_mc.value = bytes_loaded/bytes_total;
  19. }
  20. // when loading is complete for loader_mcl
  21. function onLoadComplete(target){
  22.     // show and play loaded clip
  23.     target.play();
  24.     target._visible = true;
  25.     
  26.     // remove the preloader animation
  27.     preloader_mc.removeMovieClip();
  28. }
  29. // if there is an error, this event handler will
  30. // be called and the preloader will be removed
  31. function onLoadError(target, error_code){
  32.     preloader_mc.removeMovieClip();
  33.     trace(error_code);
  34. }


I tried both these methods for the buttons within the dropdown:
1.) in the master's actionscript
Code: [ Select ]
AppSolMC.btn1.onPress = function() {
    startPreload("ContentBox.swf");
}
  1. AppSolMC.btn1.onPress = function() {
  2.     startPreload("ContentBox.swf");
  3. }

2.) That didn't work so I tried the button itself
Code: [ Select ]
on (press) {
    startPreload("ContentBox.swf");
}
  1. on (press) {
  2.     startPreload("ContentBox.swf");
  3. }


Hey all!

I figured it out; all it need was a reference to the container on _root

Here's the code that I put inside the movie clip dropdown to make it use the preloader function and recognize the container_mc
Code: [ Select ]
var loader_mcl = new MovieClipLoader();
loader_mcl.addListener(this);
function startPreload(url){
  
  // use loadMovie to load the swf url into container_mc and it must have "_root." to refer to assets outside of it
  loader_mcl.loadClip(url, _root.container_mc);
}
function onLoadProgress(target, bytes_loaded, bytes_total){
    // stop and hide movie
    target.stop();
    target._visible = false;
    
    // assign value to preloader - you must have the "_root." to refer
    //to the main movie's assets b/c there's nothing in this movie clip
    //to refer to
    _root.preloader_mc.value = bytes_loaded/bytes_total;
}

// when loading is complete for loader_mcl
function onLoadComplete(target){
    // show and play loaded clip
    target.play();
    target._visible = true;
    
    // remove the preloader animation
    //you must have the "_root." to refer
    //to the main movie's assets b/c there's nothing in this movie clip
    //to refer to
    _root.preloader_mc.removeMovieClip();
}

// if there is an error, this event handler will
// be called and the preloader will be removed
function onLoadError(target, error_code){
    _root.preloader_mc.removeMovieClip();
    trace(error_code);
}
  1. var loader_mcl = new MovieClipLoader();
  2. loader_mcl.addListener(this);
  3. function startPreload(url){
  4.   
  5.   // use loadMovie to load the swf url into container_mc and it must have "_root." to refer to assets outside of it
  6.   loader_mcl.loadClip(url, _root.container_mc);
  7. }
  8. function onLoadProgress(target, bytes_loaded, bytes_total){
  9.     // stop and hide movie
  10.     target.stop();
  11.     target._visible = false;
  12.     
  13.     // assign value to preloader - you must have the "_root." to refer
  14.     //to the main movie's assets b/c there's nothing in this movie clip
  15.     //to refer to
  16.     _root.preloader_mc.value = bytes_loaded/bytes_total;
  17. }
  18. // when loading is complete for loader_mcl
  19. function onLoadComplete(target){
  20.     // show and play loaded clip
  21.     target.play();
  22.     target._visible = true;
  23.     
  24.     // remove the preloader animation
  25.     //you must have the "_root." to refer
  26.     //to the main movie's assets b/c there's nothing in this movie clip
  27.     //to refer to
  28.     _root.preloader_mc.removeMovieClip();
  29. }
  30. // if there is an error, this event handler will
  31. // be called and the preloader will be removed
  32. function onLoadError(target, error_code){
  33.     _root.preloader_mc.removeMovieClip();
  34.     trace(error_code);
  35. }
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Glad you figured it out so quick and thanks for posting the solution.
  • gany9
  • Born
  • Born
  • gany9
  • Posts: 4

Post 3+ Months Ago

Bah! I spoke too soon.

Apparently the code I entered will remove the movie clip of the preloader but the preloader still won't load for these swfs - any ideas on how to call it?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

man oh man,
are you aware what is this code doing ?
_root.preloader_mc.removeMovieClip();
Yea, you figured it out, it removes the preloader.
Do you create / attach it again?
If not, then how do you want to appear?
So my suggestion is to hide it instead of removing it.
Just go:
_root.preloader_mc._visible = false;

And in the startPreload function, show it:
_root.preloader_mc._visible = true;

Otherwise, if you remove it like you do now, then attach it from library in the startPreload function:
_root.attachMovie("preloaderLibraryId", "preloader_mc", 1000);

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.