Source language: Translate to:

action command with graphics

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

action command with graphics

Postby stevec » Fri Feb 16, 2007 11:23 pm

Is there a way to do the following.
I have a pub that I'm working on, that I'd like to have a "Channel selector", I have created 6 images of the selector, each with a different orientation. 12 o'clock, 2 o'clock, 4, 6, 8, and 10 o'clock.

What I'd like to be able to do is this. Start with the first image [12 o'clock] and then if I clcik on it, have it change to the next image [2 o'clock, and do some simple commands, show a picture], then if clicked on again, change to the third image [4 o'clcok] and then so forth.

The images that I created are transparent png's.

Anyone, played around with this?

Thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby Cipolla » Sat Feb 17, 2007 4:30 am

Hello Steve,

i think an easy way would be to show/hide the images.

First put all images on stage in the same position and hide all exept the on you want to show (12 o´clock)

in the click action of the image put your code to HideObject [self]
and ShowObject the next one ( in your example 2 o´clock) and so on.

Another methode i used in the past for image cycling:

Define your pictures i.e. in Startup section:

(The fullpath could be [pubdir] or [temp] if you embed your images)

Code: Select all
Setvar "[Image1]" "[Fullpath]image1.png"
SetVar "[Image2]" "[Fullpath]image2.png"
SetVar "[Image3]" "[Fullpath]image3.png"

GetArrayInfo "[Image]" "" "" "[ImageTotal]"
SetVar "[ImageNr]" "1"
SetVar "[ThisImage]" "[Image[ImageNr]]"
...


Then put a picture object on stage with [ThisImage] for the Image File
and put some actions in the click section:

Code: Select all
GoSub "ChangeImage"
...
...Your actions here


And the actions to change the image in a subroutine:

Code: Select all
:ChangeImage
If "[imageNr]" ">=" "[ImageTotal]"
 SetVar "[ImageNr]" "0"
EndIf
SetVar "[ImageNr]" "[ImageNr]+1"
SetVar "[ThisImage]" "[Image[ImageNr]]"
Return


A little bit more code, but more flexible and if you have many pictures you only need one PictureObject on Stage.

The nice think about this is, that you can build the [Image]-array on the fly if you put all images in a seperate folder. The action in the Startup-section would then look like this:

Code: Select all
FileList "[YourImageFolder]\*.bmp" "Files" "[result]"
StrParse "[result]" "[#13]" "[Image]" "[ImageTotal]"
SetVar "[ImageNr]" "1"
SetVar "[ThisImage]" "[Image[ImageNr]]"
...
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Thanks

Postby stevec » Sat Feb 17, 2007 7:42 am

Cipolla.

Your right.
"i think an easy way would be to show/hide the images.

First put all images on stage in the same position and hide all exept the on you want to show (12 o´clock)

in the click action of the image put your code to HideObject [self]
and ShowObject the next one ( in your example 2 o´clock) and so on."

Thats what I did. It would be an nice feature to have a mulitple click button function, for stuff like this. Like a 1st click, 2nd click, 3rd click command. and you'd be able to tell it how many clicks were required.

I'll definetly try the code you posted.
Thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Your code

Postby stevec » Sat Feb 17, 2007 8:23 am

:lol: :lol: :lol:

It works like a charm.
Just 1 additional question.

If the image is 1, how can I tell it to show another picture?
Should that be in the subroutine?
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

I got it.

Postby stevec » Sat Feb 17, 2007 8:31 am

Here is the additional code in the subroutine;

:ChangeImage
If "[imageNr]" ">=" "[ImageTotal]"
SetVar "[ImageNr]" "0"
EndIf
SetVar "[ImageNr]" "[ImageNr]+1"
SetVar "[ThisImage]" "[Image[ImageNr]]"
If "[imageNr]" "=" "1"
HideObject "Picture2" "None" "0"
HideObject "Picture3" "None" "0"
HideObject "Picture4" "None" "0"
HideObject "Picture5" "None" "0"
HideObject "Picture6" "None" "0"
Else
EndIf
If "[imageNr]" "=" "2"
ShowObject "Picture2" "None" "0"
Else
If "[imageNr]" "=" "3"
HideObject "Picture2" "None" "0"
ShowObject "Picture3" "None" "0"
Else
If "[imageNr]" "=" "4"
HideObject "Picture3" "None" "0"
ShowObject "Picture4" "None" "0"
Else
If "[imageNr]" "=" "5"
HideObject "Picture4" "None" "0"
ShowObject "Picture5" "None" "0"
Else
If "[imageNr]" "=" "6"
HideObject "Picture5" "None" "0"
ShowObject "Picture6" "None" "0"
Else
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf


Return

Thanks;
Steve Christensen
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Postby cp4w » Tue Feb 27, 2007 7:05 am

Another tip

My English is very poor. I try to let me understand.

You must rename your image files; e.g. Image1.jpg, Image2.jpg, Image3.jpg, Image4.jpg, Image5.jpg, Image6.jpg, Image7.jpg


You have to select the Picture Tool and write as file name YourPath\Image[n].jpg

In the action command of the page (Page Enter): SetVar "[n]" "1"

In the action command of the picture object:

If "[N]" "<" "7"
SetVar "[n]" "[n]+1"
Else
SetVar "[n]" "1"
EndIf

You have only to remember to insert the 7 files in a page you never enter in, so Nobook compiles them in the EXE

Licia
cp4w
 
Posts: 533
Joined: Sun Apr 03, 2005 4:37 pm
Location: Great Neck, NY


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests