# Pass value to Public variable?

**URL:** <https://forum.kirupa.com/t/pass-value-to-public-variable/287316>\
**Category:** flash\
**Created:** [April 29, 2009, 12:08pm UTC](https://forum.kirupa.com/t/pass-value-to-public-variable/287316 "2009-04-29T12:08:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonOfChaos](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@SonOfChaos](https://forum.kirupa.com/u/SonOfChaos)\
**Post date:** [April 29, 2009, 12:08pm UTC](https://forum.kirupa.com/t/pass-value-to-public-variable/287316/1 "2009-04-29T12:08:51Z")

</div>

Okay, finally have a working hitTest (YAY!!!), now, my code is setup to create 3 ‘sasquatches’, the problem is for the hitTest to work, the variable “one” has to be public. Now, in the next bit of code we create 3 instances of one using a for loop, BUT they all three are in the same spot cause I can’t figure out how to pass Random numbers to the variable each time it creates, know what I mean? Help…

```auto
package{
    
    import flash.display.*;
    import flash.events.*;
    
    public class SQD extends MovieClip{
        public var squatchArray:Array = new Array();
        public var one:Sasquatch = new Sasquatch();
        
        public function SQD(){
            stage.addEventListener(MouseEvent.MOUSE_DOWN, attack);
            trace('working');
            for(var i:int =0; i<3; i++){
            addChild(one);
            squatchArray.push(one);
            trace(squatchArray);
            }
        }
        public function attack(mouseEv:MouseEvent){
            trace('attacking');
            for(var t:int = 0; t <=squatchArray.length; t++){
                if(one.hitTestPoint(mouseEv.stageX, mouseEv.stageY, true)){
                    trace('you be dead')
                }
            }
        }
    }
}

```
