dynamic menus
Jan Schenkel
janschenkel at yahoo.com
Mon Sep 8 13:17:00 EDT 2003
--- derek bronston <derekbronston at earthlink.net>
wrote:
> Hello, anyone have a tutorial or something
> describing creating dynamic
> menus?
>
> Basically what I am doing is creating a playlist for
> an MP3 player. I
> am opening an external text file that contains the
> song info . I am
> turning this info into an array in revolution and
> want to loop through
> and print it to the stack each as a clickable text ,
> or a button.??
>
> any ideas
>
> thanks
>
> derek
>
Hi Derek,
Why don't you have a look at the list-field control ?
Judging by your description above, you want to build a
list of mp3-files, and play them one by one, or play
one upon a double-click.
First create a player control, through which you'll
play the MP3 files -- call it "MP3Player".
Then make a field "MP3List", and set its
list-behaviour to true via the Inspector palette.
You'll also want a button "AddMP3" to add files
Set the script of the "AddMP3" button to :
--
on mouseUp
answer file "Please select an MP3 file"
if it is empty then exit mouseUp
if field "MP3List" is empty
then put it into field "MP3List"
else put return & it after field "MP3List"
end mouseUp
--
Give the list field the following script :
--
on mouseDoubleUp
put line (the hilitedLine of me) into tFile
stop player "MP3Player"
set the fileName of player "MP3Player" to tFile
start player "MP3Player"
end mouseDoubleUp
--
Saving the list to a file is easy as well ; add a
button "SaveList" and set its script to :
--
on mouseUp
ask file "Save MP3 playlist as :"
if it is empty then exit mouseUp
put field "MP3List" into URL ("file:" & it)
end mouseUp
--
Reading the list from a file is just as easy ; add a
button "LoadList" and set its script to :
--
on mouseUp
answer file "Load MP3 playlist from :"
if it is empty then exit mouseUp
put URL ("file:" & it) into field "MP3List"
end mouseUp
--
The rest I leave up to you as an exercise ; of course,
if you have mor questions, dobn't hesitate to post
them on th list -- that's what we're here for :-)
Hope this helped,
Jan Schenkel.
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
More information about the use-livecode
mailing list