本文介绍了Flex自定义组件不接受脚本:默认属性“文本”,“字符串”类型的多个初始值设定项值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Flex 4和Flash Builder 4.我只是想学习创建组件,我创建了一个mxml组件,并将其包含在我的应用程序中:

 <?xml version =1.0encoding =utf-8?> 
xmlns:s =library://ns.adobe.com/flex/spark
xmlns:mx =library://ns.adobe.com/flex/mx>
< fx:Script>
< / fx:Script>
< / s:TextInput>

如果我将fx:Script标签取出,但只要有这些标签不管是否有实际的代码在那里)我得到的错误:Flex自定义组件不接受脚本:默认属性,'文本','字符串'类型的多个初始值。

为什么会这样呢?是不是在组件允许脚本?

解决方案

这是一个已知的bug 。里程碑是下一个Flex SDK英雄版本。如果您明确设置了 text 属性,您仍然可以使用mxml。

 <?xml version = 1.0encoding =utf-8?> 
xmlns:s =library://ns.adobe.com/flex/spark
xmlns:mx =library://ns.adobe.com/flex/mx
text =>
< fx:声明>
< / fx:声明>
< / s:TextInput>

谢谢。


I'm using Flex 4 and Flash Builder 4. I just want to learn to create components and I created an mxml component as follows and included it in my application:

<?xml version="1.0" encoding="utf-8"?>
<s:TextInput xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
    </fx:Script>
</s:TextInput>

If I take out the fx:Script tags it works, but as soon as I have those tags (regardless of whether any actual code is in there) I get the error: "Flex custom component doesn't accept script: Multiple initializer values for default property, 'text', of type 'String'."

Why would that be? Is script not allowed in components?

解决方案

this is a known bug SDK-25184. Milestone is the next Flex SDK Hero Release. You still can use mxml if you explicitly set the text property.

<?xml version="1.0" encoding="utf-8"?>
<s:TextInput xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx"
             text="">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
</s:TextInput>

Thanks.

这篇关于Flex自定义组件不接受脚本:默认属性“文本”,“字符串”类型的多个初始值设定项值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:59