I am looking to find some examples to create a clock that
counts down from 3 minutes to zero and when the clock hits zero it
will refresh the application. I would also like this clock to be
clickable so that it to would refresh the app.
I have looked all over the net but have not seen any
time/date examples anywhere.
any help would be greatTime in Flex
I think you can use the Timer class to achieve that:
http://livedocs.adobe.com/flex/201/langref/flash/utils/Timer.html
Hope it helpsTime in Flex
Here is an example:
http://www.cflex.net/showFileDetails.cfm?ObjectID=560
Tracy
I've also found this but I am getting some weird errors
%26lt;mx:Script%26gt;
%26lt;![CDATA[
public class ShortTimer extends Sprite{
public function ShortTimer()
{
// creates a new five-second Timer
var minuteTimer:Timer = new Timer(1000, 300);
// designates listeners for the interval and completion
events
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
onTimerComplete);
// starts the timer ticking
minuteTimer.start();
}
public function onTick(evt:TimerEvent):void
{
// displays the tick count so far
// The target of this event is the Timer instance itself.
trace(''tick '' + evt.target.currentCount);
}
public function onTimerComplete(evt:TimerEvent):void
{
refresh();
}
}
]]%26gt;
%26lt;/mx:Script%26gt;
It keeps returning the error
Severity Description Resource In Folder Location Creation
Time Id
2 1131: Classes must not be nested. line 15 November 1, 2007
9:26:24 AM 104
The problem is that you are declaring a class inside a Script
block which belongs to the mxml file, which is as well a class, so
you are nesting classes.
Remove the public class declaration and call the logic inside
your constructor from the creationComplete event of your mxml
component.
I'm sorry but I don't have any of the things in my MXML file
that you described
This is my clock.as file
package
{
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class ShortTimer extends Sprite
{
public function ShortTimer()
{
// creates a new five-minute Timer
var minuteTimer:Timer = new Timer(1000, 300);
// designates listeners for the interval and completion
events
minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
onTimerComplete);
// starts the timer ticking
minuteTimer.start();
}
public function onTick(evt:TimerEvent):void
{
// displays the tick count so far
// The target of this event is the Timer instance itself.
trace(''tick '' + evt.target.currentCount);
}
public function onTimerComplete(evt:TimerEvent):void
{
refresh();
}
}
}
and this is my main application file
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''
http://www.adobe.com/2006/mxml''
layout=''absolute'' width=''100%'' viewSourceURL=''srcview/index.html''
height=''100%''%26gt;
%26lt;mx:Style source=''source.css''/%26gt;
%26lt;mx:Image source=''images/title.jpg'' width=''210''
height=''65'' top=''4'' left=''15''/%26gt;
%26lt;mx:Image source=''images/title1.jpg'' id=''image1''
horizontalAlign=''right'' verticalAlign=''top'' width=''784'' height=''58''
y=''3'' right=''0''/%26gt;
%26lt;mx:XML id=''tempXML'' source=''
http://company.sitename.net/interface.php?username=user%26amp;amp;password=pass%26amp;amp;cu stomer=suctomer%26amp;amp;action=showopen%26amp;amp;operation=defects%26amp;amp;format=xml%26amp;amp;cri tcal=both''
/%26gt;
%26lt;mx:XMLListCollection id=''defectXMLList''
source=''{tempXML.defect}'' /%26gt;
%26lt;mx:Script source=''clock.as'' /%26gt;
%26lt;mx:TileList
dataProvider=''{tempXML.defect.asset}''
horizontalCenter=''0'' bottom=''56'' top=''72'' width=''100%''
backgroundColor=''#000000'' color=''#ff0000'' fontSize=''27''
borderColor=''#000000'' columnWidth=''300'' rowHeight=''50''
themeColor=''#808080'' fontWeight=''bold''
allowMultipleSelection=''true''/%26gt;
%26lt;/mx:Application%26gt;
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment