Hi

In order to reference movieclips using an index you would need to keep them in an array. Alternatively if you don't need to reference them by name, you can use the return value of attachMovie() to keep a reference:

for () {
        ...

        var mc:MovieClip = _root.attachMovie("butTemp","but"+i,i+50);
        mc.id=i;
        mc.but_txt.text = songname[i];
        mc.band_txt.text = songband[i];
        mc.info.contentMain.info_txt.text = songinfo[i];
        mc.rotate.aside.loadMovie(aside[i],1);

        ...
}

This works no matter where you attach the movieclip as 'mc' is a reference to it.



On 28 Feb 2007, at 13:02, hervé hubert wrote:

Hi,
I'm making a mp3 player for a website.
I started from a code which fits quite well to what I need for this project
I want to include this player into my flash website.
In this code there is a _root["but"+i] that I would like to replace by a relative path like this.but[i]
but this doesn't work...
Here is the involved part of my code, can anyone help me?
Thanks alot.

playlist.onLoad = function(success) {
        if (success) {
                _global.songname = [];
                _global.songband = [];
                _global.songband = [];
                _global.songfile = [];
                _global.aside = [];
                _global.songinfo = [];
                for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes [i].attributes.name; _global.songband[i] = playlist.firstChild.childNodes [i].attributes.band; _global.songfile[i] = playlist.firstChild.childNodes [i].attributes.file; _global.aside[i] = playlist.firstChild.childNodes [i].attributes.aside; _global.songinfo[i] = playlist.firstChild.childNodes [i].attributes.info;
                attachMovie("butTemp","but"+i,i+50);
                eval("but"+i).id=i;
                _root["but"+i].but_txt.text = songname[i];
                _root["but"+i].band_txt.text = songband[i];
                _root["but"+i].info.contentMain.info_txt.text = songinfo[i];
                _root["but"+i].rotate.aside.loadMovie(aside[i],1);
                }
        }
}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

---
www.fridayforward.com



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to