PDA

View Full Version : getproperty(target,_name)


whos_wee_dug
09-22-2003, 02:35 PM
Hi board,

I've got a button on Scene and the following code applies to it:

on(press)
{
myvar=getProperty ( target, _name);
}
//end code

What I want is when the button is clicked the variable "myvar" changes to the name of the instance of the button. However, all I get is "". I have given a name to my instance.

If anyone could explain why this has went wrong I'd like to know!

Cheers,

whos_wee_dug.

junahu
09-22-2003, 02:52 PM
Have you given an instance name to the button? I not, give an instance name to your button.

whos_wee_dug
09-22-2003, 03:09 PM
Yeh, thats what i thought my problem might have been, but no i checked and it does have a name :confused:

Here's a link to the fla to see if anyone can shed some light on the subject :D

http://www.warmwire.co.uk/test.fla

junahu
09-23-2003, 10:17 AM
I've downloaded your file and I'll see if I can find the problem by tommorrow ok?

whos_wee_dug
09-23-2003, 01:24 PM
Thats great, thanks for ur input :D I think it will be easy to solve when a more experienced flash developer looks at my source.

whos_wee_dug.

spriggan
09-23-2003, 02:24 PM
First change your button type to movie clip, you can do this with the drop down menu above where the intance name is. Then add

on(press)
{
_root.myvar=this._name;
}

//or though the top way is preferable in MX+
on(press)
{
_root.myvar=getProperty ( this, _name);
}



note this wont work if you've got flash 5 or lower.

junahu
09-24-2003, 09:03 AM
I fixed it (unless you're using flash 4 or lower). I did pretty much what the post above said. In your code you didn't specify the target that you wanted the property of. I encased the button in a movie clip and gave it the instance name that the button had then deleted the instance name of the button. But the main thing is that it works.

junahu
09-24-2003, 09:11 AM
But I can't post *.fla files here and I don't have a webpage. I'll have to send it to you. But I don't know your e-mail. Any way around this?:confused:

spriggan
09-24-2003, 11:20 AM
zip the fla, then you can post it here.

junahu
09-24-2003, 12:53 PM
Smart. Here it is then

whos_wee_dug
09-25-2003, 09:24 AM
That wrks great guys, thanks both of you. It seems a bit stupid why the instance of the button can't be taken to me, but making it a movie clip is a good, simple solution.

Cheers,

whos_wee_dug.