Example Number 4.11

Example Name: DebugFunctions.cs

Language: C#

Version: 1.0.0

Code:

// C# Document
using System;
using FlashGateway.IO;
namespace com.oreilly.frdg {
  public class DebugFunctions {
    //protected FlashGateway.Flash Flash;
    public DebugFunctions( ) {
    }
    public ASObject computeTimeDifference (ASObject t) {
      // Set the type of the ActionScript object
      t.ASType = "TimeDifferenceClass";
      DateTime d = DateTime.UtcNow;
      DateTime e = (DateTime)t["date"];
      TimeSpan tsDuration;
      // Use an absolute value for the time difference
      tsDuration = DateTime.Compare(d, e) < 0 ? e - d : d - e;
      t["days"] = tsDuration.Days;
      t["hours"] = tsDuration.Hours;
      t["minutes"] = tsDuration.Minutes;
      t["seconds"] = tsDuration.Seconds;
      t["milliseconds"] = tsDuration.Milliseconds;
      t["serverDate"] = d;
      return t;
    }
  }
}

Download code text

Download chapter example files