Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated events, also created new function in number util

  • Loading branch information...
commit 166c597e3c181dc86ce1f531cb12c87702b5c903 1 parent 3b0d136
@ahmednuaman authored
View
4 com/firestartermedia/lib/as3/data/XMLDataService.as
@@ -32,7 +32,9 @@ package com.firestartermedia.lib.as3.data
try
{
loader.load( request );
- } catch (e:*) { }
+ }
+ catch (e:*)
+ { }
}
public function sendPost(url:String, data:URLVariables=null):void
View
97 com/firestartermedia/lib/as3/display/component/Countdown.as
@@ -1,21 +1,112 @@
package com.firestartermedia.lib.as3.display.component
{
+ import com.firestartermedia.lib.as3.events.CountdownEvent;
+
import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.text.TextFormat;
public class Countdown extends Sprite
{
- private var targetDate:Date
+ private var currentDate:Date = new Date();
- public function Countdown(targetDate:Date)
+ private var buildCountdown:Boolean;
+ private var targetDate:Date;
+ private var textFormat:TextFormat;
+ private var visualTargets:Object;
+
+ private var _decades:Number;
+ private var _years:Number;
+ private var _months:Number;
+ private var _weeks:Number;
+ private var _days:Number;
+ private var _hours:Number;
+ private var _mins:Number;
+ private var _secs:Number;
+ private var _mSecs:Number;
+
+ public function Countdown(targetDate:Date, buildCountdown:Boolean=false, visualTargets:Object=null)
{
- this.targetDate = targetDate;
+ this.buildCountdown = buildCountdown;
+ this.targetDate = targetDate;
+ this.visualTargets = visualTargets;
init();
}
private function init():void
{
+ if ( buildCountdown )
+ {
+ // build();
+ }
+ else
+ {
+ addEventListener( Event.ENTER_FRAME, applyTimes );
+ }
+ }
+
+ private function applyTimes(e:Event):void
+ {
+ var diff:Number = targetDate.getTime() - currentDate.getTime();
+
+ if ( visualTargets.hasOwnProperty( 'decades' ) )
+ {
+
+ }
+
+ if ( visualTargets.hasOwnProperty( 'years' ) )
+ {
+
+ }
+
+ if ( visualTargets.hasOwnProperty( 'months' ) )
+ {
+
+ }
+
+ if ( visualTargets.hasOwnProperty( 'weeks' ) )
+ {
+
+ }
+
+ if ( visualTargets.hasOwnProperty( 'days' ) )
+ {
+ _days = Math.floor( diff / 86400000 );
+
+ diff -= ( _days * 86400000 );
+ }
+
+ if ( visualTargets.hasOwnProperty( 'hours' ) )
+ {
+ _hours = Math.floor( diff / 3600000 );
+
+ diff -= ( _hours * 3600000 );
+ }
+
+ if ( visualTargets.hasOwnProperty( 'mins' ) )
+ {
+ _mins = Math.floor( diff / 60000 );
+
+ diff -= ( _mins * 60000 );
+ }
+
+ if ( visualTargets.hasOwnProperty( 'secs' ) )
+ {
+ _secs = Math.floor( diff / 1000 );
+
+ diff -= ( _secs * 1000 );
+ }
+
+ if ( visualTargets.hasOwnProperty( 'mSecs' ) )
+ {
+
+ }
+
+ dispatchEvent( new CountdownEvent( CountdownEvent.TIME,
+ { decades: _decades, years: _years, months: _months, weeks: _weeks, days: _days, hours: _hours, mins: _mins, secs: _secs, mSecs: _mSecs } ) );
+ currentDate = new Date();
}
}
}
View
21 com/firestartermedia/lib/as3/events/CountdownEvent.as
@@ -0,0 +1,21 @@
+package com.firestartermedia.lib.as3.events
+{
+ import flash.events.Event;
+
+ public class CountdownEvent extends Event
+ {
+ public static const NAME:String = 'CountdownEvent';
+
+ public static const TIME:String = NAME + 'Time';
+
+ public var data:Object;
+
+ public function CountdownEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
+ {
+ super( type, bubbles, cancelable );
+
+ this.data = data;
+ }
+
+ }
+}
View
2  com/firestartermedia/lib/as3/events/DataServiceEvent.as
@@ -20,7 +20,7 @@ package com.firestartermedia.lib.as3.events
public var data:Object;
- public function DataServiceEvent(type:String, data:Object=null, bubbles:Boolean=true, cancelable:Boolean=false)
+ public function DataServiceEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
{
super( type, bubbles, cancelable );
View
2  com/firestartermedia/lib/as3/events/LoaderProgressEvent.as
@@ -13,7 +13,7 @@ package com.firestartermedia.lib.as3.events
public var data:Object;
- public function LoaderProgressEvent(type:String, data:Object=null, bubbles:Boolean=true, cancelable:Boolean=false)
+ public function LoaderProgressEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
{
super( type, bubbles, cancelable );
View
2  com/firestartermedia/lib/as3/events/RemoteConnectionServiceEvent.as
@@ -20,7 +20,7 @@ package com.firestartermedia.lib.as3.events
public var data:Object;
- public function RemoteConnectionServiceEvent(type:String, data:Object=null, bubbles:Boolean=true, cancelable:Boolean=false)
+ public function RemoteConnectionServiceEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
{
super( type, bubbles, cancelable );
View
2  com/firestartermedia/lib/as3/events/VideoPlayerEvent.as
@@ -32,7 +32,7 @@ package com.firestartermedia.lib.as3.events
public var data:Object;
- public function VideoPlayerEvent(type:String, data:Object=null, bubbles:Boolean=true, cancelable:Boolean=false)
+ public function VideoPlayerEvent(type:String, data:Object=null, bubbles:Boolean=false, cancelable:Boolean=false)
{
super( type, bubbles, cancelable );
View
2  com/firestartermedia/lib/as3/events/YouTubePlayerEvent.as
@@ -23,7 +23,7 @@ package com.firestartermedia.lib.as3.events
public static const BUFFERING:String = NAME + 'Buffering';
public static const NOT_STARTED:String = NAME + 'NotStarted';
- public function YouTubePlayerEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false)
+ public function YouTubePlayerEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
super( type, bubbles, cancelable );
}
View
9 com/firestartermedia/lib/as3/utils/NumberUtil.as
@@ -37,9 +37,12 @@ package com.firestartermedia.lib.as3.utils
var minutes:Number = Math.floor( ( number % 3600 ) / 60 );
var seconds:Number = Math.floor( ( number % 3600 ) % 60 );
- return ( hours == 0 ? '' : ( hours < 10 ? '0' + hours.toString() + ':' : hours.toString() + ':' ) ) +
- ( minutes < 10 ? '0' + minutes.toString() : minutes.toString() ) + ':' +
- ( seconds < 10 ? '0' + seconds.toString() : seconds.toString() );
+ return likeTime( hours ) + ':' likeTime( minutes ) + ':' + likeTime( seconds );
+ }
+
+ public static function likeTime(number:Number):String
+ {
+ return ( number < 10 ? '0' + number.toString() : number.toString() );
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.