本文介绍了在 Flex 移动项目中使用 mx.charts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

Adobe 声明 移动项目支持图表,但是当我尝试更改以下工作文件(使用 File - New - Flex Mobile Project - Google Nexus One 创建的项目):

Adobe states that Charts are supported in mobile projects but when I try to change the following working files (created project with File - New - Flex Mobile Project - Google Nexus One):

MyTest.mxml:

MyTest.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:MobileApplication
      xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      firstView="views.MyTestHome">
 <s:navigationContent>
  <s:Button label="Home"
     click="navigator.popToFirstView();"/>
 </s:navigationContent>

 <s:actionContent/>
</s:MobileApplication>

MyTestHome.mxml:

MyTestHome.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  title="Test Chart">
</s:View>

到新的 MyTestHome.mxml:

to the new MyTestHome.mxml:

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

 <fx:Script>
  <![CDATA[
   import mx.collections.*;

   [Bindable]
   private var medalsAC:ArrayCollection =
    new ArrayCollection( [
    {Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
    {Country:"China", Gold: 32, Silver:17, Bronze: 14 },
    {Country:"Russia", Gold: 27, Silver:27, Bronze: 38 }
   ]);
  ]]>
 </fx:Script>

 <mx:PieChart id="chart" height="100%" width="100%"
     paddingRight="5" paddingLeft="5" color="0x323232"
     dataProvider="{medalsAC}" >

  <mx:series>
   <mx:PieSeries labelPosition="callout" field="Gold">
    <mx:calloutStroke>
     <s:SolidColorStroke weight="0"
        color="0x888888" alpha="1.0"/>
    </mx:calloutStroke>
    <mx:radialStroke>
     <s:SolidColorStroke weight="0"
        color="#FFFFFF" alpha="0.20"/>
    </mx:radialStroke>
    <mx:stroke>
     <s:SolidColorStroke color="0"
        alpha="0.20" weight="2"/>
    </mx:stroke>
   </mx:PieSeries>
  </mx:series>
 </mx:PieChart>
</s:View>

并添加

  • c:\Program Files\Adobe\Adobe Flash生成器 Burrito\sdks\4.5.0\frameworks\libs\datavisualization.swc
  • c:\Program Files\Adobe\Adobe Flash Builder Burrito\sdks\4.5.0\frameworks\libs\sparkskins.swc
  • c:\Program Files\Adobe\Adobe Flash Builder Burrito\sdks\4.5.0\frameworks\libs\mx\mx.swc

到 Flex 构建路径(单击添加 SWC"按钮):

to Flex Build Path (clicking "Add SWC" button):

然后它失败并出现错误:

Then it fails with the error:

无法解析为组件实现.

这里有人有想法吗?

推荐答案

好的让这个工作,这是我的设置,使用 Flash Builder Burrito 附带的默认 Hero SDK 我最终能够让这个工作我也测试过使用 Hero 17689 构建,它似乎也运行良好.您只需要从 4.5.0\frameworks\libs 文件夹中导入的两个 swc,即 mx.swc 和 datavisualization.swc.添加这两个之后,我还需要更正命名空间,以便识别并构建和运行它.

Okay got this working, here's what I have setup, using the default Hero SDK that comes with Flash Builder Burrito I was able to ultimately get this working I also tested with the Hero 17689 build and it appears to be working fine as well. You only need the two swcs imported from the 4.5.0\frameworks\libs folders the mx.swc and the datavisualization.swc. After adding these two I also needed to correct the namespaces in order to get it to be recognized and build and run.

TestMobileApp.mxml

TestMobileApp.mxml

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

TestMobileAppHome.mxml

TestMobileAppHome.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:charts="mx.charts.*"
    xmlns:series="mx.charts.series.*"
    xmlns:chartClasses="mx.charts.chartClasses.*"
    title="Test Chart">

<fx:Script>
    <![CDATA[
        import mx.charts.PieChart;
        import mx.collections.*;

        [Bindable]
        private var medalsAC:ArrayCollection =
            new ArrayCollection( [
                {Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
                {Country:"China", Gold: 32, Silver:17, Bronze: 14 },
                {Country:"Russia", Gold: 27, Silver:27, Bronze: 38 }
            ]);
    ]]>
</fx:Script>

<charts:PieChart id="chart" height="100%" width="100%"
                 paddingRight="5" paddingLeft="5" color="0x323232"
                 dataProvider="{medalsAC}" >

    <charts:series>
        <series:PieSeries labelPosition="callout" field="Gold">
            <series:calloutStroke>
                <s:SolidColorStroke weight="0"
                                    color="0x888888" alpha="1.0"/>
            </series:calloutStroke>
            <series:radialStroke>
                <s:SolidColorStroke weight="0"
                                    color="#FFFFFF" alpha="0.20"/>
            </series:radialStroke>
            <series:stroke>
                <s:SolidColorStroke color="0"
                                    alpha="0.20" weight="2"/>
            </series:stroke>
        </series:PieSeries>
    </charts:series>
</charts:PieChart>

这篇关于在 Flex 移动项目中使用 mx.charts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:24