# ENTER\_FRAME's 1 parameter limit

**URL:** <https://forum.kirupa.com/t/enter-frames-1-parameter-limit/259325>\
**Category:** flash\
**Created:** [May 3, 2008, 1:33pm UTC](https://forum.kirupa.com/t/enter-frames-1-parameter-limit/259325 "2008-05-03T13:33:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gggmork](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@gggmork](https://forum.kirupa.com/u/gggmork)\
**Post date:** [May 3, 2008, 1:33pm UTC](https://forum.kirupa.com/t/enter-frames-1-parameter-limit/259325/1 "2008-05-03T13:33:21Z")

</div>

Maybe I’m looking at it the wrong way but I seem to quite often want to have more parameters than just a single function to respond to an event listener… I read this:  
[http://www.darronschall.com/weblog/archives/000191.cfm](http://www.darronschall.com/weblog/archives/000191.cfm)  
but that seems like a super advanced non-newbie friendly hack for something that seems like it would often be needed.

```auto

var myRect = new(rectangle)
stage.addChild(myRect)

moveRect(myRect, 'down', 10) 
/*Here I'd want to make an encapsulated function that, with these parameters at least, would move the rectangle downward 10 times AT THE SPEED OF THE FRAME RATE (1 pixel each time). But once you bring frame rate into the picture, you have to use an ENTER_FRAME listener which only accepts ONE event parameter thus screwing up the parameter structure of the function you're trying to build */

```

I was able to make a movieclip on the stage move around in the shape of a square, but it is a long way that probably needs encapsulation. If you try to encapsulate though you run into stupid single-parameter-only event problems:

```auto

var myRect = new(rectangle);
//udlr stands for up down left or right
var udlr = 'd';
var counter = 0;
stage.addChild(myRect);
stage.addEventListener(Event.ENTER_FRAME, moveRect);
function moveRect(e) {
    if (udlr == 'd') {
        myRect.y +=1;
        if (counter>=10) {
            udlr = 'r';
            counter = 0
        }
    }
    if (udlr == 'r') {
        myRect.x +=1;
        if (counter>=10) {
            udlr = 'u';
            counter = 0
        }
    }
    if (udlr == 'u') {
        myRect.y -=1;
        if (counter>=10) {
            udlr = 'l';
            counter = 0
        }
    }
    if (udlr == 'l') {
        myRect.x -=1;
        if (counter>=10) {
            udlr = 'd';
            counter = 0
        }
    }
    counter++
}

```
