Solved

Loaded SWF Root Issues - Flash 8

Posted on 2009-05-11
3
636 Views
Last Modified: 2013-11-11
I've created a photo gallery called "gallery.swf".  When Gallery.swf plays, it displays 8 buttons on the stage, each button, when clicked, loads an external .swf into an empty movie clip (instance name: mc_holder).

This works fine.  Now you know the framework...

On each of the sub-swfs, I have a navigation bar of image-thumbnails that allow the user to navigate images.  When a thumbnail is pressed, a function changes the property of a movie clip instance (mc_showHome)  that's located on the _root of the sub-swf.

Although the code works fine if the sub-swfs are run independently of the gallery.swf, once they are called by the gallery.swf, the navigation no longer works.  I imagine it's due to the _root property.  However, I've tried every combination of "this" , or "_root", or "parent" and I can not get the sub-swf to refer to it's own _root timeline.

Here's the code i have:
target_mc.onRelease = function() {
      trace("this.pictureValue: " + this.pictureValue);
            _root.mc_showHome.p = this.pictureValue-1;
                  if (_root.mc_showHome._currentFrame >=37 ||     _root.mc_showHome._currentFrame <= 117){
                              _root.mc_showHome.gotoAndPlay(118);
                        }

How do i access the properties of the mc_showHome movie clip?  I've tried this._root.mc_showHome as well - and this doesn't work.

Any help would be appreciated!

Thank you!

0
Comment
Question by:steverguy
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
quizengine earned 500 total points
Comment Utility
I'm not sure if this will solve your problem, but it's what I would try first. In each of your sub-swfs add the line of code

_lockroot = true;

to the first frame. This code means that when your sub swfs use _root, they mean the root of themselves, not whatever movie they are nested inside.
0
 
LVL 1

Author Comment

by:steverguy
Comment Utility
That was it!  :)  - It works great...  but just out of curiosity, if for some reason the loaded swf needed to refer to both the base .swf's _root and it's own _root, what is the best way to call it?

Thanks for your help!
0
 
LVL 19

Expert Comment

by:quizengine
Comment Utility
If you use the technique I described, then _root of the master swf becomes unavailable to the sub-swf. For example, you couldn't say '_root.root'.

But you should still be able to access it using '_parent._parent._parent....<for as many times as the clip is nested>. This can get a bit messy if your project isn't well planned or structured.

Avoiding '_root.' is generally regarded as good programming practice, as it helps your code become more re-usable. I.e. if a movieclip has no 'dependencies' outside of itself, it can be dropped into any new project and reused without any code being rewritten. It's hard to get out of the use of _root, but you can find big time savings if you can reuse code between projects, so it may be worth a little short term pain.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now