我是新來的Flex,我一直在試圖找出如何使用下面的代碼爲Flex 4中軟硬度:需要幫助實現自定義組件的代碼虛線
http://riarange.wordpress.com/2010/10/29/how-to-create-a-dotted-line-or-dashed-line-in-flex-4/
創建虛線我希望有人更好地瞭解Flex,可以簡單地提供一個完整的(最小)示例,該示例使用此代碼繪製虛線。我無法將這些部分拼湊在一起,我認爲作者假定了一些我缺乏的基本知識。如果我有一個工作的例子,我可以找出如何適應我的需求。
在此先感謝您的任何意見/幫助。如果有更好的虛線代碼,很想知道。
UPDATE:
我把自定義組件代碼到在COM目錄中的文件DottedLine.mxml。現在,我得到的是出現在<components:Group>
行一個錯誤,指出:Could not resolve <components:Group> to a component implementation.
<mx:Application
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.*"
minWidth="955" minHeight="600" xmlns:com="com.*">
<fx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:1, Profit:2000, Expenses:1500, Amount:450},
{Month:2, Profit:1000, Expenses:200, Amount:600},
{Month:2.05, Profit:1000, Expenses:500, Amount:300},
{Month:2.1, Profit:1000, Expenses:500, Amount:450},
{Month:2.15, Profit:1000, Expenses:200, Amount:600},
{Month:2.2, Profit:1000, Expenses:500, Amount:300},
{Month:2.25, Profit:1000, Expenses:500, Amount:450},
{Month:2.3, Profit:1000, Expenses:200, Amount:600},
{Month:2.35, Profit:1000, Expenses:500, Amount:300},
{Month:2.4, Profit:1000, Expenses:500, Amount:450},
{Month:2.45, Profit:1000, Expenses:200, Amount:600},
{Month:2.5, Profit:1000, Expenses:500, Amount:300},
{Month:2.55, Profit:1000, Expenses:500, Amount:450},
{Month:2.6, Profit:1000, Expenses:200, Amount:600},
{Month:2.65, Profit:1000, Expenses:500, Amount:300},
{Month:2.7, Profit:1000, Expenses:500, Amount:450},
{Month:2.75, Profit:1000, Expenses:200, Amount:600},
{Month:2.8, Profit:1000, Expenses:500, Amount:300},
{Month:2.85, Profit:1000, Expenses:500, Amount:450},
{Month:2.9, Profit:1000, Expenses:200, Amount:600},
{Month:6, Profit:1500, Expenses:500, Amount:300}
]);
]]></fx:Script>
<mx:Panel title="Line Chart With Strokes">
<mx:LineChart id="myChart" dataProvider="{expenses}" showDataTips="true" seriesFilters="{new Array}">
<mx:horizontalAxis>
<mx:LinearAxis />
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries xField="Month" yField="Expenses" displayName="Expenses">
<mx:lineStroke>
<mx:SolidColorStroke id="s1" color="0xBD171B" weight="4"/>
</mx:lineStroke>
</mx:LineSeries>
<mx:LineSeries xField="Month" yField="Amount" displayName="Amount">
<components:Group>
<components:DottedLine width="500" height="2" dotColor="0xFFFFFF" dotWidth="3" dotAlpha="1" />
</components:Group>
</mx:LineSeries>
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{myChart}" direction="horizontal"/>
</mx:Panel>
這個例子看起來很完整,我不確定你錯過了什麼。 – JeffryHouser 2012-01-17 21:03:24
好吧,我想這很好,那肯定是顯而易見的。我將編輯帖子以顯示我所做的努力來實現它。 – ggkmath 2012-01-17 21:29:05
關於您遇到的錯誤,關於組件的問題意味着您沒有在您嘗試使用組件前綴的組件的根節點中定義的名稱空間。它應該被定義爲DottedLine類所在的包。如果DottedLine類基於它在項目中的位置具有正確的包名稱,那麼只需在
shaunhusain
2012-01-17 22:23:29