all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Navigation mechanism inside a loaded .swf not functioning



Navigation mechanism inside a loaded .swf not functioning Lobstah
12/29/2004 8:04:11 PM
flash actionscript: I have created a simple Flash MX 2004 PRO .fla in which there is an empty movie
clip called mc_1. It has an empty child called container_mc. I load 3
different .swfs into mc_1.container_mc, one at a time. Each of the .swfs
that gets loaded is just a file created using the Flash slideshow template. So
each of the loaded files has its own little navigation controller. The
navigation controllers work fine in the 3 individual .swfs but when I load them
into my master file's mc_1.container_mc, the navigation mechanisms inside the
loaded .swfs cease to function. From what I have read of the concept of
scope in ActionScript 2.0, I wouldn't expect to have to do anything to the code
driving navigation within a loaded .swf. Can anyone help me figure out what I
have to do to the controllers in each of the 3 loaded .swfs so each can be
navigated from within itself when called from the main timeline?
********************** My little files are all available
http://www.saundersbros.com/macromedia/bobbie.zip, in .zip format. The files
are: masterfile_bobbie.fla and .swf (my main timeline)
3 .swf slideshows (they're 3 copies of exactly the same little slideshow:
) show_malconian.swf, show_everet.swf, show_benoit.swf.
**************************** iF EASIER, CODE SAMPLES ARE ATTACHED
**************************** I'm learning ActionScript 2.0 slowly,
painfully.... any assistance would be greatly appreciated. Thanks CODE
SAMPLES FOLLOW:

ATTACHMENT 1: CODE FROM MAIN TIMELINE WHICH LOADS FIRST .SWF INTO
MC_1.CONTAINER_MC:

//Creates a parent movie clip to hold the container
this.createEmptyMovieClip("mc_1", 0);

//creates a child movie clip inside of "mc_1"
//this is the movie clip the external .swf will replace
mc_1.createEmptyMovieClip("container_mc",99);

mc_1.container_mc._x=405;
mc_1.container_mc._y=105;
//use moviecliploader to first unload any .swf that's playing, then load the
image
MovieClipunloader.unloadClip(mc_1.container.mc);
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.loadClip("show_malconian.swf", mc_1.container_mc);

//put event handler on the parent movie clip mc_1
mc_1.loadClip = function() {
//mc_1.container_mc_level99.Stop();
}

ATTACHMENT 2: CODE FOR THE NAVIGATION CONTROLLER RESIDENT INSIDE THE REMOTE
..SWF (SHOW_MALCONIAN.SWF:)

//controller has 3 buttons: PREVIOUS-NEXT-AUTOPLAY:

function updateFrame (inc) {
// send slides to new frame
newFrame = _root._currentFrame + inc;
_root.gotoAndStop(newFrame);

updateStatus();

if (_root._currentFrame == 1) {
prevBtn.gotoAndStop(2);
} else {
prevBtn.gotoAndStop(1);
}
if (_root._currentFrame == _root._totalFrames) {
nextBtn.gotoAndStop(2);
} else {
nextBtn.gotoAndStop(1);
}
}

function updateStatus () {
_root.statusField = _root._currentFrame + " of " + _root._totalFrames;
}

function autoplayInit () {
startTime = getTimer();
hideControls();
updateStatus();
}

function autoplay () {
if (autoplayStatus != 0) {
// get the current time and elapsed time
curTime = getTimer();
elapsedTime = curTime-startTime;

// update timer indicator
indicatorFrame = int(4/(delay/(elapsedTime/1000)));
indicator.gotoAndStop(indicatorFrame+1);

// if delay time if met, goto next photo
if (elapsedTime >= (delay*1000)) {
if (_root._currentframe == _root._totalframes) {
_root.gotoAndStop(1);
} else {
_root.nextFrame();
}
autoplayInit();
}
}
}

function hideControls () {
nextBtn.gotoAndStop(2);
prevBtn.gotoAndStop(2);
}

updateFrame();
autoplayStatus = 0;
Re: Navigation mechanism inside a loaded .swf not functioning rlc5611
12/29/2004 10:36:02 PM
Without looking at your files in detail, one thing that jumps out is your use
of _root for navigation. If you run a file by itself, _root will mean one thing
but if you load that SWF into another, _root will take on a different meaning
and target something else. You might want to look at how you are targeting the
timeline you want to navigate within and use a more relative approach by using
'this' or '_parent' or some combination as appropriate. If the use of _root is
the cause, it is the same problem for AS 1.0.
Re: Navigation mechanism inside a loaded .swf not functioning akribie
12/30/2004 1:02:50 PM
AddThis Social Bookmark Button