# Declaring variable in dynamically created movieclip

**URL:** <https://forum.kirupa.com/t/declaring-variable-in-dynamically-created-movieclip/261413>\
**Category:** flash\
**Created:** [May 27, 2008, 12:29pm UTC](https://forum.kirupa.com/t/declaring-variable-in-dynamically-created-movieclip/261413 "2008-05-27T12:29:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![geter712](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@geter712](https://forum.kirupa.com/u/geter712)\
**Post date:** [May 27, 2008, 12:29pm UTC](https://forum.kirupa.com/t/declaring-variable-in-dynamically-created-movieclip/261413/1 "2008-05-27T12:29:39Z")

</div>

Ok I know AS3 i the biggest craaa\*p ever but this is really insane !!Ⓜ  
I’ve tried to declare variable named ‘var\_1’ inside of dynamically created movie clip ‘movie\_clip\_1’ and since ‘i’ is loop variable (‘i’ value is 1) I was trying to do it this way:

getChildByName(‘movie\_clip\_’+i).var\_1=5

stupid program gives me an error saying :

\*1119: Access of possibly undefined property bar through a reference with static type flash.display:DisplayObject.  
\*  
WTF!!?? I was totally pissed off and I was trying to do it this way: movie\_clip\_1.var\_1=5 and it worked. Then after few hours seeking for solution (was also trying as2 command ‘set’ but it seems to be no longer available) I’ve randomly tried:

getChildByName(‘movie\_clip\_’+i)[‘var\_1’]=5

and it worked!! Unfuc\*ing believable stupid and doesn’t make any sense. Is it only me thinking that way or this AS3 is totally weird??!!
