Page 1 of 1

Random Number Generation

PostPosted: Fri Feb 27, 2009 7:32 am
by mechler
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.

Re: Random Number Generation

PostPosted: Fri Feb 27, 2009 10:49 am
by Nav
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

Re: Random Number Generation

PostPosted: Fri Feb 27, 2009 3:36 pm
by Nav
Update: Here is a video that shows you how to do this -

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: ... 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

Re: Random Number Generation

PostPosted: Fri Oct 18, 2013 2:13 pm
by Dan
Delayed reaction, but thank you for making this. It works really well and it's saving my bacon.

Not able to open ./cache/data_global.php