将Flex应用程序转换为视图

时间:2012-05-05 23:32:11

标签: actionscript-3 flex flex4.5

我正在尝试将Flexlib的调度示例1转换为视图。

https://github.com/flex-users/flexlib

当我把它放在视图中时,我遇到了这条线的问题:

<flexlib:ScheduleViewer id="scheduleViewer"  
            width="600" height="400" 
            dataProvider="{dataProvider }"       
            startDate="{startDate}" endDate="{endDate}" />

当我有这条线时,我注意到了:

xmlns:flexlib="http://code.google.com/p/flexlib/" 

我收到了这个错误:

Could not resolve <flexlib:ScheduleViewer> to a component implementation.

当我将该行更改为:

xmlns:flexlib="libs.flexlib.scheduling.*"

我收到此错误:

1046: Type was not found or was not a compile-time constant: ScheduleViewer.

此外,我已将flexlib.swc放入我的libs文件夹中。以下是整个代码:

<?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:flexlib="libs.flexlib.scheduling.*"
    creationComplete="onCreationComplete();">

<fx:Style>
    .myEntryStyle {
        fillAlphas: 1, 1;
        fillColors: #ff0000, #990000;
        timeStyleName: "myTimeStyle";
        color: #000000;
    }
    .myTimeStyle {
        fontSize: 9;
        fontWeight: bold;
        color: #ffff00;
    }
</fx:Style>

<fx:Script>
    <![CDATA[
        import flexlib.scheduling.scheduleClasses.SimpleScheduleEntry;
        import flexlib.scheduling.util.DateUtil;
        import mx.collections.ArrayCollection;

        [Bindable]         
        private var dataProvider : ArrayCollection;         
        [Bindable]
        private var startDate : Date;
        [Bindable]
        private var endDate : Date;

        private function onCreationComplete() : void
        {
            setTimeframe();
            initDataProvider();
        }

        private function setTimeframe() : void
        {
            startDate = DateUtil.clearTime( new Date() );
            endDate = getEndDate( startDate );
        }

        private function getEndDate( startDate : Date ) : Date
        {
            var duration : Number = DateUtil.DAY_IN_MILLISECONDS * 1;
            var endDate : Date = new Date( startDate.getTime() + duration );
            return endDate;
        }

        private function initDataProvider() : void
        {
            var entries : ArrayCollection = new ArrayCollection();
            var entry : SimpleScheduleEntry = new SimpleScheduleEntry();
            entry.startDate = DateUtil.clearTime( new Date() );
            entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 5 );
            entry.label = "Our first entry!";
            entries.addItem( entry );

            entry = new SimpleScheduleEntry();
            entry.startDate = DateUtil.setTime( new Date(), DateUtil.HOUR_IN_MILLISECONDS );
            entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 15 );
            entry.label = "Our second entry!";
            entries.addItem( entry );

            entry = new SimpleScheduleEntry();
            entry.startDate = DateUtil.setTime( new Date(), DateUtil.HOUR_IN_MILLISECONDS * 13 );
            entry.endDate = new Date( entry.startDate.getTime() + DateUtil.HOUR_IN_MILLISECONDS * 5 );
            entry.label = "Our third entry!";
            entries.addItem( entry );

            dataProvider = entries;
        }
    ]]>
</fx:Script>

<flexlib:ScheduleViewer id="scheduleViewer"  
                        width="600" height="400" 
                        dataProvider="{ dataProvider }"       
                        startDate="{ startDate }" endDate="{ endDate }" />
    </s:View>

有人知道将此示例转换为视图的问题是什么?

0 个答案:

没有答案