# String to MC name

**URL:** <https://forum.kirupa.com/t/string-to-mc-name/234834>\
**Category:** Uncategorized\
**Created:** [August 6, 2007, 3:45pm UTC](https://forum.kirupa.com/t/string-to-mc-name/234834 "2007-08-06T15:45:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrndMasterFlash](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@GrndMasterFlash](https://forum.kirupa.com/u/GrndMasterFlash)\
**Post date:** [August 6, 2007, 3:45pm UTC](https://forum.kirupa.com/t/string-to-mc-name/234834/1 "2007-08-06T15:45:10Z")

</div>

i have almost go it working where you click a button and an item inside a MC with the same name gets it visibility toggled. however it seems flash won’t convert my string to a MC name, i have tried lots of things, and need some outside input cause this has me stumped, and i need to get back to being productive:!:

```auto
import flash.display.*;
import flash.events.*;
import flash.ui.Keyboard;
var part:MovieClip;
var witch:String;

function clickbh01(event:MouseEvent) {
    witch = event.currentTarget.name;
    player[part] = player.name+"."+witch;
    trace(player[part]);
    vistoggle(player[part]);

}

player.h01.alpha = .0;
player.h02.alpha = .0;
player.b01.alpha = .0;
player.gotoAndStop(1);

h01.addEventListener(MouseEvent.MOUSE_DOWN, clickbh01);

function vistoggle(part:MovieClip) {
    if (part.alpha == .0) {
        part.alpha = 1;
    } else {
        if (part.alpha == 1) {
            part.alpha = .0;
        }
    }
}

```

any help would be greatly appreciated :+)

almost forgot here is the output error i get

//output  
player.h01  
TypeError: Error #1034: Type Coercion failed: cannot convert “player.h01” to flash.display.MovieClip.  
at itmeslecttemp\_fla::MainTimeline/clickbh01()
