[AS 2.0] Accessing variable in parent function?

I’m new to this forum, so, “Hello World”! :slight_smile:

I’m also relatively new to programming with actionscript, so my code might look quite messy to you :wink:

Here is my function. It loads the contents of an .xml file and creates a playlist for a video player.
Now my problem is that i want to set the “onRelease” function dynamicaly for each playlist item. but inside the onRelease-function i cannot access the variable i. do you have a hint / workaround for me???

here is my (shortened for readability) code

    vlist.onLoad = function() {
        for (i=0; i<_root.videoList.length; i++) {
            _root.playlist.attachMovie ("listenitem","listitem" + i, _root.playlist.getNextHighestDepth());
            _root.playlist["listitem"+i]._x = 0;
            _root.playlist["listitem"+i]._y = 18 + i * 18;
            _root.playlist["listitem"+i].listlabel.text = _root.videoList*['title'];
            _root.playlist["listitem"+i].onRelease = function() {

                //  I want to access the variable i in here, but this does not work... :*(
                _root.FLVmovie.load (_root.contentVidPath + _root.videoList*['file']);
                trace("LADE: " + _root.contentVidPath + _root.videoList*['file']);

Thank you in advance