Referencing A Nested Clip

Hello -

I'm relatively new to Flash.  Please forgive me if my terminoligy is incorrect.  Hope someone can help with this.

I have a main movie (page3.fla) which contains a movieclip with an instance name of "gallery".
Inside "gallery" is actionScript that loads images from a directory (taken from a tutorial located at http://www.kirupa.com/developer/mx/photogallery.htm).

This is a snippet from the "gallery" clip:

MovieClip.prototype.changePhoto = function(d) {
      this.pIndex = (this.pIndex+d)%this.pArray.length;
      if (this.pIndex<0) {
            this.pIndex += this.pArray.length;
      }
      this.onEnterFrame = fadeOut;
};

I'm trying to advance to the next image with the following code attached to a button instance in my main movie:

on (release) {
      gallery.changePhoto(1);      
}

It doesn't seem to be doing anything but frustrating the heck out of me!

I've tried _root.gallery and this.gallery and all kinds of other things but can't get any of it to work.

Any help would be GREATLY appreciated.

Thanks

B
LVL 1
ttist25Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vickerleungCommented:
ttist25,

try modify the code to this to check if it helps

function changePhoto (d) {
     this.pIndex = (this.pIndex+d)%this.pArray.length;
     if (this.pIndex<0) {
          this.pIndex += this.pArray.length;
     }
     this.onEnterFrame = fadeOut;
};
0
sokhodomCommented:
ttist,
May i know how do you load your gallery movie to your main movies? Using loadMovie? Plz write code down.. Sometimes, the loadMovie might give you problem as well.
SokhodoM
0
ttist25Author Commented:
vicker -

Thanks for posting so quickly.  I tried the code you posted with negative results.  Can you tell me from what I posted if the reference I'm using "gallery.changePhoto(1)" is the correct syntax for refering to this?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

vickerleungCommented:
ttist,

If you wanna check if the function is called

function changePhoto (d) {
     trace ("success"); <========== add this line~~!!
     this.pIndex = (this.pIndex+d)%this.pArray.length;
     if (this.pIndex<0) {
          this.pIndex += this.pArray.length;
     }
     this.onEnterFrame = fadeOut;
};

If the text success prints out, that means a call success
If success then is the function content's problem instead

Vicker
0
blue-genieCommented:
hi there ttist,

I had a look at the Kirupa tutorial you mentioned, if you're doing it as per the tutorial, your changePhoto method is actually residing on the timeline, not the movieclip, therefore to call it, you need to simply say _root.changePhoto(1);

Unless you've changed the whole construction of the movie, that is your problem.

blu.
0
ttist25Author Commented:
sokhodom -

I have created the gallery movie clip as a new movie symbol in the library and just inserted an instance of it on it's own layer in the main movie.

0
ttist25Author Commented:
blue -

What I am trying to do is insert the gallery as a movie clip instance in my main timeline.   I have been successful in creating the gallery as a standalone movie but the actionScript conflicts with other events on my main timeline so I was trying to add it as a movie clip instance with its own timeline to prevent those conflicts.

I created a new symbol in the library of the main movie and followed the instructions in the tutorial and I'm stuck at this point.  If I add buttons directly to the gallery instance, they don't appear when I run the swf.  So I tried putting them on the main movie and still no luck.

I'm sooooooooooooo confuuuuuuuuuuuuused!!!!

0
blue-genieCommented:
i'm a bit confused as to which approach you're using, you say that you tried Vicker's suggestion but to no avail.

i suspect that because the tutorial used Movieclip.prototype - it would cause all movieclips to act "funny" - thus the problem you had, so what you should be doing then, is as per Vicker's code (replacing the movieclip.proto bit) - and refer to it using _root.

i think that should solve it, otherwise you'll need to post the file

blu.
0
ttist25Author Commented:
Ok - I've given up on trying to get this to work as a movie clip inside the main movie.  My new approach is to create the gallery as a standalone movie and load the swf into a movieclip on the stage using loadMovie.

I created galleryKitchens.swf using the Kirup tutorial referenced above.  I added forward and backward buttons to the stage so the user can advance and rewind the images using:

on (release) {
      _root.changePhoto(1);      
}

This works great as a standalone movie.  The buttons work, it pulls in the images etc.

I assigned the following actionScript to a button on the stage of my main movie:

on (release) {
      bucket.loadMovie('galleryKitchens.swf');
}

Bucket is the movie clip instance in my main movie into which the gallery movie (galleryKitchens.swf) loads.

When I click my button it loads galleryKitchens.swf and pulls in the first image, but I can't see the forward and backward buttons (they flash for a quick instance when it is loading and disappear).

It's almost as if the image is loading ontop of the button layer but the buttons work great if I open galleryKitchens.swf alone.

Any ideas?

Brian
0
blue-genieCommented:
Hi Brian, yeah, i'd say that's your problem. *Trying to visualise your setup here*
make sure that galleryKitchens.swf doesn't have a background on it?
Surely the btns are below it - not on top of it. because then they shouldn't overlap.

where are the next and back btns? on the _root where bucket is?

are the next and back btns inside bucket? or is bucket an empty Movie clip?

try using a swapDepths as in

bucket.loadMovie('galleryKitchens.swf');
bucket.swapDepths(clipwithbtns);

or specify a level to load into.
0
ttist25Author Commented:
Blu -

The following link is to a question I posted at kirupa.com.  It gives a much better description of the setup than the feeble attempt I posted here.

http://www.kirupaforum.com/forums/showthread.php?t=77238

Also, I'd be happy to post the .fla's if you can tell me where/how to do that.

In answer to your questions:
galleryKitchens.swf has 3 layers:

layer1  - is the actionscript layer with the script from the tutorial in frame 1.  It has been modified as per vickerleung's instruction (changed all 'MovieClip.prototype' to 'function functionName()').  It works great until it's nested.

layer2 - is a rectangle the size of the images which was converted to a MovieClip instance (photo) as per the tutorial instructions.

layer3 - contains the back/forward buttons.  They are the green gel buttons from the common libraries -> buttons library.  they have the following code attached:

       on (release) {
           _root.changePhoto(1);
       }

I tried moving the nav buttons up and down the layers to no avail.

I also tried loading the movieclip bucket into level 5 with the following (from a button on the parent of galleryKitchens):

       on (release) {
      bucket.loadMovie('galleryKitchens.swf', 5);
       }

This didn't make a difference.

I'm assuming that since the buttons are in the same movieclip as galleryKitchens that we can't use the swapDepths thing.

Anyway - thanks again for all of your help.  I'll be a happy man when we get this.
0
blue-genieCommented:
either get yourself some free space, geocities or something,
and post your zipped files there.
or,
mail to bluegenie(at)bigfoot(Dot)com

0
ttist25Author Commented:
Blue,

I just sent you an email with a link
0
ttist25Author Commented:
Blu -

The email got kicked back.  Is it bluegenie or blue-genie?
0
blue-genieCommented:
oh shyte, sorry its blue-genie(at)bigfoot(dot)com

0
ttist25Author Commented:
Ok bud.  I just sent the email.  Really looking forward to your response.
0
blue-genieCommented:
Ok, i'm confused now even further.

Which file of all those is giving you the problem, there's images missing here.
can you please narrow it down and specify which file is the one where there's the problem instead of me going through each file.

What's the difference between galleryKitchensMod1.swf and galleryKitchens.swf

then your code is looking for page2.swf yet your pages are page2a.swf - I thought you'd removed the Movieclip.prototype code?

where's the latest version up to the point of your last post? i'd must rather have that then to have to sift through all the stuff again.

blu.
0
ttist25Author Commented:
I am sooo sorry Blue.  I apologize.  I was in such a hurry to get everything to you that I didn't consider how confusing that would be.  Again, very sorry.

I have uploaded a new zip file named blue.zip to the same directory.  It contains the following files:

temp1.fla - this is the main movie file
gallery.fla - this is the movie that is loaded into temp1 when the gallery button is clicked on temp1
galleryKitchens.fla - this is the movie that is loaded into 'bucket' from the 'kitchenButt' button on gallery.fla

I also included the index.html file, page1.fla (which is the first movie loaded into temp1) and the image files in the proper directories.

If you open gallerKitchens.swf you can see how that is supposed to work.

If there is anything else I can clarify please let me know.

And thanks again for all of your help.  It truly is appreciated.

Brian
0
blue-genieCommented:
Hey Brian - thanks, much better :-)

