Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Photo Gallery

Status
Not open for further replies.

bobby8685

Technical User
Mar 5, 2006
36
0
0
US
Just want to say thanks for all previous help first.

Hi,
I am trying to create a photo album for a website. The Album will work by the user clicking on a movie clip button with the instance name of "picbtn". Each of the buttons will have the call to name of "pic1_mc", "pic2_mc", etc... Upon release, my loader componet with symbol name "picLoader" and call to name of "picViewer_mc" will load the .png file that goes with each button. However when tested, upon release, nothing loads into the loader. Any help will be greatly appreciated. Thanks. My action script looks like this,
Code:
//-----------Initialization---------\\
extLoader_mc._visible = false;
//-----------------------------------\\


//--------Movie Clip Loader----------\\
var mcLoader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
mcLoader.addListener(myListener);

myListener.onLoadProgress = function(target_mc,bytesLoaded,bytesTotal) {
	extLoader_mc._visible = true;
	var pctLoaded = Math.round(bytesLoaded/bytesTotal*100);
	extLoader_mc.extLoaderBar_mc._xscale = pctLoaded;
	if (bytesLoaded >= bytesTotal) {
		extLoader_mc._visible = false;
	}
}
mcLoader.loadClip("pics/1.png",picViewer_mc.picLoader);
//-----------------------------------\\

//------------\\
//On RollOver Events\\
pic1_mc.onRollOver = function() {
	pic1_mc.gotoAndPlay("over");
}

pic2_mc.onRollOver = function() {
	pic2_mc.gotoAndPlay("over");
}

pic3_mc.onRollOver = function() {
	pic3_mc.gotoAndPlay("over");
}

pic4_mc.onRollOver = function() {
	pic4_mc.gotoAndPlay("over");
}

pic5_mc.onRollOver = function() {
	pic5_mc.gotoAndPlay("over");
}

pic6_mc.onRollOver = function() {
	pic6_mc.gotoAndPlay("over");
}

pic7_mc.onRollOver = function() {
	pic7_mc.gotoAndPlay("over");
}

pic8_mc.onRollOver = function() {
	pic8_mc.gotoAndPlay("over");
}

pic9_mc.onRollOver = function() {
	pic9_mc.gotoAndPlay("over");
}

pic10_mc.onRollOver = function() {
	pic10_mc.gotoAndPlay("over");
}

pic11_mc.onRollOver = function() {
	pic11_mc.gotoAndPlay("over");
}

pic12_mc.onRollOver = function() {
	pic12_mc.gotoAndPlay("over");
}
//---------------------\\
//Picture Load Functions\\
pic1_mc.onRelease = function  () {
	mcLoader.loadClip("pics/1.png",picViewer_mc.picLoader);
}
pic2_mc.onRelease = function  () {
	mcLoader.loadClip("pics/2.png",picViewer_mc.picLoader);
}
pic3_mc.onRelease = function  () {
	mcLoader.loadClip("pics/3.png",picViewer_mc.picLoader);
}
pic4_mc.onRelease = function  () {
	mcLoader.loadClip("pics/4.png",picViewer_mc.picLoader);
}
pic5_mc.onRelease = function  () {
	mcLoader.loadClip("pics/5.png",picViewer_mc.picLoader);
}
pic6_mc.onRelease = function  () {
	mcLoader.loadClip("pics/6.png",picViewer_mc.picLoader);
}
pic7_mc.onRelease = function  () {
	mcLoader.loadClip("pics/7.png",picViewer_mc.picLoader);
}
pic8_mc.onRelease = function  () {
	mcLoader.loadClip("pics/8.png",picViewer_mc.picLoader);
}
pic9_mc.onRelease = function  () {
	mcLoader.loadClip("pics/8.png",picViewer_mc.picLoader);
}
pic10_mc.onRelease = function  () {
	mcLoader.loadClip("pics/8.png",picViewer_mc.picLoader);
}
pic11_mc.onRelease = function  () {
	mcLoader.loadClip("pics/8.png",picViewer_mc.picLoader);
}
pic12_mc.onRelease = function  () {
	mcLoader.loadClip("pics/8.png",picViewer_mc.picLoader);
}
//-------------------------\\
There is also a preloader that will when displaying larger files.
 
It's probably a scope issue.
[tt]
pic1_mc.onRelease = function () {
trace(picViewer_mc.picLoader)
mcLoader.loadClip("pics/1.png", picViewer_mc.picLoader);
}
[/tt]
Do you get "undefined" in the Output?

You may want to do:
[tt]
pic1_mc.onRelease = function () {
mcLoader.loadClip("pics/1.png", this._parent.picViewer_mc.picLoader);
}
[/tt]

Kenneth Kawamoto
 
Thanks a lot kennethkawamoto. That got things working. I have an idea of what the "trace" does, but what does "this.parent" do?
 
this" and "_parent" are two most important concepts in ActionScript!
[tt]
pic1_mc.onRelease = function () {
trace(this);
}
[/tt]
If you do the above you should get the reference to the MovieClip "pic1_mc", because that's where this function belongs.

[tt]
pic1_mc.onRelease = function () {
trace(this._parent);
}
[/tt]
This time you should get the reference to the parent of "pic1_mc". If "pic1_mc" is on the main timeline it will output the reference to the main timeline ("_level0").

[tt]
pic1_mc.onRelease = function () {
trace(picViewer_mc);
}
[/tt]
This will be "undefined". "trace(picViewer_mc)" is the same as "trace(this.picViewer_mc)" and "picViewer_mc" does not live inside "pic1_mc" but lives inside of the parent of "pic1_mc". Therefore if you want to reference "picViewer_mc" you have to do:
[tt]
pic1_mc.onRelease = function () {
trace(this._parent.picViewer_mc);
}
[/tt]

Kenneth Kawamoto
 
Now what if I mean to point somewhere else using the same pic1_mc button. For instance. If I created a gallery in the same flash file and named it "gallery_mc". Inside this "gallery_mc" would be 2 pictures each on seperate frames and stop actions above them. Easch frame would be named 1 and 2, so on frame "1" would be the first picture and on frame "2" would be the seconf picture.

How would I be able to point from the pic1_mc to inside gallery_mc to play frame 1? When tried, I came accross an OnClip handler error. Thanks for all the assistance. This however is for thee feature, seeing as it may be another way to show a galler if needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top