00:00
00:00
Newgrounds Background Image Theme

kyzakay just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Random messages to appear on frame

811 Views | 10 Replies
New Topic Respond to this Topic

Ok, so i want the script that when you are on a stopped frame, the MC will span other "random" messages made in the libary.
Or some similer way of producing "random" messages already in the libary.

Does anyone know the script?


This is my Signature. Signature it is.

Response to Random messages to appear on frame 2006-07-30 13:31:38


Make an array and push all the phrases you want in the array. Then just set the variable of a textbox (where you want the messages to appear), and randomize the length of the array.

Response to Random messages to appear on frame 2006-07-30 13:38:48


At 7/30/06 01:31 PM, Darkfire_Blaze wrote: Make an array and push all the phrases you want in the array. Then just set the variable of a textbox (where you want the messages to appear), and randomize the length of the array.

Er, whats an "array"?


This is my Signature. Signature it is.

Response to Random messages to appear on frame 2006-07-30 13:41:10


var aText:Array = new Array(
"text1",
"text2",
"text3");
dynamicText.text = aText[Math.round(Math.random()*aText.lengt
h)];


BBS Signature

Response to Random messages to appear on frame 2006-07-30 13:44:24


Arrays are a collection of values, accessed in a single variable.
AS: Arrays, by Denvish

Like what Viktor has done above me, you can use it to store a large collection of a single type of data (like, text messages) in a single variable, and access them using aText[x] where x is the value you want to access (starting at 0 going up to the length of the array).

See Denvish's topic for more info.


...

BBS Signature

Response to Random messages to appear on frame 2006-07-30 14:01:41


Like what Viktor has done above me, you can use it to store a large collection of a single type of data (like, text messages) in a single variable, and access them using aText[x] where x is the value you want to access (starting at 0 going up to the length of the array).

See Denvish's topic for more info.

I still dont get it.
How do i put a text into an array?


This is my Signature. Signature it is.

Response to Random messages to appear on frame 2006-07-30 16:41:04


Can someone lay out what to do to make a random message to me in very clear steps.
Im a total noob when it comes to actionscript.
Its like trying to read a foreign language(without any training!)


This is my Signature. Signature it is.

Response to Random messages to appear on frame 2006-08-04 15:39:08


At 7/30/06 04:41 PM, -Edward- wrote: Can someone lay out what to do to make a random message to me in very clear steps.
Im a total noob when it comes to actionscript.
Its like trying to read a foreign language(without any training!)

...anyone?


This is my Signature. Signature it is.

Response to Random messages to appear on frame 2006-08-04 17:08:12


Giving people code is like giving coke addicts crack, it only solves the immediate problem.

Within whatever movieclip you're putting this in and on whatever frame you are putting this in, put a text box where ever you want it. Make it a dynamic textbox with the properties inspector. In the low corner, assign it the variable name display. Then, on the timeline in that same frame, put this code.

var messages:Array = new Array(
"Your first message",
"Put them all in double quotes",
"Follow them all with commas",
"Except the last one",
"You can do this as long as you like."
"The last one needs a close parentheses and a semicolon",
"Like this");

var timelimit:Number = The Number of Frames Before It Switches Messages
var countdown:Number = timelimit;

this.onEnterFrame = function() {
countdown--;
if(countdown<=0) {
display = messages[Math.floor(Math.random()*messages
.length)];
countdown = timelimit;
}
}

Ok, that's the code. But please note that if the movieclip you put it in already has an onEnterFrame function, this will erase it in favor of this new one.

Say thank you to the drug dealer.

Response to Random messages to appear on frame 2006-08-04 17:10:32


Actually, change that code a little bit. Where it says

var countdown:Number = timelimit;

change that to

var countdown:Number = 0;

Ok, now say thank you to the drug dealer.

Response to Random messages to appear on frame 2006-08-05 08:13:10


At 8/4/06 05:10 PM, Fat_Lifeguard wrote: Actually, change that code a little bit. Where it says

var countdown:Number = timelimit;

change that to

var countdown:Number = 0;

Ok, now say thank you to the drug dealer.

Thank you drug-dealer. Same time next week?

PS:thanks, the code did work this time.


This is my Signature. Signature it is.