Random Number Generation

For general questions about Content Authoring

Moderator: Nav

Random Number Generation

Postby mechler » Fri Feb 27, 2009 7:32 am

I've scoured the online help, pored through the SmartBuilder user guide pdf, and used the search function on this forum. If there is a way to generate a random number inside of SmartBuilder (without creating my own flash and using the API), I can't find it. Am I to suppose it isn't possible? The kinds of interactions that SmartBuilder is trying to create seem as if they could benefit strongly from this capability.

Any word? I appreciate your time considering and answering this question.
mechler
 
Posts: 1
Joined: Fri Feb 27, 2009 7:10 am

Re: Random Number Generation

Postby Nav » Fri Feb 27, 2009 10:49 am

That's a great question. A random number generator is something that does not exist, but needs to. I think I can create a pseudo widget fairly easily later today, but it probably won't be until around 3pm Pacific time. I'll repost here when I've uploaded it into the system with instructions on how to use it.

- Nav
Nav
 
Posts: 866
Joined: Mon Nov 05, 2007 2:58 pm

Re: Random Number Generation

Postby Nav » Fri Feb 27, 2009 3:36 pm

Update: Here is a video that shows you how to do this - http://screencast.com/t/TKgK1rM4l

Okay, there's a lesson in Shared Library > Examples > Examples using SDK objects called Random Number Generator (using SWF Messenger).

Check out the lesson to see how it works. You can save a copy of lessons in the Examples folder, and see how it's set up in the Action List.

The SWF Messenger is better documented here for its original purpose: http://www.suddenlysmart.com/forum/view ... enger#p876

But basically, all you're doing is sending information to and from a SWF. Now, this SWF has some special ActionScript code that grabs the information that you're sending, calculates a random number, and returns the result as an Event. You can use that Event to go to a random display, random page, or... well, that's all I can think of at the moment.

In order to set this up, you have to place the SWF Messenger widget on the stage and load this special SWF into it. This SWF is called Random Number Generator PseudoWidget, and is located in the Shared Library > Media & Assets > Sample Flash Animations (and source files) folder. Once properly inserted into the lesson, you have to set up an action that sends the SWF a message with the highest and lowest values that you want. Then it will return an Event whose name is that random number. You can use the getEvent method to utilize that number. Here's an example of how this would work:

Trigger: Randomize button > onClick
Response: SWF Messenger > sendMessage > name="1" ; value="5"

Trigger: SWF Messenger > onEvent
Response: Display Set > gotoDisplay > SWF Messenger > getEvent

Really this should be a proper widget, and not exapting the SWF Messenger widget, but this is easier, it works, and I'm still learning the widget API. This was a pretty high level description, so if you want a more step by step answer, or if anything is unclear, please feel free to ask. Also, if you have any more ideas for widgets, let me know!

- Nav
Nav
 
Posts: 866
Joined: Mon Nov 05, 2007 2:58 pm

Re: Random Number Generation

Postby Dan » Fri Oct 18, 2013 2:13 pm

Delayed reaction, but thank you for making this. It works really well and it's saving my bacon.
Dan
 
Posts: 10
Joined: Sat Mar 27, 2010 9:05 am


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Not able to open ./cache/data_global.php