protected function buildScriptText()
    {
        $controlId  = Builder::escapeText($this->control->getId());
        $scriptText = '';
        $closeBlock = false;
        if (ScriptLabel::isEventLabel($this->labelName)) {
            $scriptText .= "
if (Event.ControlId == {$controlId}) {
declare Control <=> Event.Control;";
            $closeBlock = true;
        } else {
            $scriptText .= "
declare Control <=> Page.GetFirstChild({$controlId});";
        }
        $class      = $this->control->getManiaScriptClass();
        $name       = preg_replace('/^CMl/', '', $class, 1);
        $scriptText .= "
declare {$name} <=> (Control as {$class});
";
        $scriptText .= $this->scriptText . "
";
        if ($closeBlock) {
            $scriptText .= "}";
        }
        return $scriptText;
    }