# attachMovie and new variables driving me crazy

**URL:** <https://forum.kirupa.com/t/attachmovie-and-new-variables-driving-me-crazy/313894>\
**Category:** Uncategorized\
**Created:** [September 13, 2010, 9:00am UTC](https://forum.kirupa.com/t/attachmovie-and-new-variables-driving-me-crazy/313894 "2010-09-13T09:00:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geodeath](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@geodeath](https://forum.kirupa.com/u/geodeath)\
**Post date:** [September 13, 2010, 9:00am UTC](https://forum.kirupa.com/t/attachmovie-and-new-variables-driving-me-crazy/313894/1 "2010-09-13T09:00:51Z")

</div>

Hi all!

I am surprised at the following code not working, as it has worked time and again in the past… no wonder i love as3 way more than as2. At the following code, the problem is that i am declaring a variable at a newly created movieclip through attachmovie but it will not be available in the loader events and neither will it show as a variable at the debug window when i select the movieclip…

```auto

myListener.onLoadInit = function (trgt:MovieClip) {
	trace(trgt.loadId);
}

Xml.onLoad = function(success) {
	//blah blah
        for (i=0; i<total; i++) {
		entry = body.attachMovie("viewer_big","p"+i,i);
		myLoader.loadClip("xml image path", entry);
		//here lies the problem
                entry.loadId = i;
	}
}

```

Now, why exactly the above wont run correctly or why the debug window wont show the variable is a mystery to me. I always handled situations like that so that created movieclips can have their own properties like colors, some text etc. I even tried writting “var loadId:Number = 1;” in the movie clip in the library too, but it still wont show up or trace. All i get is undefined!

Am i missing something here?

George
