# Tweening an XML file

**URL:** <https://forum.kirupa.com/t/tweening-an-xml-file/315465>\
**Category:** Uncategorized\
**Created:** [October 27, 2010, 3:18am UTC](https://forum.kirupa.com/t/tweening-an-xml-file/315465 "2010-10-27T03:18:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quiet0ne](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@quiet0ne](https://forum.kirupa.com/u/quiet0ne)\
**Post date:** [October 27, 2010, 3:18am UTC](https://forum.kirupa.com/t/tweening-an-xml-file/315465/1 "2010-10-27T03:18:23Z")

</div>

Hello! Complete actionscript/flash newb here. I’ll try to explain my problem as clearly as I can… My brain is fried after much googling, random guessing, and frustration. :insomniac: any help or pointers would be hugely appreciated.

I’m creating a flash animation using Todd Perkins’s [“Displaying Synched Song Lyrics Tutorial”](http://www.toddperkins.com/2010/05/20/displaying-synced-song-lyrics-tutorial/) . I have the initial flash working okay. However, I would like to add a fade in transition for **each** song lyric. My newbiness kicks in as I have no idea how to create what I want to happen.

I _think_ I need to be doing some kind of “addChild” doobedad, and then manipulate the child element with a tween… (that bright idea [came from this tutorial](http://www.republicofcode.com/tutorials/flash/as3slideshow/4.php)). I’ve been operating under the assumption that I need to add the tween information to the updateLyrics function… but I either get compile errors of various sorts, or the swf compiles okay and no transitions happen.

Here’s the actionscript I’m using at the moment:

```php

import flash.display.Stage;
import flash.events.*;
import flash.text.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
var lyrics:XML;
var loader:URLLoader = new URLLoader();
var lyricFade:Sprite = new Sprite();
var lyricFading:Sprite = new Sprite();
var startTime:uint = 0;
var currentTime:uint = 0;
var currentLyric:uint = 0;
var moby:Sound = new Sound();
var mobyChannel:SoundChannel;

moby.addEventListener(Event.COMPLETE, soundLoaded);
moby.load(new URLRequest("gamma.mp3"));
 
function soundLoaded(event:Event):void
{
    loader.addEventListener(Event.COMPLETE, xmlLoaded);
    loader.load(new URLRequest("lyrics.xml"));
}
 
function xmlLoaded(event:Event):void
{
    lyrics_txt.text = "Lyrics have loaded, please click play.";
    lyrics = new XML(loader.data);
    play_btn.addEventListener(MouseEvent.CLICK, playSong);
}
 
function playSong(event:MouseEvent):void
{
    startTime = getTimer();
    currentLyric = 0;
    lyrics_txt.text = "";
    if(mobyChannel)
    {
        mobyChannel.stop();
    }
 
    mobyChannel = moby.play(0);
 
    addEventListener(Event.ENTER_FRAME, updateLyrics);
}

function updateLyrics(event:Event):void
{
    addChild(lyricFade);
    lyricFade.addChild(lyricFading);
    new Tween(lyricFading,"alpha",Strong.easeIn,0,1,1,true);
    currentTime = getTimer() - startTime;
    if(currentTime >= lyrics.lyric[currentLyric].@time)
    {
        lyrics_txt.text = lyrics.lyric[currentLyric];
        currentLyric ++;
        if(currentLyric >= lyrics.lyric.length())
        {
            removeEventListener(Event.ENTER_FRAME, updateLyrics);
        }
    }    
}

```

here’s a quick example of what the XML file is supposed to look like:

```auto

<lyrics>
    <lyric time="400">Row, row, row your boat</lyric>
    <lyric time="560">gently down the stream!</lyric>
    <lyric time="780">Merrily, merrily, merrily</lyric>
    <lyric time="832">life is but a dream!</lyric>
</lyrics>

```

please help!!! even if it’s to hit me with a newbhammer and point out what I’m doing horribly wrong. thank you!!
