Skip to main content
Known Participant
August 26, 2010
Question

buttons do not work! function script problem

  • August 26, 2010
  • 1 reply
  • 550 views

help please!

I tried a new script. But it doesn't want to work. it is like this

photo.onPress = function(){
startPreload("slider.swf");
}

bio.onPress = function(){
startPreload("bio.swf");
};

design.onPress = function(){
startPreload("design.swf");
};

function startPreload(url){
Cont.loadMovie(url);
attachMovie("preloader anim", "prldr", 500, {_x:400, _y:300});

onEnterFrame = preloadContainer;
}

//and in same frame different layer


function preloadContainer(){
ar ldd = Cont.getBytesLoaded();

var ttl = Cont.getBytesTotal();


Cont.stop();
Cont._visible = false;

if (bytes_total > 0){
var prcnt = ldd/ttl;
preloader_mc.value = prcnt;

if (prcnt == 1){

Cont.play();

Cont._visible = true;


preloader_mc.removeMovieClip();
delete onEnterFrame;

}
}
}

that's it.

I checked. The movie clip that swfs are loaded into has instance "Cont"

other instances are also ok. photo, bio and design are instances of buttons.

Bio loads the swf but the preloader is not showing up. Photo doesn't load the swf and preloader at all ;/

help help help!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 27, 2010

1.  slider.swf isn't correct

2.  first check if your preloader is created.  what do the trace() statements show:


function startPreload(url){
Cont.loadMovie(url);
var mc:MovieClip = attachMovie("preloader anim", "prldr", 500, {_x:400, _y:300});

trace(mc);


onEnterFrame = preloadContainer;
}


function preloadContainer(){
ar ldd = Cont.getBytesLoaded();

var ttl = Cont.getBytesTotal();


Cont.stop();  // this won't work until loading is complete
Cont._visible = false;  // this won't work until loading is complete

if (bytes_total > 0){
var prcnt = ldd/ttl;
preloader_mc.value = prcnt;

if (prcnt == 1){

Cont.play();

Cont._visible = true;

trace("removed");


preloader_mc.removeMovieClip();
delete onEnterFrame;

}
}
}


borys_kAuthor
Known Participant
August 27, 2010

when i previously used a script:

on (release) {

     loadMovie("slider.swf", Cont)

     }

everything was fine

it seems like the problem is between photo instance and the button ;/

kglad
Community Expert
Community Expert
August 27, 2010

ok