# How to make an AS3 package to call a function in main timeline

**URL:** https://forum.kirupa.com/t/how-to-make-an-as3-package-to-call-a-function-in-main-timeline/214465
**Category:** flash
**Created:** [January 29, 2007, 8:23am UTC](https://forum.kirupa.com/t/how-to-make-an-as3-package-to-call-a-function-in-main-timeline/214465 "2007-01-29T08:23:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![glidealong](https://avatars.discourse-cdn.com/v4/letter/g/da6949/32.png) [@glidealong](https://forum.kirupa.com/u/glidealong)
#### Post date: [January 29, 2007, 8:23am UTC](https://forum.kirupa.com/t/how-to-make-an-as3-package-to-call-a-function-in-main-timeline/214465/1 "2007-01-29T08:23:02Z")

</div>

I am working on AS3 and I have a created a button class which have an off state and on state. I did the class and it works fine, but i need a little fine tuning. Right now I am polling the button state from the root(main timeline) by checking a boolean property in the button class. I feel it is quite inefficient to check the button state on every enterFrame event of the main timeline. Rather I would prefer the button to tell the root time line by invoking a function written in the root, whenever a state change occurs.  
It should be cleaner , right??  
But when I try to access a function in the root which goes like this

function setVertical(button\_name:String):void{  
trace("value of button is "+button\_name);  
}

from the button object, I get the following error

ReferenceError: Error #1069: Property setVertical not found on flash.display.Stage and there is no default value.  
at ICT::genBtn/ICT:genBtn::btnClick()

:sigh:  
Thanks in Advance
