A Flash Developer Resource Site

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

Thread: Flash MX Dynamic text

  1. #1
    Junior Member
    Join Date
    Dec 2003
    Posts
    14

    Flash MX Dynamic text

    Hi.

    Im working on a project for a company im employed with and I am having some difficulties with dynamic text. I have a dynamic leaderboard that reads an array of names, scores etc from a local file. When it does that , I am creating a horizontal panel with a few graphics and 5 dynamic text fields where I put player name, score rank etc. The problem is that when I scroll those names, and when I have lots of names then the resource consumtion peaks 100%. I cannot allow that because we have other equipment hooked up to the PC and it gets messed up when Flash hits 100% in resource consumption.
    I have tested this leaderboard with different data/fonts etc. These are the conclusions:
    - If i scroll the leaderboard without any text (dynamic text fields are there, I just disabled the action script assigning value to it), then I peak out at 35% resources
    - If i only show 1 field with only 1 number/character, I peak out at 38%. Each additional character adds approximately 2% to the total resource consumtion.
    Embed Font Outline is set to ALL CHARACTERS everywhere - that seem to be taking least resources. If I change Embed Font Outline to NONE - it doesnt show anything at all, if i change it to certain characters, it uses even more resources then ALL CHARACTERS.

    My question is:
    Is there any way I can lower teh resource consumtion related to the number of characters displayed at one time on the screen on a fixed amount of dynamic textboxes?

    I am using Flash MX version 6, I recompiled my source file using flash MX 2004 and played it on newest flash player 7 with no visible improvements.
    My system specs:
    Intel P4 2.4Ghz
    512Ram
    40G HDD
    ALLINWONDER 9000 Video Card with 64Mb memory

    All drivers are up-to-date.
    Thanks for any help.

    James R.
    Attached Images Attached Images
    • File Type: jpg 2.jpg (72.2 KB, 51 views)
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Location
    Houston TX
    Posts
    563
    This is one of the problems Flash has with scrolling dynamic text boxes. It takes processor time to rasterize the screen each time you scroll and the more entries you have the worse it is going to get. At this time I do not know of any work arounds. This maybe one of the times you call Macromedia for help.

    www.tobymack.com
    www.e4net.com
    Best regards
    Toby Mack

    For the best and funniest Audio Blog on the Internet come visit:

    http://feeds.feedburner.com/Fla****UpBlog

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    351
    how do you scroll the text?
    is it an on enter frame event?

  4. #4
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    I am scrolling the text with code. I have an array of predefined _y coordinates.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  5. #5
    Senior Member
    Join Date
    May 2001
    Posts
    351
    so you have to loop throught the array of y coordinates?

    are you using objects?

    somewhere in there, there has to be some sort of holder clip
    the one that holds ALL text fields and graphics
    and then your just moving the one clip that holds everything

    and then you say, when click up arrow, go to y_cord_array[3];
    or something like that

    am i close?

    scrolling with code isnt very detailed

  6. #6
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Okay. I will try to explain the system in detail.

    I have one object. It contains some shapes as background plus few (5 at the moment) dynamic textboxes. at the beginning, I load an array of player names, scores blah blah. After that I duplicate that single object to fit on the visual plane ( I do not create as many objects as there are players becuase there can be maximum 10 objects visible at the same time). After that I create 2 arrays and calculate _y coordinates - one array will have original _y coordinates that never change, the other will be decreased by 2 pixels, its the one i will use for scrolling. After an object scrolls outside the boundaries (another variable holds the value for this) I assign a _y coordinate from the original array, slap a new player name and stats on it and scroll from the beginning. That way I reuse the object that is no longer shown.
    So, the big issue is in the following:
    if there are approximately 8-9 objects scrolling at the same time, each object has around 6 shapes and 5 dynamic text boxes, then they slow down a bit, and on rare ocasions freeze to a crawl for a second or two. This ONLY happens when the objects fill in the visual pane completely. As a comparison, imagine you just finished watching a movie, and now the list of people that acted in that movie starts scrolling up from the bottom. The first few are ok, but when the screen is filled with names, then it starts to slow down a bit, jerk around, and sometimes freeze for a split second.
    I have tried to create one object, a movie clip, and fill that object with my little objects that contain player names etc etc and scroll that one big clip instead of controlling each individual small object, but it showed same results.

    I hope I was descriptive enough
    Thanks again for any help!

    James R.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    351
    i am going to run a little test of this, just to see how performance is affected

    i would think that if this movie runs inside another movie, your losing performance through that also

    but for my test, i am going to just load a bunch of names similar to your movie credits example

    on thing i guess i would do during my testing, is to not use any array for coordinates
    either your moving it up or down by 2 pixels
    i like to use empty movie clips, load where you want the names to start appearing, and use a mask to just show those visible

    i may even try to do a hit test on the mask, and make visible only if hit test returns true
    but im not sure if thats possible, using a mask for hit test

    ill post my movie url

    dan

  8. #8
    Senior Member
    Join Date
    May 2001
    Posts
    351
    are you using custom objects, or straight code library stuff?

  9. #9

  10. #10
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Not sure what you mean by custom object or straight code.
    I will post a link to the swf file once I go to work, I have been sick for a couple of days.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  11. #11
    Senior Member
    Join Date
    May 2001
    Posts
    351
    by custom objects, i mean a class that does things for me
    i have a box that i can resize, recolor, move, things like that

    straight code is using no objects, using library resources, having seperate things in the library for each part of your app

    with the object methods, i have one box and change the sizer and color for different things
    i am curious if here are any performance advantages using this technique

    i wanted to do the scrolling thing with different techniques to test that
    youll see if you make 100 names to scroll, it does get slower
    the current version does not remove things outside the mask
    thats another thing i wanted to test

    i was hoping you could give some feedback on the swf i made so to accurately test what your doing

    hope you feel better

  12. #12
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Thanks my friend. I feel better today, although still at home, recovering from having over 39 celcius temperature for 2 days.
    Your swf file is pretty close to what I have made except that its used more like a text box, my project is not user interactive. There is no way for anyone to interact with my flash. Imagine this situation:
    Bar, 10pm, football (or hockey, baseball, soccer etc) playoffs. Lots of people cheering for their favorite team, drinking booze and spending money.
    Before the game starts, people can play a game and guess whos gonna win, with what score, etc etc (we use separate equipment for this stage). So when the game actually starts, we have a list of player names, their picks and we got a life feed from the game. By comparing life feed/player results/score value from our database we come up with current scores. So the player scores change as soon as anything happens in the game (or rather as soon as the life feed arrives to our computer). When a commercial starts showing on the TV, our game administrator turns off TV feed and replaces it with flash feed, and at that moment we see the leaderboard with peoples names, scores, rank etc. This is a good way for people who are inbar to see their scores while the game is still live. There is no interactivity because we use flash to only show results/adds, like a weather channel.

    To answer your question, Im not using objects or separate classes. I have recently purchased OOP with Flash (forgot who the author is, I htink O'Reily), and am reading on it. Right now, everything I use is in the library.

    Thanks for your help and Happy New Year
    James R.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  13. #13
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Hello again. I am back at work and I have uploaded the file to my geocities account. Heres the link

    http://www.geocities.com/jimmyman99/sp/HB2_PS2.swf



    http://www.geocities.com/jimmyman99/sp/HB2_PS2.swf


    Thank you,
    James R.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  14. #14
    Senior Member
    Join Date
    May 2001
    Posts
    351
    i get 'page unavailable'

  15. #15
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Very weird, but I click on the link i pasted above, I see geocities error page telling me that page doesnt exist. If I cut and paste the URL (which is the same) it still says that page doesnt exist. But If close the browser, open a new one and then cut/paste the URL then it works fine...
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  16. #16
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    BAH You posted right before me! LMAO
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  17. #17
    Senior Member
    Join Date
    May 2001
    Posts
    351
    cool, that is a weird thing though, cut and pasting in a new browser

    so it appears to work
    does it still seem slow?
    whats the issue?

  18. #18
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    I described the issue in my post #1. The file that we currently have is working fine, it does everything I wanted it to do.However, when we play this swf file (the one I posted the link to) and when the leaderboard is filled with player names, then we peak CPU usage at 100%. We have some other equipment hooked up to the computers that play these swf files and when that computer CPU usage hits 100%, that equipment starts lagging behind, causing us major problems.
    I have tracked down the problem to the dynamic text. as you can see on the leaderboard, each player has a separate object that holds players name, scores etc. That object has some graphics (as a background and eye candy). Each object has 5 dynamic textboxes. There can be maximum 9 objects visible on a screen at a time, that means we have 45 dynamic textboxes scrolling simultaneously. That cause the biggest drain on CPU usage. Once I take out the dynamic text boxes, CPU usage is very low. If I remove graphics but leave the text boxes, CPU usage is still very high. So, I came to a conclusion, that dynamic textboxes dramatically increase CPU usage.
    Last edited by JimmyMan99; 01-06-2004 at 01:42 PM.
    -----
    If its not broken, then break it, fix it and bill it.
    -----

  19. #19
    Senior Member
    Join Date
    May 2001
    Posts
    351
    at home i can work on it a little more to test the one thing that MIGHT help

    its an oop approach, but i use a one character dynamic text movie clip and then i set its formating properties for the font size, color, max width and label

    by reusing one clip multiple times, it would avoid having 5 different text boxes per line

    you can do it woithout the oop approach, but its easier to say setFontSize rather then duplicating all the code necessary for setting a text format
    plus it lets you swap out the fonts pretty easy

    since it scrolls non-stop, the onEnterFrame event is always running
    its prolly still going to peak, there may be no way around that
    but thats just a guess

    unless you destroy clips when they arent visible and reload them JIT, right when you need them

    just trying to limit resources

    hopefully none of the other graphics have events or are moving
    be sure your killing all your onEnterFrame
    or are the surrounding graphics tweened?

  20. #20
    Junior Member
    Join Date
    Dec 2003
    Posts
    14
    Yup, all other graphics are tweened
    I have no onEnterFrame

    I will try to explain the method I am using for scrolling. I am not the best person for explaining things, so please forgive me if I confuse you or bore you to tears.

    I will just explain the scrolling of the "panels". Panel is one object that holds Player name, score, rank and also panel has some shapes as a background eyecandy. "Panel" is just like name tag grocery store clerks wearon their shirts.
    Right now I have 9 panels on the screen (1.jpg). When the swf starting, it disables (visible=false) all but the bottom one. Then I put values into the bottom panel, values like player name, player score etc. Then I scroll all panels, but since all of them are invisible you dont see it, you only see the one that was outside the visibility range appear as it scrolls from the bottom(lets call it panel1. Number increases as we go up, so the panel above panel1 is panel2, panel3 is above panel2 etc).
    When Panel1 reaches position Panel2 originally (originally is the location of the panel before we did any scrolling) used to be (since we scroll all panels, panel2 is where panel3 used to be, panel3 is now in the place where panel4 was, panel4 is where panel5 was etc) then i swap values of textboxes from panel1 to panel2, move panel1 to its original location (at the bottom, we cant see it) slap new player name, score, rank etc. At this moment we have 1 content (by content i mean player name, score, rank etc) visible on the screen, and another name is outside the visual range.
    Now we continue scrolling, panel2 scrolls up to where panel3 original location was. At the same time panel1 scrolls from outside into the visual range and it scrolls to where panel2 originally was. At this point we give content (name, score rank etc) of panel2 to panel3 and panel1 to panel2, move all panels back to their original location, give panel1 new content. so now we already have 2 names visible on the screen, and 3rd one ready to be scrolled into visual range.

    I do the same thing with the rest of the names, give a new content to the panel at the bottom, scroll panel untill it reaches the location panel above it used to be, pass the content to the panel above it, move back to original location, get new content... blah blah...

    Needless to say, I disable all panels that do not have name, so we dont see empty panels (panels with background but no content) scrolling along.

    I know this method is not very effective. I used it before I knew AS very well. I will probably modify for it to scroll all the way outside the visual range and not scroll a bit up, pass content to your neighbour, move back to original location, get new content.
    However, I tried something similar to this and it still produced similar results in CPU usage.

    I am reading Object-Oriented Programming with ActionScript by Branden Hall and Samuel Wan, first edition, sep 2002. It is a bit complicated subject for me though and im going through it very slowly.

    I am talking to my management if they could allow me to post a source file for this leaderboard.

    Sorry if I have confused anyone

    Best Regards,
    James R.
    Attached Images Attached Images
    • File Type: jpg 1.jpg (64.5 KB, 23 views)
    -----
    If its not broken, then break it, fix it and bill it.
    -----

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