Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何在不丢失Flex格式的情况下替换RichTextEditor文本_Actionscript 3_Flash_Apache Flex_Actionscript_Rich Text Editor - Fatal编程技术网

Actionscript 3 如何在不丢失Flex格式的情况下替换RichTextEditor文本

Actionscript 3 如何在不丢失Flex格式的情况下替换RichTextEditor文本,actionscript-3,flash,apache-flex,actionscript,rich-text-editor,Actionscript 3,Flash,Apache Flex,Actionscript,Rich Text Editor,在我的ActionScript代码中,我使用richTextEditor执行以下操作 protected function createEmailTemplateContent(subRecord:String = null):void{ var index:int = emailTemplateContent.selection.beginIndex; if(subRecord != null){ emailTemplateContent.text = emailTemplateCon

在我的ActionScript代码中,我使用richTextEditor执行以下操作

protected function createEmailTemplateContent(subRecord:String = null):void{
var index:int = emailTemplateContent.selection.beginIndex;
if(subRecord != null){
    emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem.toString().substring(0,insertFieldDD.selectedItem.toString().indexOf('(+)')-1) +  '].[' + subRecord + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}else{
    emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}
}
<component:RichTextEditorWithAllControls id="emailTemplateContent" dropShadowVisible="false" creationComplete="emailTemplatesContentInit()" headerHeight="0" width="100%" height="100%" htmlText="@{emailTemplateObject.emailContent}" showControlBar="false" verticalScrollPolicy="auto"/>
当用户从下拉列表中选择项目时,将实现上述方法。然后,该特定项将填充在富文本编辑器的文本区域内

我的问题是,如果用户已经对文本进行了一些格式化(使用RichTextEditor中的格式化选项),那么当用户选择一个项目并填充文本区域时,这些内容也会被替换

在这里,“emailTemplateContent”是指RichTextEditor。我已将RichTextEditor代码包含在以下内容中

protected function createEmailTemplateContent(subRecord:String = null):void{
var index:int = emailTemplateContent.selection.beginIndex;
if(subRecord != null){
    emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem.toString().substring(0,insertFieldDD.selectedItem.toString().indexOf('(+)')-1) +  '].[' + subRecord + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}else{
    emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}
}
<component:RichTextEditorWithAllControls id="emailTemplateContent" dropShadowVisible="false" creationComplete="emailTemplatesContentInit()" headerHeight="0" width="100%" height="100%" htmlText="@{emailTemplateObject.emailContent}" showControlBar="false" verticalScrollPolicy="auto"/>

我假设发生这种情况是因为当我在richTextEditor中填充“text”值时,“htmlText”值也会被替换

有人知道克服这个问题的方法吗


提前感谢。

首先将连接的文本存储在字符串中,然后将其替换为html文本。像下面这样

protected function createEmailTemplateContent(subRecord:String = null):void{
  var index:int = emailTemplateContent.selection.beginIndex;
  var newText:String;
  if(subRecord != null){
    newText = emailTemplateContent.text.substring(0,index) 
    + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem.toString().substring(0,insertFieldDD.selectedItem.toString().indexOf('(+)')-1) +  '].[' + subRecord + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
  }else{
    newText = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
  }
  emailTemplateContent.htmlText = emailTemplateContent.htmlText.replace(emailTemplateContent.text, newText);
}

您是否可以添加显示格式化文本的屏幕截图,以及从下拉列表中选择项目后会发生什么情况?