Flex Scheduling Framework:TimeLine Basic Sample
From Adobe Labs
Timeline is an independent control that renders and let users interact with a customizable timeframe. Developers can use this component in combinations other components, eg. to add a timeline to a ScheduleViewer component. See com.adobe.ac.controls.ScheduleViewer for more details.
You can style the layout of the timeline frame and customize and style each item of the timeline. By default, one item of Timeline would be a Label displaying a date.
The rendering of the item can be customized via the itemRenderer property. The itemRenderer has to implement com.adobe.ac.controls.timelineClasses.ITimelineEntryRenderer. Via Timeline's timeRanges property you can pass more information to the renderers on specific time ranges. By default a format string as used in mx.formatters.DateFormatter is passed to the renderer depending on what time range is currently displayed. i.e. by default a format string of "L:NNAA" is passed to the renderer when Timeline currently only dispays a time range of one minute. You can customize this with passing your own timeRanges collection. timeRanges must contain items that adhere to the com.adobe.ac.controls.timelineClasses.ITimeDescriptor interface. See com.adobe.ac.controls.timelineClasses.TimeRangeDescriptorUtil class for more details and utilities on customizations of time ranges.
Timeline supports zooming via the zoom and contentWidth property.
Currently, only horizontal timelines are supported.
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2006. Adobe Systems Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Adobe Systems Incorporated nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
@ignore
-->
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:controls="com.adobe.ac.controls.*"
creationComplete="onCreationComplete();">
<mx:Script>
<![CDATA[
import com.adobe.ac.util.DateUtil;
import mx.events.ScrollEvent;
[Bindable]
private var startDate : Date;
[Bindable]
private var endDate : Date;
[Bindable]
private var currentDate : Date;
[Bindable]
private var zoom : Number;
private function onCreationComplete() : void
{
var duration : Number = DateUtil.MONTH_IN_MILLISECONDS * 24;
startDate = DateUtil.clearTime( new Date() );
endDate = new Date( startDate.getTime() + duration );
startDateField.selectedDate = startDate;
endDateField.selectedDate = endDate;
zoom = 100;
}
private function onZoom( value : Number ) : void
{
zoom = value;
}
private function onScrollTimeline( event : ScrollEvent ) : void
{
//you can trigger other components here to connect them with Timeline.
}
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label="startDate">
<mx:Label text="{ timeline.startDate }" />
<mx:DateField id="startDateField" change="timeline.startDate = event.newDate"/>
</mx:FormItem>
<mx:FormItem label="endDate">
<mx:Label text="{ timeline.endDate }" />
<mx:DateField id="endDateField" change="timeline.endDate = event.newDate"/>
</mx:FormItem>
<mx:FormItem label="xPosition">
<mx:Label text="{ timeline.xPosition }" />
</mx:FormItem>
<mx:FormItem label="zoom">
<mx:Label text="{ timeline.zoom }" />
</mx:FormItem>
<mx:FormItem label="currentDate">
<mx:Label text="{ timeline.currentDate }" />
</mx:FormItem>
</mx:Form>
<controls:Timeline
id="timeline"
width="600"
startDate="{ startDate }"
endDate="{ endDate }"
zoom="{ zoom }"
borderStyle="solid" backgroundColor="0xffffff"
scroll="onScrollTimeline( event );" />
<mx:HSlider
id="zoomSlider"
width="1200"
minimum="0" maximum="15000" value="{ zoom }"
snapInterval="1" liveDragging="true"
change="onZoom( zoomSlider.value );" />
</mx:Application>
