# Problem Integrating 2 Tutorials

**URL:** <https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049>\
**Category:** flash\
**Created:** [July 19, 2004, 12:27pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049 "2004-07-19T12:27:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swedish\_Mike](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Swedish\_Mike](https://forum.kirupa.com/u/Swedish_Mike)\
**Post date:** [July 19, 2004, 12:27pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/1 "2004-07-19T12:27:45Z")

</div>

[left]Hi there![/left]  
[left] [/left]

[left]First of all, I wanted to say thank you to all of you who post here regularly and provide tutorials for all us n00bs to benefit from. I have learned more about Flash MX from this site than I ever would have reading a book about the topic.[/left]  
[left] [/left]

[left]I am in the process of creating a little personal site, and I am using a couple of tutorials found on this site to do so. The first is “The Complete Flash Site” tutorial ([http://www.kirupa.com/developer/mx/full\_site.htm) and the second is “Creating a Photo Gallery” ([url=“http://www.kirupa.com/developer/mx/photogallery.htm”]http://www.kirupa.com/developer/mx/photogallery.htm](http://www.kirupa.com/developer/mx/full_site.htm)).[/left]

[left] [/left]  
[left]Anyway. I’ve successfully created both and they run fine on their own. My problem begins when I try to integrate the two. I’ve created the basic navigational structure for my site (i.e. “Home”, “Contact”, etc…) and it all works fine. Each page being linked too on the navigation is a published .swf file that gets loaded into the movie clip “contents” which is an instans of the main window. This works just great for all the buttons EXCEPT for “gallery”[/left]

[left]My gallery works fine on it’s own. The pictures show up as they are supposed to, and fade in and out, etc… The code (by suprabeener) for the gallery is as follows:[/left]

[left] [/left]  
[left]//Code written by sbeener (suprabeener)[/left]  
/\*  
i wrote this code, but you can use and abuse it however you like.  
the methods are defined in the order which they occur to make it  
easier to understand.  
\*/  
// variables ------------------------------------------  
// put the path to your pics here, include the slashes (ie. “pics/”)  
// leave it blank if they’re in the same directory  
this.pathToPics = “…/graphics/”;  
// fill this array with your pics  
this.pArray = [“image0.jpg”, “image1.jpg”, “image2.jpg”, “image3.jpg”, “image4.jpg”, “image5.jpg”, “image6.jpg”, “image7.jpg”, “image8.jpg”, “image9.jpg”];  
this.fadeSpeed = 20;  
this.pIndex = 0;  
// MovieClip methods ----------------------------------  
// d=direction; should 1 or -1 but can be any number  
//loads an image automatically when you run animation  
loadMovie(this.pathToPics+this.pArray[0], \_root.photo);  
MovieClip.prototype.changePhoto = function(d) {  
// make sure pIndex falls within pArray.length  
this.pIndex = (this.pIndex+d)%this.pArray.length;  
if (this.pIndex\<0) {  
this.pIndex += this.pArray.length;  
}  
this.onEnterFrame = fadeOut;  
};  
MovieClip.prototype.fadeOut = function() {  
if (this.photo.\_alpha\>this.fadeSpeed) {  
this.photo.\_alpha -= this.fadeSpeed;  
} else {  
this.loadPhoto();  
}  
};  
MovieClip.prototype.loadPhoto = function() {  
// specify the movieclip to load images into  
var p = \_root.photo;  
//------------------------------------------  
p.\_alpha = 0;  
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);  
this.onEnterFrame = loadMeter;  
};  
MovieClip.prototype.loadMeter = function() {  
var i, l, t;  
l = this.photo.getBytesLoaded();  
t = this.photo.getBytesTotal();  
if (t\>0 && t == l) {  
this.onEnterFrame = fadeIn;  
} else {  
trace(l/t);  
}  
};  
MovieClip.prototype.fadeIn = function() {  
if (this.photo.\_alpha\<100-this.fadeSpeed) {  
this.photo.\_alpha += this.fadeSpeed;  
} else {  
this.photo.\_alpha = 100;  
this.onEnterFrame = null;  
}  
};  
// Actions -----------------------------------------  
// these aren’t necessary, just an example implementation  
this.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
this.changePhoto(-1);  
} else if (Key.getCode() == Key.RIGHT) {  
this.changePhoto(1);  
}  
};  
Key.addListener(this);

[left] [/left]  
[left]-------------------------------------------------------------------------[/left]

[left] [/left]  
[left]When I click on my “gallery” button, instead of loading in the designated area (like the other links do), my gallery loads in the top left corner of the screen, and I only see part of the .swf page (the first .jpeg I am trying to display, without the navigation arrows, etc…). I also don’t see any of my “main” navigation, etc…[/left]  
[left] [/left]

[left]The action code on the “gallery” button is the same as the others:[/left]

[left] [/left]  
[left]on (release) {[/left]  
\_root.contents.loadMovie(“gallery.swf”);  
}

[left] [/left]  
[left]Any ideas what may be causing this? I’ve tried multiple workarounds, but none work very well. Any help is appreciated :)[/left]

[left] [/left]  
[left]-Swedish Mike[/left]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 1:35pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/2 "2004-07-19T13:35:01Z")

</div>

Welcome to kirupa forum=)

If you look in the code you’ll 2 times “\_root.photo”. Change those in “this.photo”. The same for your buttons, though you can do it there with skipping the “\_root”.  
More on \_root etc  
[http://www.kirupa.com/developer/actionscript/tricks/root\_parent\_this.htm](http://www.kirupa.com/developer/actionscript/tricks/root_parent_this.htm)

scotty(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 1:49pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/3 "2004-07-19T13:49:37Z")

</div>

> [@scotty](#):
>
> Welcome to kirupa forum=)
> 
> If you look in the code you’ll 2 times “\_root.photo”. Change those in “this.photo”. The same for your buttons, though you can do it there with skipping the “\_root”.  
> More on \_root etc  
> [http://www.kirupa.com/developer/actionscript/tricks/root\_parent\_this.htm](http://www.kirupa.com/developer/actionscript/tricks/root_parent_this.htm)
> 
> scotty(-:

THANK YOU! THANK YOU! THANK YOU!

I have been going NUTS trying to figure this out. I really appreciate the quick reply. Now I just need to do some additional reading about \_root to fully understand why it didn’t work.

In the meantime, I have another quick questions. The image itself keeps “resizing” a little when I go from one to the next. They are all the same size, and I have made sure that the area they are displayed in is the same (and that the scale is set to 100%, 100%).

What could be causing that?

-Swedish Mike

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 2:18pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/4 "2004-07-19T14:18:41Z")

</div>

Flash has some problems with \_alpha when it’s set to 100.  
Try this, maybe it helps:)

```auto
MovieClip.prototype.fadeIn = function() {
 if (this.photo._alpha<98-this.fadeSpeed) {
 this.photo._alpha += this.fadeSpeed;
 } else {
 this.photo._alpha = 99;
 this.onEnterFrame = null;
}
}

```

scotty(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 2:31pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/5 "2004-07-19T14:31:57Z")

</div>

It works wonders!

You certainly know your stuff. Thanks for all the help!

-Swedish Mike

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 2:34pm UTC](https://forum.kirupa.com/t/problem-integrating-2-tutorials/58049/6 "2004-07-19T14:34:33Z")

</div>

no problem=)
