Solved

Loaded SWF Root Issues - Flash 8

Posted on 2009-05-11
3
642 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
quizengine earned 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

759 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