Log in

View Full Version : Preload SWF files with MovieClipLoader class and Nav Buttons



Sergio11
11-18-2008, 06:46 PM
Hello all,

Thank you to Medyman who pointed me to a wonderful tutorial a few weeks ago regarding preloading external SWFs into an empty movieclip (gotoandlearn.com).

The above worked like a charm. In addition to a left nav bar, we would like to add "forward" and "back" buttons to the individual external SWFs that are being loaded into the empty movieclip which appears in what is the home page.

Is it possible to have the "forward" and "back" buttons, within these external SWFs, which are displayed in an empty movieclip, link to another external SWF and have that SWF display in the empty movieclip?

In other words, once the "forward" or "back" button is clicked, the current SWF is replaced by a new SWF within the same empty movieclip on the home page.

I have not been able to figure out how to target these external SWFs to the empty movieclip on the home page.

Any suggestions or help is sincerely appreciated.

Kind regards,
Sergio

Medyman
11-18-2008, 07:17 PM
Sure,
It's just a matter of how you call the appropriate actions. The process is the same, you just have to make sure you're loading MCs into the same container.

If you're calling actions from the main timeline of the embedded SWF, using this._parent should point you towards the MC into which the embedded SWF is loaded.

Sergio11
11-18-2008, 07:22 PM
Hi Medyman,

Thank you again. Your help is appreciated. I will give this a try.

Have a great day!
Sergio

Sergio11
11-18-2008, 08:08 PM
Hi Again Medyman,

If you have time, could you share more of what the code might look like please?

I used the code below on an "actions" layer, within the scene, of the SWF that is currently loaded into the movieclip (holder).

next_cms_overview.onRelease = function () {
mcl.loadClip ("about_us.swf", this.parent.holder);

Please excuse my ignorance. And, if you are too busy to reply, I COMPLETELY understand.

Thanks again!
Sergio

Medyman
11-18-2008, 08:12 PM
You're using AS2, right? If so, the parent selector has a underscore in front. So it should be:


mcl.loadClip ("about_us.swf", this._parent.holder);

If that doesn't work, add this to the same place that you're adding the above:

trace(this._parent);

Now, test the main SWF (not the embedded one). Does the output from the trace point to the right MC? If not, you might need to add multiple parent selectors (this._parent._parent, for example).

Sergio11
11-18-2008, 08:38 PM
Hi Medyman,

Thank you very much. I am using AS2. Also, I tested all three options you mention above using the main SWF. I received the following error with the first code:
"undefined"
I received the following error with the other code:
"_level10.holder".

Please do not feel like you need to offer more help. I appreciate the time you have already given.

I will better look into taking a class :-)

Kind regards,
Sergio

Medyman
11-19-2008, 01:27 AM
Hmm...

What did you put to get this: "_level10.holder"..

That's not an error. That's what you want. I'm getting it was trace(this._parent._parent).

If so, try this:

mcl.loadClip ("about_us.swf", this._parent._parent);

Basically you want the this._parent._parent part to equal the holder movieclip. So, keep tracking until you get that value to equal _level10.holder and then put that value there.

Sergio11
11-20-2008, 01:38 PM
Hi Medyman,

Sorry for the late response... was off-site yesterday.

Thank you for the additional advice. I will give it a try.

Kind regards,
Sergio

Sergio11
11-25-2008, 08:38 PM
Hi Medyman,

Thank you for your help last week. I didn't have much luck (I probably did something wrong). However, this code below seems to work well. I am copying below for others to use. Thanks again for your time.

Kind regards,
Sergio

next_cms_overview.onRelease = function () {
_level0.holder.loadMovie("about_us.swf");
}

Medyman
11-25-2008, 11:50 PM
Hmm...yeah that would work too. Or you could replace _level0 with _root. I should have suggested that first.

I've been doing OOP stuff in AS3 so root has an entirely different scope and meaning. That's why I didn't immediately think of it. Oh well :)

Glad you got it working.

Sergio11
11-26-2008, 03:36 PM
Hi Medyman,

Sounds complicated to me :-)

I sure hope to learn more actionscript over time.

Have a great holiday!