flashflash-cc

The name property of a Timeline-placed object cannot be modified


I'm having this error in

Error: Error #2078: The name property of a Timeline-placed object cannot be modified.
    at flash.display::DisplayObject/set name()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()

My code is the following:

import flash.events.MouseEvent;

stop();

name.label = "Please, enter your name...";

enter.label = "Enter";

enter.addEventListener(MouseEvent.CLICK, submitName);

function submitName(pEvent: MouseEvent): void {
    var myVariable = name.text;
    output.text = "Thanks for your help, " + myVariable;
}

The program should take a name in a textbox and return it in a dynamic text instance when a button is pressed. Thanks for your help.


Solution

  • You can not use name as a name of any object ( component, variable, ... ) because it refers to the name of your MainTimeline ( root ).

    So to avoid that error, you have to change the name of the component that you've inserted to the stage.

    Don't forget also to avoid using keywords and reserved words reserved for use by ActionScript.

    Hope that can help.