PDA

View Full Version : Help with text effect function.


gladius
02-07-2009, 08:30 PM
Hello guys,

I'm new on this forum but I have some basic skills with AMS. Now i'm using AMS 7.5 and I'm trying to find a way to solve a very simple problem with this function, that add a typing effect to the text:

function efeitotexto ()
cont = 0
texto = Paragraph.GetText("Paragraph1");
menssagem = "Any message here"
total = String.Length(message);
for cont = 0, total do
escrever = String.Left(menssagem, cont);
Paragraph.SetText("Paragraph1", escrever);
Application.Sleep(120);
end
end

Is there any other way to pause the script for a short time instead of using application.sleep? like, i want the delay time but without freezing the application. I attached my project here. Please help.

Sorry my english.

Gladius

holtgrewe
02-08-2009, 01:41 PM
One way would be to use the page timer to accomplish this.
Place your code for the message On Show then place your loop within the page timer script. Place the code that you have in the function ON show as well. The button would then start the page timer, instead of calling the function.

If you need the page timer for other things also, you can make each code structure dependent on a switch that you can turn on/off; or you can search the forum for multiple-timer options/offerings.

An example in your apz with a dependancy switch, the On Timer code could be:
if delaySw == 1 then
if cont < total+1 then
escrever = String.Left(message, cont);
Paragraph.SetText("Paragraph1", escrever);
cont=cont + 1
end
end
with the Page.StartTimer(120).
To stop the text effect, you may turn off the delaySw or set cont > total...

I hope that gives you some idea.

P.S. Welcome to the forum.

gladius
02-08-2009, 03:52 PM
Hello guys,

Thank you for the help holtgrewe but this is not working (Am I doing something wrong?:huh). Below is my code ( I changed some things):

On show
-- function for the text effect
function efeitotexto ()
-- counter
cont = 0
-- string that hold the message for the paragraph1
texto = Paragraph.GetText("Paragraph1");
message = "Any message here"
total = String.Length(message);
end


On Timer
delaySw = 1
efeitotexto()
if delaySw == 1 then
if cont < total+1 then
for cont = 0, total do
escrever = String.Left(message, cont);
Paragraph.SetText("Paragraph1", escrever);
cont=cont + 1
end
end
end


Plugin2
Page.StartTimer(120)


I attached the program if you guys want to take a look.


Gladius

longedge
02-08-2009, 04:40 PM
Did you mean that your application stops responding? Try -

In preload -
message = "Mamae te amo\r\n\r\nvoce é a melhor mae do mundo\r\n\r\n beijos, murillo S2"
total = String.Length(message);
cont=0
-- Not the place that I would normally put functions.
function efeitotexto ()
escrever = String.Left(message, cont);
Paragraph.SetText("Paragraph1", escrever);
cont=cont+1
if cont==total then
Page.StopTimer()
cont = 0
end;
end;

In page timer -
efeitotexto ()

In the button on click -
Paragraph.SetText("Paragraph1", "");
cont=0
Page.StartTimer(100

gladius
02-09-2009, 12:49 PM
Thank you longedge, now its working the way I wanted (without freezing the program while showing the message).

Below I attached the program done for those who want it!

Thanks again guys for all the help!


Gladius