# How to target this?

**URL:** <https://forum.kirupa.com/t/how-to-target-this/17834>\
**Category:** Uncategorized\
**Created:** [April 9, 2003, 8:57pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834 "2003-04-09T20:57:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashmatazz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/flashmatazz/32/140_2.png) [@Flashmatazz](https://forum.kirupa.com/u/Flashmatazz)\
**Post date:** [April 9, 2003, 8:57pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/1 "2003-04-09T20:57:10Z")

</div>

I can’t seem to figure out how to target an mc properly after loadMovie.

I have a swf where an mc is copied 15 times (so a 4\*4 grid is formed) like this:

```auto

Movieclip.prototype.duplicateMC = function(){
	amount = 16
	x = 1;
	y = 0;
	for (i=1; i<amount; i++){
		//trace("x:" + x + " y: " + y);
		duplicateMovieClip(this, "copy"+i, i);
		if (i%4 == 0) {
			x = 0;
			y += 1;	
		}
		_root["copy"+i]._x += 50*x;
		_root["copy"+i]._y += 50*y;
		x++;
	}
}
this.onLoad = function(){
	_root.original.duplicateMC();
}

```

This works fine. However, when I load it into another movie with loadMovie, it doesn’t work anymore because of the **\_root** that I use.  
I thought that using **\_parent[“copy”+i].\_x += 50\*x;** would do the trick, but it doesn’t…

Who can help me out on the proper notation for this??

Thanks!

---

<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:** [April 9, 2003, 9:03pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/2 "2003-04-09T21:03:08Z")

</div>

did you try this[“copy”+i] ??

---

<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:** [April 9, 2003, 9:08pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/3 "2003-04-09T21:08:27Z")

</div>

yes, I tried that as well. It doesn’t work unfortunately ☹

Any other ideas?

Cheers.

---

<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:** [April 10, 2003, 1:23pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/4 "2003-04-10T13:23:49Z")

</div>

Anyone??

---

<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:** [April 11, 2003, 8:47am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/5 "2003-04-11T08:47:36Z")

</div>

I just can’t believe there’s no flashguru that doesn’t know this so… \* bump \*

---

<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:** [April 11, 2003, 9:27am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/6 "2003-04-11T09:27:49Z")

</div>

ok… well this is not very dynamic, but if you knew exactly where these mc’s were going to reside, then you could call out to it.

so if you used loadMovie to load this swf into a movie clip called. “holder” Then the prototype script might be something like this

```auto
Movieclip.prototype.duplicateMC = function(){
        amount = 16
        x = 1;
        y = 0;
        for (i=1; i<amount; i++){
                //trace("x:" + x + " y: " + y);
                duplicateMovieClip(this, "copy"+i, i);
                if (i%4 == 0) {
                        x = 0;
                        y += 1;
                }
                _root.holder["copy"+i]._x += 50*x;
                _root.holder["copy"+i]._y += 50*y;
                x++;
        }
}
this.onLoad = function(){
        _root.holder.original.duplicateMC();
}

```

maybe…

just wondering… why not use attachMovie instead? I find it more convienient.

---

<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:** [April 11, 2003, 10:22am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/7 "2003-04-11T10:22:40Z")

</div>

Thanks David.

However, if I would target the container mc directly, my original movie wouldn’t work as a standalone movie anymore, am I right?

Also I’m just wondering: what would be the benefit of using attachMovie instead of placing one instance on stage and copy that with duplicateMovieClip?

Thanks.

---

<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:** [April 11, 2003, 8:40pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/8 "2003-04-11T20:40:40Z")

</div>

This actually means no one knows?? \* gets QotSA music inside head \* 🙂

where are all you ASgurus: LiB, Ilyas, Kax or others??

---

<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:** [April 11, 2003, 8:48pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/9 "2003-04-11T20:48:30Z")

</div>

Problem 1) Since you are loading this in… the \_root is no longer the \_root… it is now a sub timeline of the \_root timeline in the main movie you are loading into.

\_root[“copy”+i].\_x += 50\*x;

Since you are targeting a movie clip to be affected by this prototype, this and \_parent won’t do exactly what you want. So what you need to do is combine them into this.\_parent 😉

Same goes with

\_root.original.duplicateMC();

Except this is locating the target clip, all you have to do is just remove the \_root part.

Problem 2) Not really a problem, more like useless code. You don’t need an onLoad on frame when the actions are supposed to load when the frame loads. By putting them just on the frame thy are told to load when the frame loads… so there is no point to an onLoad for a frame.

[AS]Movieclip.prototype.duplicateMC = function() {  
amount = 16;  
x = 1;  
y = 0;  
for (i=1; i\<amount; i++) {  
//trace(“x:” + x + " y: " + y);  
this.duplicateMovieClip(“copy”+i, i);  
if (i%4 == 0) {  
x = 0;  
y += 1;  
}  
this.\_parent[“copy”+i].\_x += 50_x;  
this.\_parent[“copy”+i].\_y += 50_y;  
x++;  
}  
};  
original.duplicateMC();[/AS]

---

<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:** [April 11, 2003, 9:13pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/10 "2003-04-11T21:13:25Z")

</div>

