I have created an mp3 player, in MX 2004, that uses arrays to dynamically populate the movie clip. What I would like to do now is place the 2 arrays, artist and title info into a text file, so I can use just one movie to play various cds. Unfortunately, I have not found a good tutorial on how to accomplish this.
It is a basic script that I will incorporate into the mp3 player once I get the script to work right. There are links in the main movie that will send the appropriate text file to the player.
Anybody have any suggestions?
THe following code is what I want placed in a text file:
-----------------------------------------------------
var titles = new Array("Track01","Track02","Track03","Track04","Tra ck05","Track06");
var songNames = new Array("Track01.mp3","Track02.mp3","Track03.mp3","T rack04.mp3","Track05.mp3","Track06.mp3");
var artist = "Jeffrey Smith";
var cd = "Let Me Worship You";
-----------------------------------------------------
The following code will be located in the movieclip:
How do I join the create movie loop with the array?
Thanks for replying to my thread, I am really at the end of my rope on this one.
I created the following songs.text file:
&artist=Jeffrey Smith&cd=Let Me Worship You
&titles=Track01,Track02,Track03,Track04,Track05,Tr ack06&songNames=Track01.mp3,Track02.mp3,Track03.mp 3,Track04.mp3,Track05.mp3,Track06.mp3
loaded the code below into my flash movie. I can't get the data to display. Something is wrong with my loop. I traced both arrays and they show up in a straight line instead of descending in the movie clip. Nothing I do can get them to display like they do in the original menuarray_100.fla
---------------------------------------
var lv=new LoadVars();
All I want to do is populate an array, that is inside a flash movie, with data from a text file. The array in the flash movie creates a seperate movie for each mp3 file.
The following code populates the array from inside the movie and works well. I would like the data to come form a text file.
Code:
var titles = new Array("Track01","Track02","Track03","Track04","Track05","Track06");
var songNames = new Array("Track01.mp3","Track02.mp3","Track03.mp3","Track04.mp3","Track05.mp3","Track06.mp3");
var artist = "Jeffrey Smith";
var cd = "Let Me Worship You";
artist_txt.text = artist;
cd_txt.text = cd;
var sectionCount = titles.length;
var menu = this.createEmptyMovieClip("menu_mc", 1);
menu._x = 25;
menu._y = 70;
for(var i=0; i < sectionCount; i++){
var depthCount = menu.getNextHighestDepth();
var item = menu.attachMovie("itemClip", "item_" + i, depthCount);
item.labelName = titles[i];
item.song = songNames[i];
item.targetClip = this;
item._y = i*45;
}
I would like to move the following code into a text file:
Code:
var titles = new Array("Track01","Track02","Track03","Track04","Track05","Track06");
var songNames = new Array("Track01.mp3","Track02.mp3","Track03.mp3","Track04.mp3","Track05.mp3","Track06.mp3");
var artist = "Jeffrey Smith";
var cd = "Let Me Worship You";
I have tried the following:
Code:
var lv=new LoadVars();
lv.onLoad=function(ok){
if(ok){
titlesArray=this.titles.split(",");
songs=this.songNames.split(",");
}
else{
trace("text file failed to load"):
}
}
lv.load("songs.txt");
But I cannot get the data to populate my movie clips. I have spent two days on this and still have gotten no where. Attached is the text file I am working with. I have even included a screen shot of the successful movie. Can anybody help?
var menu = this.createEmptyMovieClip("menu_mc", 1);
with
Code:
var menu = _root.createEmptyMovieClip("menu_mc", 1);
Using this inside of a function meant you were creating the empty inside the function (invisible to the eye) instead on the main time where the user can see it
2. in your for loop replace
Code:
item.song = songNames[i];
with
Code:
item.song = songs[i];
The array of songs you create is called songs not SongNames
---
Thinking outside of the box will get you fired if the "box" is strict budget.