Solved

Loaded SWF Root Issues - Flash 8

Posted on 2009-05-11
3
640 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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 what frame rate is, how to control it and what effect it has on the video.

839 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