# \[AS2/CS4\] function trouble!

**URL:** <https://forum.kirupa.com/t/as2-cs4-function-trouble/292228>\
**Category:** flash\
**Created:** [July 12, 2009, 12:02am UTC](https://forum.kirupa.com/t/as2-cs4-function-trouble/292228 "2009-07-12T00:02:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cloudiness](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cloudiness](https://forum.kirupa.com/u/cloudiness)\
**Post date:** [July 12, 2009, 12:02am UTC](https://forum.kirupa.com/t/as2-cs4-function-trouble/292228/1 "2009-07-12T00:02:59Z")

</div>

hello everyone!  
i’m having an issue calling a function from a movieclip.  
I have a button that creates a variable and then sends that variable to the root timeline.  
I think that the issue is that the function is looking for the “item” variable on the root timeline.  
here is the code:

```auto

on(press){
     
var item = new CartItem

//description, cost, qty
(DESC, 100.00, 1);
_parent.additem(item);
}

```

when I have this button on the main timeline everything works alright, though when its in a movieclip it returns “undefined” This is all apart of a shopping cart i’m working on.

does anybody have any thoughts or suggestions? I would really appreciate any help I can get. Many thanks in advance!
