View Full Version : Loader Component + loaded .swf = I can't access functions in main .swf
liltee
09-18-2008, 04:05 PM
Hello,
I'm new here at AS.org but love the site. I feel i'm fairly proficient in AS and have used these components etc for some time, but I am banging my head against the wall here.
I have a main.swf that contains some top level functions to be shared across the project. This "main.swf" also contains a AS2.0 Loader component that loads in content "transitions.swf". transitions.swf contains 6 other symbols that have tiny frame based animations "transitions" each with it's own AS layer containing "stop();" actions and calls to the functions in the main timeline that actually holds "the loader component. The purpose of this is to trigger events on the main timeline when a frame is hit in the transition.
So my problem is this, when these frames are hit all my trace("something") report i'm there but, the functions on the timeline do not fire nor do their trace actions fire. I'm able to tell the transitions to gotoAndPlay() to run them from the main timeline but can't seem to go in reverse.
I've tried adding _lockroot to the content of the component but that does not work.
I hope this makes sense.
atomic
09-18-2008, 04:15 PM
Be better if you attached your .fla to this forum...
It just seems to me, to be a path problem... Are the transitions.swf's loaded in a container clip or on a level?
Can you at least post an example main timeline function call code from one of these transition.swf's?
liltee
09-18-2008, 04:39 PM
On main timeline I have and instance of the Loader component named "loader_clip"
Loader_clip loads up "transitions.swf" which contains several MC's all contained in a clip
with the instance name of "contentHolder"
on the first frame of the main timeline I have this code.
transitionLoader = new Object();
transitionLoader.complete = function(eventObject){
trace("everything is loaded");
gotoAndPlay(2);
}
loadListener = new Object();
loadListener.progress = function(eventObj) {
// eventObj.target is the component that generated the progress event,
// that is, the loader.
trace("The image is "+loader_clip.percentLoaded+"% loaded.");
new Tween (preloader_mc.bar_mc, "_xscale", preloader_mc.bar_mc._xscale, loader_clip.percentLoaded, .25, true);
preloader_mc.percent_tf.text = Math.round(loader_clip.percentLoaded) + " %";
// Track loading progress.
};
loader_clip.autoLoad = true;
loader_clip.contentPath = "transitions.swf";
//loader_clip.content._lockroot = true;
loader_clip.load();
loader_clip.addEventListener("complete", transitionLoader);
loader_clip.addEventListener("progress", loadListener);
Once the transitions are loaded the main timeline skips to frame 2.
Where I make calls to the transitions like such to get them to run. This works.
showLobby = function(){
loader_clip.contentHolder.enter_house.gotoAndPlay( 8);
lastOpen = "enter_house";
}
What i'm unable to do is the following:
Say I have a button in the MC with an instance name of "button"
On the main timeline I can't get the following to work.
loader_clip.contentHolder.enter_house.myButton.onR elease = function(){
loader_clip.contentHolder.goConference.gotoAndPlay (2);
}
Nor am I able to make a call from the above MC "enter_house" to the Main timeline
. I have code on the last frame of the MC like such
stop();
_root.showLobby();
atomic
09-18-2008, 05:38 PM
Ummmmmmmmmh! Think you'll need to attach or provide a link to all your files...
I've always hated the loader component...
That said concerning your first problem...
What i'm unable to do is the following:
Say I have a button in the MC with an instance name of "button"
On the main timeline I can't get the following to work.
loader_clip.contentHolder.enter_house.myButton.onR elease = function(){
loader_clip.contentHolder.goConference.gotoAndPlay (2);
}
First you say that the instance of the button is button, while in your script, you're using myButton... Which is it?
Second, other than the instance name might be wrong or not, when assigning a button's handler in this manner from the main timeline, are you aware that you can only do so, if the button or the myButton is actually present on stage on the frame you're attempting to assign the handler?
In other words, if the button is only present, as an example, from frame 5 in your enter_house mc, and that the enter_house mc, again as an example, is stopped on it's frame 1, when you're trying to assign the handler to the button, then that won't work.
You cannot target (and assign a handler to...) a button from the main timeline, if that button is not actually present on stage, when assigning the handler...
liltee
09-18-2008, 05:48 PM
my mistake. "button" or "myButton" was a typo and just an example. Your second part of the post does answer my problem with assigning the embedded button via the main timeline.
So why am I having problems accessing functions on the main timeline from MC's inside the loaderclip? Shouldn't I just be able to use _root to take my path out to the main timeline that holds the loader component?
atomic
09-18-2008, 06:00 PM
So why am I having problems accessing functions on the main timeline from MC's inside the loaderclip? Shouldn't I just be able to use _root to take my path out to the main timeline that holds the loader component?
Maybe the loader component's fault again... And why I asked that you attach your files, so that I can do some testing on my own...
Are you using _lockroot within the loaded in movies?
If so that might be the culprit, since _root would then target the main timeline of the loaded in movie itself rather than the main movie's main timeline...
If that's what happening, suggest you try _level0 rather than _root or even a relative path such as...
_parent.showLobby();
You might even need more than 1 _parent, depending on the nested level on which the mc actually is...
liltee
09-18-2008, 06:18 PM
Your awesome. _level0 gets me out where I need to be.
I thought I had tried that but obviously not.
Thanks so much for you help.
atomic
09-18-2008, 06:37 PM
Grrrrrrreat! ;)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.