PDA

View Full Version : basic movie event



zeff
July 18th, 2008, 04:14 AM
Hello Guys,
I'm new to AS3 and i couldn't solve this very simple error
ReferenceError: Error #1069: Property labeltxt not found on flash.text.TextField and there is no default value. at testas_fla::MainTimeline/button_ss()

for the button_out and button_hover it was working fine but the button_click
raise the above error message

this is my code

function button_hover(evt:Event):void{
evt.target.labeltxt.text="HOVER";

}
function button_out(evt:Event):void{
evt.target.labeltxt.text="HOUT";

}

function button_click(evt:Event):void{
evt.target.labeltxt.text="HOUT";
}

tmp_btn.addEventListener(MouseEvent.ROLL_OVER,butt on_hover);
tmp_btn.addEventListener(MouseEvent.CLICK,button_c lick);
tmp_btn.addEventListener(MouseEvent.ROLL_OUT,butto n_out);

Favardin
July 19th, 2008, 07:48 AM
Hello Guys,
I'm new to AS3 and i couldn't solve this very simple error
ReferenceError: Error #1069: Property labeltxt not found on flash.text.TextField and there is no default value. at testas_fla::MainTimeline/button_ss()

for the button_out and button_hover it was working fine but the button_click
raise the above error message

this is my code

function button_hover(evt:Event):void{
evt.target.labeltxt.text="HOVER";

}
function button_out(evt:Event):void{
evt.target.labeltxt.text="HOUT";

}

function button_click(evt:Event):void{
evt.target.labeltxt.text="HOUT";
}

tmp_btn.addEventListener(MouseEvent.ROLL_OVER,butt on_hover);
tmp_btn.addEventListener(MouseEvent.CLICK,button_c lick);
tmp_btn.addEventListener(MouseEvent.ROLL_OUT,butto n_out);

You should be a bit more specific. How does your setup look like? How is tmp_btn composed?
I guess you created a button with an textfield inside of it. Try



var label:TextField = evt.target.getChildByName( "labeltxt" );
label.text = "HOUT";


for the events.

stringy
July 19th, 2008, 09:36 AM
it looks like your textfield is the Event objects target(if you are clicking on a textfield within a sprite then it will)
try using

evt.currentTarget.labeltxt.text="HOUT";

zeff
July 21st, 2008, 03:23 AM
it looks like your textfield is the Event objects target(if you are clicking on a textfield within a sprite then it will)
try using
ActionScript Code:

evt.currentTarget.labeltxt.text="HOUT";




Wow your code works like magic. thanks