﻿//CONSTRUCTOR
function KeyFrame(oControl) {
 
 //PROPERTIES
 this.__oControl = oControl;
 var __aKeySpline = new Array();
 var __aKeyFrame = new Array();
 var __oTargetElement;
 
 //PUBLIC PROPERTIES
 this.target;
 this.property;
 this.storyboard;
 
 
 
 //PRIVATE PROPERTIES
 this.sSpline;
 this.nValue;
 this.sTimeSpan;
 

 
 //PRIVATE
 
 //PUBLIC
 
 
 //TWEEN BUILDER
 this.buildTween = function() {
    

  var plugin = this.__oControl;
  
  //Animation Properties 
 // var sStoryBoardName = sStoryBName;
  
  this.checkforKeyFrameProp(__aKeyFrame);
  
  var aXamlBuild = ['<Storyboard  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"',
                   ' x:Name="', this.storyboard,'">',
                   __aKeyFrame.join(""),
                   '</Storyboard>' ];
                   
         
  var xamlFragment = aXamlBuild.join("");
  
  storyBoardElement = plugin.content.createFromXaml(xamlFragment, false);               
  __aKeyFrame = new Array();
  return storyBoardElement;
 }

  //BUILD KEYFRAME PROPERTIES
  this.addKeyFrame = function() {
  __aKeyFrame.push(' <DoubleAnimationUsingKeyFrames ',
                 ' Storyboard.TargetName="',  this.target.name ,'"',
                 ' Storyboard.TargetProperty ="' , this.property , '">',
                 __aKeySpline.join(""),
                 ' </DoubleAnimationUsingKeyFrames>');
    __aKeySpline = new Array();
   }
  
  //SPLINE
  this.addSpline = function(sSpline, nValue, sKeyTime) {
     __aKeySpline.push('<SplineDoubleKeyFrame KeySpline="' + sSpline + '" Value="' + nValue + '" KeyTime="' + sKeyTime + '" />');
 }


 //CHECK KEY FRAMES
   this.checkforKeyFrameProp = function(aKeyFrame) {
     if(aKeyFrame == "") {
       alert("you need to insert key frame properties before building animation");
       alert("!!!!!!Fuck Face!!!!!!");
     }
    }
 }