Okay, first things first, the problem is simply a case of confused roots ie. in your galleryKitchens.fla - you'll notice you have a couple of references to _root.photo - but once you load galleryKitchens.swf into _level0.bucket - your root structure then changes.

I tried putting in this._lockroot = true which ususally would do the trick, but it didn't - go figure.

anyways, if you change those _root.photo to this.photo - you'll notice that your btns now appear - but you'll also notice that they won't work - don't be disheartened - change your code on the buttons to -

 on (release) {
      _level0.bucket.changePhoto(-1);
}

but then - yet another problem - your original picture you'll see, shows through when you're doing the alpha fade out, so what i'd sugest there is use an unload when they first click on the gallery link to remove it.

hope this all makes sense.

ps. like your design (looks good).
blu.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ttist25Author Commented:
BLUE!!!!!!!!!!!!!!!!!!!!!!!!!!!

You're the man!  Thanks Boss.

It works great now.  I just did a couple things differently.  On the buttons instead of '_level0.bucket.changePhoto' I did 'this.bucket.changePhoto' (the level0 wouldn't work for some reason???).

Also, I couldn't get unload to work on the original pic so I just set the alpha of the original picture to 0 on release.

PRESTO!

You have no idea how happy I am to have this working.  Thanks so much for your patience.

Great job.
0
blue-genieCommented:
Um, i'm not so sure about the man bit, but um yeah, alright.
Not keen on the sex change idea, but you're very welcome.

I like the Boss bit though ;-)
there's many ways to beat a horse (or however the saying goes) - I guess once you know what the problem is, there's a number of ways to solve it, but I'm glad its working.

blu
0
ttist25Author Commented:
Ok then - Boss it is!

Thanks again Blu.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.