# Flex/AS3 casting question

**URL:** <https://forum.kirupa.com/t/flex-as3-casting-question/225437>\
**Category:** flash\
**Created:** [May 11, 2007, 7:05pm UTC](https://forum.kirupa.com/t/flex-as3-casting-question/225437 "2007-05-11T19:05:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![silverg](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@silverg](https://forum.kirupa.com/u/silverg)\
**Post date:** [May 11, 2007, 7:05pm UTC](https://forum.kirupa.com/t/flex-as3-casting-question/225437/1 "2007-05-11T19:05:47Z")

</div>

I am having a hard time coming from another programming mentality here. I am trying to reference an object using a variable passed to a handler. the string as it seems (datatype) is correct, but I cant figure out how to define it as an object reference.

The problem here is, [event.item.@data](mailto:event.item.@data) when outputed as a string is “networkPanel” which i want. But I need to somehow, and i dont know the command to do so… but if it existed

thisIsaObject([event.item.@data).visible](mailto:event.item.@data).visible) = whatever;

```auto
private var menubarXML:XMLList =
                <>
                    <menuitem label="Applications" data="top">
                        <menuitem label="Network Status" data="networkPanel"/>
                    </menuitem>
                </>;
            // Event handler to initialize the MenuBar control.
            private function initCollections():void {
                menuBarCollection = new XMLListCollection(menubarXML);
            }
            // Event handler for the MenuBar control's itemClick event.
             private function menuHandler(event:MenuEvent):void{
                //If i change event.item.@data to networkPanel - this works.
                 if (event.item.@data == true)
                 {
                  event.item.@data.visible = false;
                 }
                 else
                 {
                  event.item.@data.visible = true;                  
                 }            
            }

```
