View Full Version : targeting trouble
irkNoir
07-22-2004, 09:59 PM
I have two .swfs loaded into another. I need to control one of them with a button located in the other. The script lies in the master-file.
here is what i thought the principle would be like:
stop();
createEmptyMovieClip("mcPlaceholder1",0);
loadMovie("mc1.swf","mcPlaceholder1");
createEmptyMovieClip("mcPlaceholder2",1);
loadMovie("mc2.swf","mcPlaceholder2");
this.mcPlaceholder1.button.onRelease = function(){
mcPlaceholder2.stop();
}
..but it won't work. any hints?
try adding _root:
this.mcPlaceholder1.button.onRelease = function(){
_root.mcPlaceholder2.stop();
irkNoir
07-23-2004, 08:13 AM
Nope, doesn't help. This is something i really would like to understand as it is quite essential to communication between clips.
My situation is that I have a row of buttons that scroll, contained within a clip thats loaded into the main clip. In the main clip there are other clips that needs to be controlled by the buttons in the scrolling row.
Is'nt this quite a basic setup? What am I doing wrong here?
Let me see if I follow. YOu have a movieclip with buttons, that creates two empty movieclips. Ok, now, in the loaded swf with the buttons, is "button" the instance name?
this.mcPlaceholder1.button.onRelease = function(){
irkNoir
07-23-2004, 05:54 PM
yes, button is the instance name
irkNoir
07-23-2004, 05:59 PM
but the empty movieclips and where they are created (in this example they are created in the swf that all the clips are loaded into) is not really essential. They might as well have been created in the timeline.
irkNoir
07-23-2004, 06:20 PM
ok here is a simple diagram showing the setup(check attachment)
1) mc1 and mc2 is loaded into master
2)the button in mc1 is to control the timeline in mc2
3)the code is to be in the master.swf
:)
Therefore, _root should work. Try chaning:
this.mcPlaceholder1.button.onRelease = function(){
to
_root.mcPlaceholder1.button.onRelease = function(){
irkNoir
07-28-2004, 06:40 AM
Sorry! I'm being very unreliable here (had to go on a small holiday in the middle of our conversation...).
Anyway, thank you so much for trying to help (I don't know anyone who knows AS so this is my only place to go). Here are the files attached.
Changing it to _root. won't help, u see.
...If you're still there.
irkNoir
07-29-2004, 07:34 PM
thought i should post the solution the this problem for academic reasons...
basically you need to preload the movies so that they are fully loaded before the button statement becomes "active"
createEmptyMovieClip("mcPlaceholder1", 1);
createEmptyMovieClip("mcPlaceholder2", 2);
function checkload() {
if (mcPlaceholder2.getBytesLoaded()>=mcPlaceholder2.getBytesTotal() && mcPlaceholder2.getBytesLoaded()>1 && mcPlaceholder1.getBytesLoaded()>=mcPlaceholder1.getBytesTotal() && mcPlaceholder1.getBytesLoaded()>1) {
//trace("hello");
mcPlaceholder2.gotoAndPlay(2);
mcPlaceholder1.gotoAndPlay(2);
mcPlaceholder2.butt1.onPress = function() {
mcPlaceholder2.stop();
};
clearInterval(myinterval);
}
}
_root.mcPlaceholder1.loadMovie("mc1.swf");
//decided to use a holder mc rather than creating a new one
mcPlaceholder2._y = 200;
mcPlaceholder2.loadMovie("mc2.swf");
myinterval = setInterval(checkload, 50);
(greetings to kam in london!)
signing out
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.