# Passing a movieclip object as variable

**URL:** https://forum.kirupa.com/t/passing-a-movieclip-object-as-variable/314154
**Category:** flash
**Created:** [September 20, 2010, 2:37pm UTC](https://forum.kirupa.com/t/passing-a-movieclip-object-as-variable/314154 "2010-09-20T14:37:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rayarman](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@rayarman](https://forum.kirupa.com/u/rayarman)
#### Post date: [September 20, 2010, 2:37pm UTC](https://forum.kirupa.com/t/passing-a-movieclip-object-as-variable/314154/1 "2010-09-20T14:37:47Z")

</div>

Hi!

This is my first post here so Hello! :mountie:

I’m relatively new to Flash and ActionScript and have a problem with the following code i’m putting together:

```auto

// creating a new testmclip object

var testmclip = new testmclip(); // creating a new testmclip object

/* create a new pop up menu
- sending the testmclip as var and "test" as label */

popupmenu = new Menu ([path: testmclip, label: "test"]);

//the menu class creates itself and adds itself to the stage

public function Menu (items:Array)
{
     _items = items;
     // does other stuff to add itself to stage
}

/*- it then takes the path and label and creates a new MenuItem as child of itself */

var itemone = new MenuItem(_items[0].path, _items[0].label);
addChild(itemone);

/* the MenuItem class takes the path and label and returns itself with the path and label as its children */

public function MenuItem(path,label:String)
{
     _path=path;
    field.text=label;

}

/* the following is the code where I need help.....
Once addedtostage --> MenuItem takes the path (which should be the testmclip object) and adds it as its child */

addChildat( _path, numChildren - 1);

```

The above doesn’t work.

I’m trying to send a movieclip object created in one class, to a different class - for the latter class to add as it’s child.

The code was originally Kevin Hoyts Android Component for Menu and MenuItem ([http://blog.kevinhoyt.org/?p=548](http://blog.kevinhoyt.org/?p=548)) … but in that the path for the menuitem was a path which loaded from url or relative path --\> this I can’t do with flash…I think.

Any help appreciated!

Ray
