Adding Code to Setup the Application Once it is Launched

At this point your Video Player application is working in the Revolution IDE and you are just about ready to build an application that you can share with others. The final step is to write a little revTalk that will populate the video menu and load the first video when your application is launched.

Edit Card Script

Edit Card Script

With the Video Player Stack window as the frontmost window choose Object > Card Script.

Define preOpenCard Message

Define preOpenCard Message

When a Stack window is about to be opened up and displayed on the computer Revolution sends the preOpenCard message to the Card that is about to be shown. This is a good place to initialize the menu and load a video.

To initialize the menu all we need to do is call uiPopulateVideoList (1) as that reads in the list of video files and populates the menu.

After the menu has been populated we can load the first video in the list. Before we load the video we check to make sure that at least one video exists in the menu. Checking that the text of field "Video Menu" is not empty (2) accomplishes this. If the text property of the field contains any text at all then there is at least one video file.

After confirming that there is at least one video we use revTalk to change the line that is selected by setting the hilitedLIne property of the list field to 1 (3). This selects the first line of the list field.

With the first line selected we finally call uiLoadSelectedVideo which loads the currently selected video in the menu (4).

Copy & Paste Into Card Script

on preOpenCard

## Load the video list

uiPopulateVideoList

## If there is at least 1 video in the list then load the video

if the text of field "Video Menu" is not empty then

set the hilitedline of field "Video Menu" to 1

uiLoadSelectedVideo

end if

end preOpenCard

Compile The Script

Make sure and compile the Card script after adding the above revTalk.

2 Comments

Marcus

I have put code in preopen of a card, applied it and put a break point in it. To run my app I just click the run tool. My break point is never hit. I am running my programs wrong?

Hanson Schmidt-Cornelius

Hi Marcus,

the preOpenCard or preOpenStack handlers are called before the stack or card are opened. This would be the place to put code if you want it to be called when someone starts your application or moves to a particular card.

Once you application has been stared, these handlers are not called by default, except if you moved to a particular card that has a preOpenCard handler.

You can set breakpoints in these handlers but selecting run mode will not make your application hit these break points.

You would have to interact with your application to move to a particular card with a preOpenCard handler, or you have to call the preOpenStack handler.

You can call the preOpenStack handler from code or enter "preOpenStack" into the Message Box.

Kind Regards,

Hanson

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.