Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loaded SWF Root Issues - Flash 8

Posted on 2009-05-11
3
Medium Priority
?
649 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 2000 total points
ID: 24356605
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
ID: 24356657
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
ID: 24356929
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

963 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