PDA

View Full Version : How to make a drop down menu


KathyM
02-12-2007, 05:18 PM
Hello,

I am very new at AMS, but love it so far. I am using it 100% for CD Business Cards. I am struggling with the scripting part as that is a completely new area for me. So I decided to use this forum as a place to start learning.

My question today is this... On my home page of a CD Business card, I have a list of items, one of which is "Testimonials". How do I create a drop down list that drops down from Testimonials when the user clicks on that word? Just like any drop down list in a windows menu. I will have 3 or 4 items on the list and when the user chooses one it will then play a video testimonial. I want the list not to be visible unless the user clicks on the word "Testimonials". I'm really struggling with this, so any help would be greatly appreciated.

Thanks,
Kathy

Roboblue
02-12-2007, 07:31 PM
Just curious, can you use a combo box? It's probably the easiest to use.
Creating a popup menu (looks like a drop down if you position it right) is fairly easy, but still tough for a new user. You have to create a table, then use Application.ShowpopupMenu
Try this to get started. Put it on your button (or label) on-click
tblMenu = {};
tblMenu[1] ={};
tblMenu[1].Text = "Testimony 1";
tblMenu[1].ID = 100;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;
tblMenu[2] ={};
tblMenu[2].Text = "Testimony 2";
tblMenu[2].ID = 200;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

nTrayMenu = Application.ShowPopupMenu(X, Y, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, false, true);

if nTrayMenu == 100 then
---do something here
elseif nTrayMenu == 200 then
---do something here
end

Substitute the X,Y above for the position (X = from left, Y = from top) that you want the popup to be shown.

KathyM
02-12-2007, 08:41 PM
Wow, thanks. It's a bit overwhelming for me, but I want to learn. I will give it a try!

bule
02-13-2007, 12:49 AM
It's a bit overwhelming for me, but I want to learn.

