元素的前缀未绑定 [英] Prefix for element not bound

查看:1382
本文介绍了元素的前缀未绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Flex开发中的新手,并使用带有SDK 4的Flash Builder 4.现在,我得到错误,在元素fx:Style的前缀fx没有绑定在行号4中。
我搜查了它,它有某事。我不能自己解决它。



我在名为组件的目录中有一个名为UserStory.mxml的文件, main.mxml到屏幕上:

 < fx:Script> 
<![CDATA [
import components.UserStory;
private function init():void {
var userStory1:UserStory = new UserStory();
userStory1.x = 100;
userStory1.y = 100;

userStory1.userStoryText =test;

this.addChild(userStory1);
}
]]>
< / fx:Script>

错误发生在第no行的文件。 4:

 <?xml version =1.0encoding =utf-8?> 

< fx:Style source =styles / styles.css/>


< mx:Script>
...
< / mx:Script>
< / mx:Canvas>

有人可以告诉我什么是错的吗?

解决方案

正如你怀疑这是命名空间的问题。 MXML只是XML,在XML中可以定义名称空间并将其绑定到URL。命名空间是XML元素冒号前面的部分,通常在封闭元素上定义。



如果您查看MXML文件,您将看到 mx 命名空间的一个命名空间声明:

 < mx:Canvas xmlns:mx =http://www.adobe.com/2006/mxml... 

fx 的声明丢失,这就是编译器抱怨。添加适当的定义,您应该没问题(请参阅此页更多细节):

 < mx:Canvas xmlns:fx =http://ns.adobe.com/mxml/另外,如果您使用的是Flex 4,您应该查看文件为 mx:Canvas 是一个Flex 3组件,因此在Flex 4应用程序中不能直接使用。查看 API Flex 4 SDK的Canvas文档 

I am a newbie in Flex development and using Flash Builder 4 with SDK 4. Now I get the error that "the prefix "fx" for element "fx:Style" is not bound" in line number 4. I searched for it, and it has sth. to do with namespaces, but I can not solve it by myelf.

I have the file called "UserStory.mxml" in the directory "components" to place it via the main.mxml onto the screen:

<fx:Script>
    <![CDATA[
        import components.UserStory;
        private function init():void {
            var userStory1:UserStory = new UserStory();
            userStory1.x = 100;
            userStory1.y = 100;

            userStory1.userStoryText = "test";

            this.addChild(userStory1);
        }
    ]]>
</fx:Script>

The file in which the error occurs in line no. 4:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="150" styleName="userstory">

    <fx:Style source="styles/styles.css"/>

    <fx:Text x="5" y="5" width="275" height="135" text="{userStoryText}" fontFamily="notes" fontSize="18"/>

    <mx:Script>
        ...
    </mx:Script>
</mx:Canvas>

Can someone tell me what's wrong?

解决方案

As you suspected it is a problem with the namespace. MXML is just XML and in XML you can define namespaces and bind them to a URL. The namespaces are the part before the colon of an XML element and are usually defined on the enclosing element.

If you look at your MXML file you'll see one namespace declaration for the mx namespace:

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" ...

The declaration for fx is missing and that's what the compiler complains about. Add the appropriate definition and you should be fine (see this page for more details):

<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" ...

Also, if you are using Flex 4 you should review the file as mx:Canvas is a Flex 3 component and as such not directly usable in Flex 4 apps. Have a look at the API docs of Canvas for the Flex 4 SDK.

这篇关于元素的前缀未绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