hi, here is my question:
I have two boxes in my webpage,I want in one to appear the name of the songs and when I press a song ,its lyrics appears in the other one,and when I press another song ,the previous lyrics are erased, any ideas???,PLEASE HELP
the problem is that the lyrics are movieclips,because they have a text scroller
I’m confused…you have two text boxes, and I’m assuming that your text is loaded from a txt file…
On the button that changes the name of your song, just loadVars the new text into the lyrics box. Your targeting would have to include that movieClip that holds the text box too like:
_root.movieClipName.textBoxName.text=this.variableInTxtFile;
Should change automatically, if I understand…This thread helped someone with a simular situation:
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=30075&highlight=textbox
actually ,I don´t know how to do that,can you explain how to load the txt file and the loadVars, PLEASE…
This tutorial explains all about it: http://www.kirupa.com/developer/mx/dynamic_scroller.htm
If you get through that tutorial, and you still have problems targeting those text boxes, take them out of the movieClips and plop them on the main stage. A textbox does not need to be a movieClip to have a scroll bar component added to it. That way, you can target your stuff just like they have in the tutorial Voetsjoeba mentioned. (-:
the thing is that in the tutorial they target only one external txt ,what should I add to my buttons to target the different txt?
*Originally posted by moshlp *
**the thing is that in the tutorial they target only one external txt ,what should I add to my buttons to target the different txt? **
I don’t get your question, please restate it. Are you loading the song titles dynamically too ?
no really, i just write them in the box in Flash and that´s it,should I load the titles dynamically also?
As for the tutorial, they don´t use any button to load different txt, and in my case, i have 5 buttons that should load 5 different txt, what do I have to do with my buttons?what sholud I add to make them call a different txt?
another thing: if I load the song titles dynamically,how do I make them buttons?
No, you shouldn’t load your song titles dynamically. For such small amounts of text, it’s not worth the effort loading them dynamically. Lemme see about the loadVars(); for a moment …
Okay, let’s look at some code:
loadText = new loadVars();
//defines 'loadText' as a variable to accept info
loadText.load("kirupa.txt");
//defines what info to load into 'loadText'
loadText.onLoad = function() {
//when this script runs, this function defines where to put the info
//it just loaded in
scroller.text = this.kirupatext;
};
As we learned in the tut, ‘scroller’ is the name of the text box and ‘kirupatext’ is the variable that Flash will search for in your text file and print out everything after ‘kirupatext=…’
Since you want multiple things, I would do this in the text file. For example:
songone=These are the lyrics to my song,%0dIt’s a good song%0dlalala!!
&songtwo=These are the lyrics to the next song%0ddumdedumdum%0dGuitarsolo!!
etc.
The & tells Flash that there’s a new variable. The %0d is a carridge return (do a search on URL encode later :P). Now, I don’t know if your fla is just one frame, or you have multiple frames or what have you, so I can’t really tell you exactly what to do in your case. I would put all the actions in my buttons like:
on(press){
loadText = new loadVars();
loadText.load("songlyrics.txt");
loadText.onLoad = function() {
lyricsBox.text = this.songone;
}
}
Then on another button…
on(press){
loadText = new loadVars();
loadText.load("songlyrics.txt");
loadText.onLoad = function() {
lyricsBox.text = this.songtwo;
}
}
Play with that for a while (-:
How to make your text a button, I would just put a button in a layer underneath your textbox. Here’s an example. Goto my site:
http://www.freddythunder.com
On the top left side, click the bottom bar of the ‘music box’. Four song names will pop up. These song names are loaded dynamically and there are buttons underneath them.
Whew - that was a long post!!
[edit]Voetsjoeba - Loading the names would be benificial if he needs to ever change them -to avoid the cache situtation, correct? – And man, I hope you’re not typing out the same thing I did…if so, I’m sorry!!:P[/edit]
I’m making a FLA, set up the way you posted
Voetsjoeba - Loading the names would be benificial if he needs to ever change them -to avoid the cache situtation, correct? – And man, I hope you’re not typing out the same thing I did…if so, I’m sorry!!
Well, if he ever needs to change them he’ll just have to open up Flah and change a tiny bit of text About the cache situation - I have a SWF with dynamically loaded text, and the cache problem remains :-\ But, for a friend of mine, the cache problem isn’t there. So that kinda confuses me. But, I suppose the cache problem won’t be there, and probably it’s just my pc being weird
i have a fla of the textboxes,if you can do something with them,i´d appreciate it.These are the same as I have in my page
in the left one i want to write the name of the songs,and in the other one, the lyrics
Where are the buttons to switch songs ? Have you tried Freddy’s method ?
i haven´t done them yet.
I´m trying to make the button behind the layer, but i can´t.
Anyway, i think I´ll just make them in the stage instead of loading them dynamically
Repost when you have the switchbuttons
Check if this helps
here are the textboxes with the buttons.I added the code you gave me,and changed the names and stuff, but they don´t seem to work,can you tell me what´s wrong?
Here