A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: slow speed with large amount of text

  1. #1
    Senior Member
    Join Date
    Jul 2010
    Posts
    111

    slow speed with large amount of text

    Hi! I have some pretty crazy text manipulation code, lots of split/joins, html code adding, you name it.. but the larger amount of text that it is manipulating, the slower it processes. It is all dynamic, nothing as far as static or animation like. Also nothing actually has to 'render', all processing is off screen.

    I feel like there is a way to get it to process faster, just not sure what to do next. I've tried splitting the text into working with 1 paragraph at a time, setInterval with function()s, and those are working, but still has a hard time w/ lots of text.

    My question is, can anybody think of a way to somehow get it to process faster? Maybe doing its calculations in a separate movie clip or swf? Not sure what else to try.. maybe someone has some magic up their sleeve! Thanks!
    Last edited by sammy123123; 04-13-2012 at 09:58 PM.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I have had the same problem, only that the problem lied within the amount of text. The larger the amount, the slower the loading of the text, if that's what you're doing, loading external text into Flash? Though, I haven't come up with a solution yet!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Thanks man, I figured if anyone had an answer it would be you Well I will keep trying and will post to let you know if I figure something out

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    I don't know in what are you both working, but the first thing that came to my mind was, make a preloader (0% to 100%) to give some time to load all the text. Also, when you are not using the dynamic imported text, you may clear it, or put the dynamic text box "not visible". Also, you can change the values of the dynamic text box to Custom anti-alias or any other value and test. Hope this helps, in the meanwhile you post something about what you are working on. ^_^

  5. #5
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    The problem is that the text which is being imported into Flash in runtime, is taking some time to being imported into Flash, and he was asking if there was a way to make it load faster
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  6. #6
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Mmmm now i get it... i will be reading about that..hope there's a workarround. I don't know if the LoadVars or the LoadVariables functions are manipulable, like loading more faster, of if there is something like force scripts to execute faster...

  7. #7
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Hey, thanks for the tips.. actually, though, its not imported text i'm having trouble with. Its like this:

    Say I have a main textbox on stage.. well, off stage I have another textbox that i bring the text over to, then maniputate it, then bring it back to the main textbox. Reason for manipulating it in a textbox offstage is so the user doesnt actually see what's happening. Anyways, so its like for example:

    txtbox.text = "Hi, how are you today?"

    txtboxoffstage.text=txtbox.text
    txtboxoffstage.text=txtboxoffstage.text.split("Hi" ).join("Hello")

    txtbox.text=txtboxoffstage.text

    So, thats just a basic example.. everything 'works' okay, just imagine having lots (and i mean lots) of manipulation like this, which still works okay, except for when I have lots (and i mean lots ) of text. That's what ends up throwing me the error message "a script is causing flash player to run slow - abort script?", and indeed it is.

    I read that dynamic text boxes are slow.. should I be using variables or something for the manipulation instead? Oh btw, they are also within nested movie clips, is that my problem?

  8. #8
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Mmmmm.... I suggest instead of creating the dynamic text boxes manually on the stage, create them with action scripting, so you can delete them when not using them and free memory . Also avoid the use of "onEnterFrame" as much as it be possible with these dynamic texts, because it tends to that "a script is causing flash player to run slow - abort script" error.

  9. #9
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Thanks! I do try to clear them, for example, txtboxoffstage.text="" at the end.. but still. So, how do I create dynamic textboxes w/ actionscript? I never thought of doing something like that. Also, I do use onEnterFrames but then use an onEnterFrame=undefined when I need to stop it. I confess some places where I have code to manipulate textboxes I do have onEnterFrames, and some I have the code within a function, then use a set interval, like setInterval("function",1)e.g.. How do I avoid using these? gotoAndPlay frame skipping seems to make it slower. Thanks for the ideas

  10. #10
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    createTextField("dynamic_txt", 1, 10, 10, 150, 30);
    dynamic_txt.text = "Here's some text";

  11. #11
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Ok, thanks! I am now trying to change dynamic textfields to variables, which is seeming to work, but i am stuck.. how do I change replaceText to work with variables. Like:

    someField_txt.replaceText(targetString.indexOf("{" ) , targetString.indexOf("}")+1, newString)

    doesnt like the "replaceText"

  12. #12
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    replaceText only works with text fields, so with variables, you would have to do it manually:

    Actionscript Code:
    myvar = myvar.substring(0, targetString.indexOf("{"))+newString+myvar.substring(targetString.indexOf("}")+1, myvar.length);

    Also, for the Script running slow message, that's usually caused by using a never-ending loop. You have somehow triggered an infinite loop somewhere in your code, try to look for it, something like a large for or while loop with an undefined conditional variable or two functions executing each other.
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  13. #13
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Thanks a ton for the replaceText to variable workaround

    I have thought of that neverending loop, but it actually ends because it works every time except for when I have a ton of text.. its like it almost chokes on it.. but when you press 'no' (dont cancel script) it eventually works. It does happen, though, when its running a 'while' condition. Are you saying I should somehow end this with a conditional statement? As it is now, it goes thru the 'while' thing until its basically done with it (like while(number<25)) - then it just naturally goes to the next frame or whatever.. should I actually 'stop' on the frame, then when it's done with its 'while' actually tell it to go to the next frame?
    Last edited by sammy123123; 04-18-2012 at 09:37 PM.

  14. #14
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Could you share your FLA file, because I would like to see this while loop myself

    EDIT: Post #1337, I am elite ;D
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  15. #15
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Hey Nig, I would attach but unfortunately (or fortunately depending how you look at it) there's so much going on that it would be just way too confusing.. even I dont always remember what I coded half the time.. know what i mean?

    I can post a snippet, or the code that's in the frame if you want.. but it's basically:

    number=0
    while(number<20){
    does a bunch of junk
    number=number+1
    }

    What ended up happening is, i was making it do a bunch of stuff before getting there, then it got there, and had more than a handful to do both before and there, so just asking too much of it to do at once.. im working on reducing the amount it has to do all at once, and other tricks to deal with large amounts of text. The changing from textfields to variables is helping a ton.. thanks again for that replaceText to variable code
    Last edited by sammy123123; 04-19-2012 at 05:13 PM.

  16. #16
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Great you are solving your problem , always there is a workarround

  17. #17
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Thanks for all your help angel

  18. #18
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    even I dont always remember what I coded half the time.. know what i mean?
    of course I do. I made this game for someone a while ago, and when he asked for me to change some of the stuff and gameplay, I didn't understand my own coding at all
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  19. #19
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    I know! I have only 3 words..

    //comment
    //comment
    //comment

    U think I take my own advice?! Noooo!

  20. #20
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center