Help with text effect function.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • gladius
    Forum Member
    • Feb 2009
    • 30

    Help with text effect function.

    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:

    Code:
    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
    Last edited by gladius; 02-09-2009, 11:50 AM.
  • holtgrewe
    Indigo Rose Customer
    • Jul 2002
    • 779

    #2
    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:
    Code:
    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.
    Last edited by holtgrewe; 02-08-2009, 12:45 PM.

    Comment

    • gladius
      Forum Member
      • Feb 2009
      • 30

      #3
      Not Working

      Hello guys,

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

      On show
      Code:
      -- 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
      Code:
      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
      Code:
      Page.StartTimer(120)

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


      Gladius
      Last edited by gladius; 02-09-2009, 11:50 AM.

      Comment

      • longedge
        Indigo Rose Customer
        • Aug 2003
        • 2498

        #4
        Did you mean that your application stops responding? Try -

        In preload -
        Code:
        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 -
        Code:
        efeitotexto ()
        In the button on click -
        Code:
        Paragraph.SetText("Paragraph1", "");
        cont=0
        Page.StartTimer(100

        Comment

        • gladius
          Forum Member
          • Feb 2009
          • 30

          #5
          Thank you

          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
          Attached Files

          Comment

          Working...
          X