Question : Reference a created movie clip, AS2 Flash 8

I have a list of thumbnails i create using XML.  they are loaded into a movie clip - "thumbnail_mc".  

They are created using these lines:
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());

image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);

I typically load about 25 images into this thumbnail list.  They are spaced out and when clicked, they trigger the larger image to show.  This all works, but I've been adding an auto play - the large image changes after 5 seconds, and I want to change the _alpha of the current image to 50%.  My issue is that I cannot figure out how to reference the thumbnails!

I thought it would be:  
tName = "_level0.thumbnail_mc.t"+p
tName._alpha = 50;

However, when i do a trace on the movie clip - I get a "_level0.instance43.thumbnail_mc.t11" - although it's sometimes it's instance45 or instance47...

Anyway, I'm not sure how to reference the thumbnail movie clips.  Any ideas?  

This is kind of a confusing question, i've posted my entire thumbnails function below.  I also posted what I was trying to do to reference the thumbnails.

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
function thumbnails_fn(k) { 
thumbnail_mc.createEmptyMovieClip("t"+k, k); 
tlistener = new Object(); 
tlistener.onLoadComplete = function(target_mc) {
 
if (lcorn >= 150){
	lcorn = 0;
	ucorn = ucorn + 78;
	}
target_mc._x = lcorn;
target_mc._y = ucorn;
lcorn = lcorn + 78;
 
target_mc.pictureValue = k; 
 
target_mc.onRelease = function() { 
trace("me: " + this);
// this trace displays: _level0.instance43.thumbnail_mc.t11
p = this.pictureValue-1; 
trace("here - nextImage");
nextImage(); 
}; 
 
target_mc.onRollOver = function() { 
this._alpha = 50; 
}; 
 
target_mc.onRollOut = function() { 
this._alpha = 100; 
}; 
}; 
 
image_mcl = new MovieClipLoader(); 
image_mcl.addListener(tlistener); 
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k); 
}
 
// ---------------  What I've tried ------------------------//
// this function is called when my setInterval function fires.
function nextImage() {
	
                     tName = "_level0.thumbnail_mc.t"+p
	tName._alpha = 50;
	trace("tName: " + tName);
	if (p<(total-1)) { 
	p++;
	trace("this is p: " + p);
		this.onEnterFrame = function(){
			if (picture._alpha > 0){
				picture._alpha -= 10;
				
			} else {
				delete this.onEnterFrame;
				loadIt();
			}
		};
	};
}
//THANKS FOR YOUR HELP!
Open in New Window Select All

Answer : Reference a created movie clip, AS2 Flash 8

Hiya mate,

This is a problem I've had many times. My favourite way to solve it (because it gives most flexibility) is to add each new clip to an array as you create them.

So, I'll try a step by step:

1. Declare a new blank array at the top of your script:
var aImageReference:Array = new Array();

2. Each time you "loop" through your code that attaches the image to the thumb clip, push a reference to it on to the array. I'm not sure what you've called them but let's say it is "thumb_mc":
aImageReference.push(thumb_mc);

3. Now, whenever you want to access a clip, just use array access notation. So, if you want to change the alpha of the third image in the series:
aImageReference[2]._alpha = 50;

NB. Arrays are zero based so the third clip is number 2 (because the first one is zero!).

Finally, just be careful of one thing. If your movie performs this task over and over (e.g. it attaches different clips to different instances on different "pages" of your site), be sure to clear the array each time before you start pushing back onto it:
aImageReference = new Array();

Any probs, let me know!

Random Solutions  
 
programming4us programming4us