自定义组建中使用layout出错解决方法
自定义组建中使用layout出错
代码如下;
其中以Custom*打头的组建都是我自定义的,此时编译出错,错误信息为:
无法将“<s:layout>”解析为组件执行。
当我将“components:CustomNavigatorContent”替换为“s:NavigatorContent”时就没问题了,其中:
public class CustomNavigatorContent extends NavigatorContent
{}
请问这是为何,我该如何让自定义的CustomNavigatorContent也能进行布局?
------解决方案--------------------
这样修改试试 把s改为container
<container:SuperTabNavigator id="superTab" x="0" y="0" width="100%" height="100%">
<components:CustomNavigatorContent label="{rootTabName}" width="70%" height="100%">
<container:layout>
<container:VerticalLayout/>
</container:layout>
<components:CustomDataGrid width="100%" height="50%"/>
<components:CustomLineChart width="100%" height="50%"/>
</components:CustomNavigatorContent>
</container:SuperTabNavigator>
------解决方案--------------------
应该是没有此标签的,楼主换一种标签
------解决方案--------------------
<components:CustomNavigatorContent >
继承的哪个类,如果不是Spark容器类不起作用。
出现这种错误,我估计你的CustomNavigatorContent 是在MX组件基础上写的。所以出现这个错误。
可以在里面在加一层 <Group>
<components:CustomNavigatorContent >
<s:layout>
<s:VerticalLayout/>
</s:layout>
</components:CustomNavigatorContent >
这里顺便给大家讲一下,虽然FLEX 4 官方提倡把SPARK和MX组件混合应用,不过在使用的时候一定要注意RENDERER 的使用者是MX组件还是Spark组件。
最后唠叨一句,下面是我们的博客,里面收集了很多FLEX相关知识,希望能够对大家有所帮助!
blog.chinemit.com
代码如下;
- Java code
<?xml version="1.0" encoding="utf-8"?> <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="com.syslink.components.*" xmlns:container="flexlib.containers.*" width="100%" height="100%"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <container:SuperTabNavigator id="superTab" x="0" y="0" width="100%" height="100%"> <components:CustomNavigatorContent label="{rootTabName}" width="70%" height="100%"> <s:layout> <s:VerticalLayout/> </s:layout> <components:CustomDataGrid width="100%" height="50%"/> <components:CustomLineChart width="100%" height="50%"/> </components:CustomNavigatorContent> </container:SuperTabNavigator> </s:Group>
其中以Custom*打头的组建都是我自定义的,此时编译出错,错误信息为:
无法将“<s:layout>”解析为组件执行。
当我将“components:CustomNavigatorContent”替换为“s:NavigatorContent”时就没问题了,其中:
public class CustomNavigatorContent extends NavigatorContent
{}
请问这是为何,我该如何让自定义的CustomNavigatorContent也能进行布局?
------解决方案--------------------
这样修改试试 把s改为container
<container:SuperTabNavigator id="superTab" x="0" y="0" width="100%" height="100%">
<components:CustomNavigatorContent label="{rootTabName}" width="70%" height="100%">
<container:layout>
<container:VerticalLayout/>
</container:layout>
<components:CustomDataGrid width="100%" height="50%"/>
<components:CustomLineChart width="100%" height="50%"/>
</components:CustomNavigatorContent>
</container:SuperTabNavigator>
------解决方案--------------------
应该是没有此标签的,楼主换一种标签
------解决方案--------------------
<components:CustomNavigatorContent >
继承的哪个类,如果不是Spark容器类不起作用。
出现这种错误,我估计你的CustomNavigatorContent 是在MX组件基础上写的。所以出现这个错误。
可以在里面在加一层 <Group>
<components:CustomNavigatorContent >
<s:layout>
<s:VerticalLayout/>
</s:layout>
</components:CustomNavigatorContent >
这里顺便给大家讲一下,虽然FLEX 4 官方提倡把SPARK和MX组件混合应用,不过在使用的时候一定要注意RENDERER 的使用者是MX组件还是Spark组件。
最后唠叨一句,下面是我们的博客,里面收集了很多FLEX相关知识,希望能够对大家有所帮助!
blog.chinemit.com