Error #1034: Type Coercion failed: cannot convert flash.text::TextField@1182e101 to flash.display.MovieClip

StackOverflow https://stackoverflow.com/questions/18792830

  •  28-06-2022
  •  | 
  •  

Question

I am fairly new to actionscript 3.0, and I keep getting the error above. My code is

stop();
Lamp.addEventListener(MouseEvent.CLICK,lookatlamp);
function lookatlamp(event:MouseEvent){
Dialogue.text = "It is a very bright lamp. It hurts your eyes.";
}
Room.addEventListener(MouseEvent.CLICK,standup);
function standup(event:MouseEvent){
gotoAndStop(2);
}

Frame 2:

stop();
Table.addEventListener(MouseEvent.CLICK,lookatthetable);
function lookatthetable(event:MouseEvent){
gotoAndStop(4);
}
FirstDoor.addEventListener(MouseEvent.CLICK,gotonextroom);
function gotonextroom(event:MouseEvent){
gotoAndStop(3);
}

frame 3:

stop();
Inspctdr.addEventListener(MouseEvent.CLICK,lookatthedoor);
function lookatthedoor(event:MouseEvent){
Dialogue.text = "It is a metal door with a shiny silver handle.";
}

and the full error is:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.text::TextField@119c83d1 to flash.display.MovieClip.

at flash.display::MovieClip/gotoAndStop()
at Untitled_fla::MainTimeline/standup()

and

TypeError: Error #1034: Type Coercion failed: cannot convert flash.text::TextField@119c8449 to flash.display.MovieClip.

at flash.display::MovieClip/gotoAndStop()
at Untitled_fla::MainTimeline/lookatthetable()

what did I do wrong?

Was it helpful?

Solution

Looks like Dialogue is not a textField. Is Dialogue a MovieClip with a textfield inside? If so, give the textField inside an instance name like tf.

Then set the text like:

Dialogue.tf.text = 'some text';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top