Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loaded SWF Root Issues - Flash 8

Posted on 2009-05-11
3
Medium Priority
?
646 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

719 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