Conditional Actions


(moshe_caine) #1

Hi there.
The more one works with Hype, the more one loves it. At the same time, one discovers little things which are sorely missing. One of these is the conditional response: "if… then, else…"
I assume this is possible with Javascript, however it would great to have this built into the Actions Inspector.
The uses for this function are endless and would greatly enhance interactive functionality.
Thanks.


#2

Thanks for the suggestion, Moshe!

Can you give me an example of an if/then interaction you would like to create?


(moshe_caine) #3

Hi Daniel.
thanks for the quick response.
The obvious conditional interactions are the on/off - toggle type, such as:

  • Toggle visibility of an object.
  • Toggle sound.
  • Toggle color of element
  • Start/Stop play of timeline.
    The more sophisticated could include:
  • Drag to element on screen. If the locX>100 and <200 then play sound 1, else play sound 2
  • Conditional action based on user response: if (age entered) >18 then go to scene “adult”. else go to scene “child”
  • Game scenario: response of the game based on the time elapsed to perform chosen action.

Obviously, many more possibilities.
As you can guess, I used Macromedia (Adobe) Director for many years. Hated Flash and I look at Hype as the closest replacement.
Thanks.
Moshe


(Joan Deppa) #4

Hi, Daniel,
I agree with Moshe’s suggestion. In my interactive grammar book, I want to be sure that students identify the correct answer before going to the next scene. I came up with a workaround that doesn’t really do the trick. An if-then statement should do the trick. Like Moshe, I’m a veteran of Macromedia Director and before that, HyperCard.


#5

I like the idea but I see immediate issues - referencing objects and making simple calls.

Let’s take the example of @moshe_caine “Toggle the visibility of an object.”

OK - which object? The object to hide may not necessarily be the one acted upon.
How do You reference this other object? What is being shown above is more of the HyperTalk approach - now we have another layer - a second language - to create and implement. This type of scenario seems to invite complexity rather than simplicity - and it will always be crippled by limited capabilities (you’ll always wish it did more).

On the other hand this situation is easily handled by jQuery using toggle().

Clicking the “Button” shows/hides paragraphs (in this case) based on current visibility… could be triggered by a timeline function instead (no “click” function obviously).

$("button").click(function(){
    $("p").toggle();
});

You could substitute fadeToggle() or slideToggle() for toggle().

This is not hard or arcane. I am a visual~design oriented person - even I can cover these scenarios.

Ditto the other examples - basic jQuery coding that also offers far more extensibility.

================================

HyperTalk is still the “Gold” standard in my opinion for the ease of use/power ratio:

Send "doMenu" to card btn "Total"

So easy to envision & create - I wish it wasn’t a thing of the past. Thank You Dan Winkler & Kevin Calhoun - simply brilliant.


(moshe_caine) #6

Hi.
I too grew up on HyperCard and HyperTalk.
Simple, logical and even a non programmer like me could write it.
When it finally died I jumped over to Lingo and Director, which served me for some twenty years.
I suppose I should buckle down and simply learn java script.
Moshe


#7

@moshe_caine

Hi Moshe!

I suppose I should buckle down and simply learn java script.

May I suggest utilizing the jQuery library? jQuery’s mantra is “Write less, do more” and I have found it makes JavaScript far more accessible.

Along these lines there is a book I would highly recommend: “JavaScript & jQuery - The Missing Manual”. Here is a link to it on Amazon. I found this book to be well suited as an intro on these subjects, particularly for those with a designer bent.

The first part of the book shucks the core concepts of JavaScript down to the cob - without getting bogged down in minutia. Lots of examples… cogent & lucid.

The rest of the book is devoted to utilizing jQuery. Again, lots of practical examples & tutorials - well explained - with a generous amount of info on animating elements.

While jQuery doesn’t turn JavaScript into HyperTalk I found it makes utilizing JavaScript far easier.


(moshe_caine) #8

Thanks Jim, for the suggestion and link.
Shall certainly give it a try.
Moshe


(moshe_caine) #9

Hi Jim
Success.
Many thanks.
Moshe