An you should swallow it quite easily... LUA scripting language is so easy for any newcomer to understand and use it in a productive matter in a snap. Combined with the powerful IDE such as APMS (and all it's plugins), any time soon and you will be unstoppable! Just be persistent in the beginning, and if stuck, ask here (explain your problem, what are you trying to achieve and what have you tried so far). Like TJ would say... Happy coding!

KathyM
02-13-2007, 10:32 AM
Thanks guys, I might rely on your help. Roboblue, I tried your code and it worked great except that I can't get the video to actually play. Here is what I added, can you see anything I'm doing wrong? The menu comes up just fine (I named the first item Prime Time Mortgage), but when Prime Time Mortgage is clicked, nothing happens.

if nTrayMenu == 100 then
Video.Load("Prime Time Mortgage", "AutoPlay\\Videos\\Prime Time Mortgage.wmv", false, false);
Video.Play("Prime Time Mortgage");
Video.SetFullScreen("Prime Time Mortgage", true);

Thanks!

Roboblue
02-13-2007, 05:50 PM
I found the problem. It was in the nTrayMenu = line. The wait for return line was set for false.
Since you are going to have more than on video on the page, build the menu function in Page-On Preload . Also, if you are going to be putting it on a removable drive, I would be safe and add the Global Variable _SourceFolder.. to the file path as shown below.
function TestyVids()
tblMenu = {};
tblMenu[1] ={};
tblMenu[1].Text = "Testimony 1";
tblMenu[1].ID = 100;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;
tblMenu[2] ={};
tblMenu[2].Text = "Testimony 2";
tblMenu[2].ID = 200;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

nTrayMenu = Application.ShowPopupMenu(120, 30, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true);
if nTrayMenu ~= "" then
if nTrayMenu == 100 then
Video.Load("Video1", _SourceFolder.. "\\AutoPlay\\Videos\\Prime Time Mortgage.wmv", false, false);
Video.Play("Video1");
Video.SetFullScreen("Video1", true);
elseif nTrayMenu == 200 then
---do something here
end
end
end
just use the function on the event (label click, button click, etc).
TestyVids()
Is the popup menu what you want?
Have you looked at the ComboBox?

KathyM
02-13-2007, 06:49 PM
This didn't work either. And I'm catching on to about half of what you are saying, it's a whole new language for me. Is there a way I can turn my project into an example that I can attach here for you to look at? The popup menu is perfect, it just doesn't play the video when clicked on. I looked at a Combo box but don't have a clue how to use it.

Roboblue
02-13-2007, 08:14 PM
Temporarily move all the vids out of the Video folder. Go to File-Export and export your project as an apz. Check to see how large it is as there is a 1MB limit to upload.
Or, move tyhe vids out and right click the Page tab in the project and choose Organize-Export and just export the page and upload it.
That should be enough to see what is going on.
If your video object is named "Video1", your video file is in the path you have typed in, and if the video file is named correctly, the above code should work.
In the meantime try this apz (just download and double click to start AMS, or, if .apz is not associated with AMS, do an "open With AMS all the time" thing when asked.
Put the Prime Time Mortgage.wmv in the AutoPlay\Videos directory of the project. It should work.

KathyM
02-13-2007, 09:58 PM
Yesss!! I think I figured it out. Your example worked perfectly, I copied your code into mine and it still did not work. Then I noticed that you had the video object actually on the page, I did not. Woohoo! Now it works, I just made the video object not visible. Now, I'll add another twist... when the video is playing full screen, if the user presses Esc on the keyboard, the video goes away but the audio continues. How do I have it stop completely and just return to the page?
Thanks for all your help!

Roboblue
02-13-2007, 10:07 PM
If it's running full screen, instead of Escape, double click anywhere. This will bring it back to the AMS window and you can just click the stop button on the player.
I would also make sure the Video object was set for not autostart in the Video-Settings window.

KathyM
02-14-2007, 08:07 PM
Double clicking produces the same result as the escape key, video stops but audio continues. Not only that, but my video is invisible on the page, so the controls would not work. Also, if the video is left to play all the way to the end, it just goes to black instead of returning to the page. How do I have it return to the page whenever it stops, either on it's own or by the user?

Roboblue
02-14-2007, 09:06 PM
To bring it back to normal size on the page, go to the Video object properties -Script-On-Finish and put
Video.SetFullScreen("Video1", false);
do the same in On Stop.

So, you have the player on the same page but invisible. Then when the user clicks on a label (or button?) it opens in full screen. Is this correct?
If so, now I see why you said it would still play the audio when you pressed Escape. It just goes back to normal when you press Escape. It's still playing, just that you have it invisible. Problem is, as long as it's modal (external from AMS or full screen in this case), it won't callback to the program.
What you will need to do is set up a timer that will monitor the Video.IsFullScreen status. You start Page.StartTimer on the same event as the starting the video. then stop the video and Timer when the video object comes back to the app window.
Here is an apz that works. The button code is the same, but the On Page code has the timer start in the menu ID selection. The timer code is in Page-On Timer.
I have also set the video object to go back to normal On Finish, On Stop, and On Click.
I think this is what you want.
I can also make you the same with a combo box if you like.

KathyM
02-14-2007, 11:31 PM
Thanks again, I think this will work. I need to digest this and play with it for a while. I have learned a ton in the last couple days. Do you know of a good book for beginners? Like Scripting for Dummies or something?

I will let you know if I run into any other problems.

Roboblue
02-14-2007, 11:41 PM
There is a book for LUA script that is pretty good. But the best way to learn as far as AMS is concerned is to just start reading the Help and doing the examples.
That will get you going and with some help from the gurus here, you may be ready for the LUA book in a couple of months.
You will be surprised at how much you can get out of AMS just from the Help examples.

bobbie
02-15-2007, 07:31 AM
Roboblue I'm trying to use the popup menu for this table but I can't seem to get it to write to the file on line 7 ?
well anyline. lol just a blank space where it should be.
What should I have here..
function TestyVids()
tblMenu = {};
tblMenu[1] ={};
tblMenu[1].Text = "Testimony 1";
tblMenu[1].ID = 100;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;
tblMenu[2] ={};
tblMenu[2].Text = "Testimony 2";
tblMenu[2].ID = 200;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

nTrayMenu = Application.ShowPopupMenu(380, 331, tblMenu, TPM_LEFTALIGN, TPM_TOPALIGN, true, true);
if nTrayMenu ~= "" then
if nTrayMenu == 100 then
text_contents = TextFile.ReadToTable("AutoPlay\\Docs\\Myfile.txt");
Table.Insert(text_contents, 7,"toolbar: red");
elseif nTrayMenu == 200 then
text_contents = TextFile.ReadToTable("AutoPlay\\Docs\\Myfile.txt");
Table.Insert(text_contents, 7,"toolbar: blue");
end
end
end

bule
02-15-2007, 08:25 AM
Thanks again, I think this will work. I need to digest this and play with it for a while. I have learned a ton in the last couple days. Do you know of a good book for beginners? Like Scripting for Dummies or something? .

Try this: http://www.lua.org/pil/

Or this: http://www.inf.puc-rio.br/~roberto/pil2/

Roboblue
02-15-2007, 10:34 AM
Bobbie
You forgot an action (in Red

text_contents = TextFile.ReadToTable("AutoPlay\\Docs\\Myfile.txt");
Table.Insert(text_contents, 7,"toolbar: red");
TextFile.WriteFromTable("AutoPlay\\Docs\\Myfile.txt", text_contents, false);

bobbie
02-15-2007, 10:48 AM
Thank you, that was it ..

KathyM
02-15-2007, 08:27 PM
Thanks, Bule. I will check these out.