# Dynamic linkage id in Object.registerClass ? How?

**URL:** https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573
**Category:** flash
**Created:** [August 13, 2002, 4:14pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573 "2002-08-13T16:14:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Spongebob](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Spongebob](https://forum.kirupa.com/u/Spongebob)
#### Post date: [August 13, 2002, 4:14pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/1 "2002-08-13T16:14:09Z")

</div>

Hi there,

Anybody knows a way of setting the linkage identifier of the movie clip symbol in the Object.registerClass dynamically?

If I write “LinkageId” between " " it works fine…  
[COLOR=blue]Object.registerClass( **“LinkageId”** ,MyClass);[/COLOR]

BUT if I don’t use " " and try to set the contents of a variable, it doesn’t work ☹

[COLOR=red]  
**myLinkId** = “XXX”;  
Object.registerClass( **myLinkId** ,MyClass);[/COLOR]

I’ve already tried to concatenate " " to myLinkId and it still doesn’t work…

I need to dynamically register lots of MCs to myClass ☹  
Anybody has a tip on how to do it ?

Thanks in advance,  
Spongebob.

---

<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: [August 14, 2002, 4:35pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/2 "2002-08-14T16:35:28Z")

</div>

Anybody … ? Please help me on this subject…☹  
Any tip I can try will be helpful…

Thanks,  
Spongebob

---

<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: [August 14, 2002, 5:09pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/3 "2002-08-14T17:09:55Z")

</div>

Why do you always come up with tough questions like that? 😛  
I’ve never actually programmed components, so I don’t have your answer, but I’ll try and ask my Chinese master, he may know.

pom :asian:

---

<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: [August 14, 2002, 5:27pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/4 "2002-08-14T17:27:24Z")

</div>

Sorry :-\  
I’ve lately came up with these strange things …, haven’t I ?

I hope this is the last thing I cannot solve by myself 🙂

Thanks for your and your master’s help =)

```
   Spongebob.
```

---

<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: [August 15, 2002, 12:37am UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/5 "2002-08-15T00:37:20Z")

</div>

i was unable to get this method to work with anything aside from exported library assets. i’m not sure it that’s the intention or i was just doing it wrong.

are you able to set a particular movie clip’s class with this method?

with library assets though, it worked happily with or without variables. i exported an asset under the name “sqr” from the library and this code worked fine:

```auto

function Classy(){
	this.class = "Classy";
	this.onMouseUp = function(){ trace("i'm classy!"); };
};

item = "sqr";

Object.registerClass(item,Classy);

_root.attachMovie("sqr","square",0);

```

i’m thinking that you’re trying to do something a little different but i’m not sure what.

for a heavy read, you could browse dave yang’s site on oop in flash.  
[http://www.quantumwave.com/flash/](http://www.quantumwave.com/flash/)

---

<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: [August 15, 2002, 1:40pm UTC](https://forum.kirupa.com/t/dynamic-linkage-id-in-object-registerclass-how/4573/6 "2002-08-15T13:40:10Z")

</div>

Great sbeener ! =)

This is exactly what I’m trying to do!, worked marvellous!

I now know what I was doing wrong :\*(

I was trying to register the item with the class right after the attachMovie sentence !! I’m such a #?$#"&% !! ☹

Thank you very much for your help!  
Regards,  
Spongebob.
