Ultrashock Forums > Flash > ActionScript
Help with MC Visibility

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Help with MC Visibility
Old 2010-02-03 Last edited by m2244 : 2010-02-04 at 04:46.

What I am trying to do is capture the name of the button which is clicked and add "hl" to it, which is the name of another movieclip already on stage. This works. Then with that modified name I want to set the visibility of that movieclip, ie popUp0hl, to true. This is not working. None of these MCs are created dynamically by the way.

I hope this makes sense. Here is some code. Line 2 is the problem

var highLight:String = evt.currentTarget.name + "hl";
this[highlight].visible = true;

Thanks in advance

MH
postbit arrow 5 comments | 143 views postbit arrow Reply: with Quote   
Registered User
m2244 is offline
seperator
Posts: 3
2009-12-07
m2244 lives in United States
seperator

Ultrashock Member Comments:
JimTester's Avatar JimTester JimTester is offline JimTester lives in United Kingdom 2010-02-04 #2 Old  
m2244

Could that lowercase/uppercase "L" in highLight / highlight be your problem?
Reply With Quote  
m2244 m2244 is offline m2244 lives in United States 2010-02-04 #3 Old  
Quote: Originally Posted by JimTester View Post
m2244

Could that lowercase/uppercase "L" in highLight / highlight be your problem?
No. I tried to edit that after I posted it but the change does not show up for some reason. Good eye though. I do not understand why this is not working. Damn it!
Reply With Quote  
JimTester's Avatar JimTester JimTester is offline JimTester lives in United Kingdom 2010-02-04 #4 Old  
Ok - let's take a small step back so that I (being a thicko) can get a definite understanding of your setup.

Am I right in thinking that you have 2 MCs on stage? One called "popUp0" and one called "hl"?
Is there an MC on stage anywhere called "popUp0hl"?
Reply With Quote  
m2244 m2244 is offline m2244 lives in United States 2010-02-08 #5 Old  
I appologize for the confusion here. I have a botton named popUp0 and a MC named popUp0hl. When the user clicks on the button popUp0 I want to take that name and and "hl" so that I then have the name of the MC I want to control. By the way I have multiple instances ie, popUp0, popUp1, popUp2, etc. So what I did was to create 2 arrays, one with the names of the buttons and the other with the names of the MCs and use the index of one to referrence the other giving me the corresponding MC for that button. But what I wanted to do was take the evt.target.name and add "hl" on to it. This worked but the this[highlight].visible = true; does not. Thanks man.
Reply With Quote  
JimTester's Avatar JimTester JimTester is offline JimTester lives in United Kingdom 2010-02-09 #6 Old  
Ok cool - I think I understand. I think you need to use getChildByName to get hold of the MovieClip and also cast it as a MovieClip. Try this:

Code:
popUp1.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownBtn);
popUp2.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownBtn);
popUp3.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDownBtn);


function onMouseDownBtn(me:MouseEvent):void{
	//trace(me.target.name);	
	
	var btnName:String = me.target.name;
	var mcName:String = btnName + "_mc";
	var mc:MovieClip = getChildByName(mcName) as MovieClip;
	
	mc.visible = false;
}
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: