Score change animation

template

#1

Hi,
I try to make simple scorebug. It’s feed from external XML file. I want to start an animation when score changing, but i doesn’t found event listener or dispatcher to get change of value.
My code is:

> 
> import flash.net.URLLoader;
> import flash.events.Event;
> import flash.events.TimerEvent;
> import flash.net.URLRequest;
> import flash.utils.Timer;
> import flash.geom.ColorTransform
> import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
> 
> var myTimer:Timer = new Timer(100);
> myTimer.addEventListener(TimerEvent.TIMER, timerListener);
> function timerListener (e:TimerEvent):void
{
>   var myXMLLoader:URLLoader = new URLLoader();
>   myXMLLoader.load(new URLRequest("D:/Download/SCOREBOARDS/Scoreboard+(16)/New folder/Output/Xml.xml"));
>   myXMLLoader.addEventListener(Event.COMPLETE, processXML);
> 
>    function processXML (e:Event):void
>    {
>    var myXML:XML = new XML(e.target.data);
> 
> ShotClock.text = myXML.timestamp;
> GameClock.text = myXML.Clock;
> HS.HomeScore.text = myXML.HomeScore;
> AS.AwayScore.text = myXML.AwayScore;
> Period.text = myXML.Period;
> AwayTeam.text = myXML.AwayName;
> HomeTeam.text = myXML.HomeName;
> 
> 	    if ((myXML.timestamp) > 5) 
>  
>       {	  
>         var colorYELL:ColorTransform = ShotClock.transform.colorTransform;
>         colorYELL.color = 0xFFCC00;
>         ShotClock.transform.colorTransform = colorYELL; 
>       }
> 	  else 
> 	  {
> 		  var colorRED:ColorTransform = ShotClock.transform.colorTransform;
>         colorRED.color = 0xFF0000;
>         ShotClock.transform.colorTransform = colorRED;
> 	  }
>         if ((myXML.HomeScore).CHANGE) 
		
	{var myTween:Tween = new Tween(HS.HomeScore, "alpha", Strong.easeIn, 0, 1, 1, true);
> 		
> 	}
> 
> 	}
> myTimer.start();

#2

Where is that code? In a frame? See this for a proper way to run code inside your template.


#3

Yes. It is in first frame. Can you show me an example to get external data via Advanced Flash Templates?


#4

There is a basic code example for dynamic images here. You can copy your code into the as file and overwrite postInitialize to add the event listener and start the timer.

I have no example as I normally process external data in a custom client and not directly in the template.