And because I am SUPER BORED I decided to obfuscate this a bit…

[AS]MovieClip.prototype.duplicateMC = function() {  
this.\_visible=false, amount=16, x=1, y=0;  
for(i=0; i\<amount; i++){mc=this.duplicateMovieClip(“copy”+i, i), i%4==0 ? (x=0, y++) : null, mc.\_x=50_x, mc.\_y=50_y, x++;}  
};  
original.duplicateMC();[/AS]

NOTE: DO NOT use the above code. It is pointless to write it out like that if you dont need to. Obfuscating (compressing the code) is a pain to read and can actually slow down the performance of your code. I did this out of sheer bordom, I just figured if I posted it, then maybe you may learn a trick or two from it 😉

---

<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:** [April 11, 2003, 9:15pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/11 "2003-04-11T21:15:32Z")

</div>

After viewing my obfuscated code, I just realized I did something there that I forgot to post 2 posts ago :hangover:

What I did was assign the duplicate movie clip as a variable called “mc” That way you can reference the duplicated movie clip through “mc”

And y+=1 can be said as y++ as well…

[AS]MovieClip.prototype.duplicateMC = function() {  
amount = 16;  
x = 1;  
y = 0;  
for (i=1; i\<amount; i++) {  
//trace(“x:” + x + " y: " + y);  
mc = this.duplicateMovieClip(“copy”+i, i);  
if (i%4 == 0) {  
x = 0;  
y++;  
}  
mc.\_x += 50_x;  
mc.\_y += 50_y;  
x++;  
}  
};  
original.duplicateMC();[/AS]

---

<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:** [April 12, 2003, 8:39am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/12 "2003-04-12T08:39:37Z")

</div>

Wow, thanks a lot man!

I wish I could come up with stuff like that when I’m superbored 😛

I think I have to study on your obfuscated script: I think I’ll have to study on that a bit before I’ll get it

And the y++ part: :bounce: stupid me!! I should have seen that myself.

Anyway, thanks a lot, I’m happy!

---

<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:** [April 12, 2003, 8:30pm UTC](https://forum.kirupa.com/t/how-to-target-this/17834/13 "2003-04-12T20:30:47Z")

</div>

Glad it helped 🙂

And don’t worry about learning obfuscated script, unless you are going to be in a situation where you have to code something in as little lines as humanly possible, then you don’t need it. It just makes things a pain to read and edit 😛

I posted that method here because I did get bored and I wanted to see how many lines I could get it down to 😛

---

<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:** [April 15, 2003, 1:59am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/14 "2003-04-15T01:59:36Z")

</div>

Lost in beta said  
What I did was assign the duplicate movie clip as a variable called “mc” That way you can reference the duplicated movie clip through “mc”

I am wondering how you “reference” a movie clip so that it is recognized as “mc” or whatever you choose to call it?

---

<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:** [April 15, 2003, 2:22am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/15 "2003-04-15T02:22:02Z")

</div>

When using duplicateMovieClip or attachMovie you do it the way I did above…

[AS]mc = this.duplicateMovieClip(“copy”+i, i);[/AS]

But any other way you just do…

variableName = clipInstanceName

(and don’t forget about \_root, \_parent, this, etc if you need them)

---

<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:** [April 15, 2003, 2:31am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/16 "2003-04-15T02:31:28Z")

</div>

Lost in beta… you’ve been seeing me trying to do this for the last few weeks and I think your aware of my lack of knowlede in scripting beyond lodmovie in this movie clip and button commands. I was wondering if for the next 15 minutes you could help me get this nightmare of a menu figured out in a simplified way.

the outdated menu I have been trying to work with has been confusing me to death… if you cannot recall the menu please visit  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20204](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20204)

If you can help me understand what it is I have to do to get what I could go to sleep at night with my girlfriend instead of leaving her angry at me for staying up all hours of the night.

---

<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:** [April 15, 2003, 2:34am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/17 "2003-04-15T02:34:15Z")

</div>

Sure, I will help.

But I am going to try and rewrite something. That Flash 4 syntax gives me the biggest friggin headache… I got nuts flipping from frame to frame from timeline to timeline just to figure out what does what in that script. It can be so much easier in MX.

---

<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:** [April 15, 2003, 2:44am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/18 "2003-04-15T02:44:16Z")

</div>

I really appretiate your help.  
I’ve been trying to learn actionscript through trial error, copying pasting and applying the effects I see into my sites. I have done well up until this point and I have found things I don’t understand at all like  
prototype  
pathing \_root \_parent (i understand the concept but not the application)  
how to apply different button commands to duplicate movieclips

---

<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:** [April 15, 2003, 3:01am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/19 "2003-04-15T03:01:00Z")

</div>

so is the other thread enough for us to start discussing what is to be done or would you need me to explain step by step what I am aiming for so we figure somthing out… I am under the impression from your last post that your tackling this right away but I am not sure and want to contribute if i can.

---

<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:** [April 15, 2003, 3:15am UTC](https://forum.kirupa.com/t/how-to-target-this/17834/20 "2003-04-15T03:15:12Z")

</div>

Im already almost done coding it. I will explain in step by step detail in your other thread.
