# Passing entire doc class as function argument -- good or bad?

**URL:** <https://forum.kirupa.com/t/passing-entire-doc-class-as-function-argument-good-or-bad/296042>\
**Category:** flash\
**Created:** [September 8, 2009, 11:54pm UTC](https://forum.kirupa.com/t/passing-entire-doc-class-as-function-argument-good-or-bad/296042 "2009-09-08T23:54:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xgraves](https://avatars.discourse-cdn.com/v4/letter/x/7cd45c/32.png) [@xgraves](https://forum.kirupa.com/u/xgraves)\
**Post date:** [September 8, 2009, 11:54pm UTC](https://forum.kirupa.com/t/passing-entire-doc-class-as-function-argument-good-or-bad/296042/1 "2009-09-08T23:54:02Z")

</div>

I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I’m wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.

EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER\_FRAME scrolling function that’s 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it’s impractical. So my question is: good or bad practice to pass the entire class?

```auto
// in app or doc class
this.addEventListener(Event.ENTER_FRAME, scroll_me);
public var scroll_me(evt:Event):void {
   // Scroller.as now has the long scrolling function 
   Scroller(this); // Really?!?!
}

```
