I am currently using the fl.controls.DataGrid in my as3 application. In addition to very frustrating bugs, it seems to have very bad performances especially when your data size increases.
Is there a simple way to make an efficient datagrid with as3?
The best success I have had is with setting as few of the properties as possible, tying the data to a simple AS object class that contains only the data properties and writing it directly to an ArrayCollection. If your class includes a 'label' property you can pretty much get away without setting anything but the dataprovider (which I emphasize should always be an arraycollection; I forego the creating an array then 'wrapping' it in an arrayCollection) but having a tightly bound model for the data seems to improve the useability. I have heard that using xml data offers a slight improvement, but I prefer pure AS classes, which outperform mxml by a mile.
It always has been that all my AS3 woes stem from the display end of things. Pure AS3 would be a God-send if they could come up with a replacement for mxml.
P.S. avoid item editors! they work great if you only have 50 records, but the grids are designed to DISPLAY data ((a pure text grid of 250k records should scroll fine....) Always edit the data, not the grid. Pull the data into a form to edit. The data binding will take care of updating the grid.
Related
I'm writing a graphic console that highlights different entries and stores things when you input them (in AS3) but I've found that once there are thousands of entries, the program starts lagging and scrolling is slow. If I want scrolling to be animated with acceleration it gets even slower.
How do I move the giant block of objects that are my stored entries up and down?
Do I have to progressively load messages around where the user is looking? How does the scrollbar handle this, then?
you should create a custom container instead TextField, it would be easier to build an accelerated scrolling too,
each log entry would be an extended DisplayObject that holds anything you want just like inflating layouts in android.
the most important part should be reducing Memory usage:
you may only store plain text of log enteries in something like a global array and when scroll position is close enough, generate this layouts, then adding them in container to show, and vice versa for removing far behind chats.
however this proccess stills using much memory during runtime.
so, just according the concept of android's DiskLruCache, it is possible to storing some part of our invisible data which would be too far from our scroll position to disk instead memory, using SharedObject's.
How do I move the giant block of objects that are my stored entries up
and down?
You don't. As you have noticed, when the number Display Objectson the DisplayList greatly increases, the memory overhead increases and the housekeeping details of managing the Display Objectseventually causes performance to suffer. You don't mention any details of how you are implementing what you have so far so my comments will be general.
The way this is handled by various platform list components in Flex, iOS and I assume, Flash, is to only display the minimum number of objects needed, and as the user scrolls, objects are shuffled in and out of the render list. A further optimization is to use a "pool" of "template" objects which are reused so you don't pay a initialization time penalty. There is probably an actual name for this ("...buffering...") technique but I don't know what it is (hopefully some kind person will provide it and a link to a fuller description for how it works).
And as for how it works – you can DIY it, figuring out, as the user scrolls, which objects are moving off-screen and can be recycled, which are going to move on-screen, etc. Of course this all assumes that you have your objects stored in a data structure like and Array, ArrayList or ArrayCollection. As an alternative to coding all this from scratch, you might see if the DataGrid or List components will meet your needs – they manage all of this for you.
Flash Tutorial: The DataGrid Component (youTube video)
Customize the List component
Lots of other examples and resources out there.
(again, I work in Flex where the DataGrid and other list-based components can customized extensively using "skins" and custom item renderers for visual style – not sure if it is the same in Flash)
I can't seem to find a specific solution for my problem so I hope someone here can help me.
I am experimenting with alternativa 3D in Actionscript3 and I managed to upload a textured .3DS model from 3D Max.
The object is a complex spaceship that wasn't intended to be used in a game but I wanted to use it as an example.
The problem is:
Since the imported model is complex it has a lot of overlapping parts. Alternativa z-sorting engine don't react well to this overlapping and the output is jittery texture(i don't know how else to call it) in the overlapping places.
I know next time to model my objects with as less overlapping parts as possible but I am sure this problem will reappear in other forms in the future.
The Alternativa documentation suggests using Decal objects instead of Mash objects but I can't seem to convert imported object Mashs to Decay objects.
Any help will be appreciated.
If you have a model where faces directly intersect one another, then I'd suggest this, not the engine, is the problem.
A well-built 3d model shouldn't have any intersecting faces - you may not notice or think it's a problem in a program like 3dsMAX, you can get away with it more - but it'll certainly show up in a real-time engine.
I just recently switched from doing timeline code to documentclass and I am having some trouble figuring this out...
I am making a choice based game so I have a lot of choices that needs to take place...
in the time line what I did was had each frame with choice. if the user picked a choice it would assign that choice a variable and at the end of the game it would run a switch case to pick out the one with that variable and adds it to the screen...
but as soon as I got to the document class to try to do the same things just using code; I couldn't figure out what to do...
I mean i couldn't operate it the same way, otherwise I would have if loops with in if loops with in if loops and I would have to write down each possibility manually. so I decided to use the bitmap screenshots instead but now I can't figure out...that how do I exactly sequence things inside the document class?...I mean how do I tell it to show me these choice after the previous ones are done? and not have to gointo never ending if loops. with timeline I was able to sequence things using frames but without accessing frames how can I sequence things based on, if a choice is clicked, remove those objects and add new ones but not getting locked within functions of functions? can somebody show me the light by providing a clear example please? I am really new at this and really lost,too...
I am porting as3iso to use with my abstract display list but I fail to see the reason why the author decided to use a secondary display list (the node hierarchy). I cannot think of the necessity of this apart from being able to get the children array of a display object. Is it really that big a performance hit to do for(i in 0...numChildren) getChildAt vs getting the children array? This can also be mitigated by maintaining a children array while overriding.
The only other reason is that some properties of flash.display.DisplayObject are final and wanting to have x and y correlate to isoX/isoY, but worldX/worldY is a reasonable API for this.
I have no problem with the secondary display list but I fail to see the point and am leaning toward having my iso display objects extend from my DisplayObject.
Also, I had presumed that marking objects visible=false that are not on the screen or outside of a scrollRect is not necessary with Flash and in rendering in general as this is/should be handled at the renderer level? Is this the case with the flash software renderer?
For the last question, it's useful to set visible=false because that way the renderer can quickly skip this object without having to calculate whether it is within the screen rectangle or not.
This way the library doesn't rely on the rendering system. You can use the traditional flash display list, Stage3D or a custom solution.
I've been working with several different programming languages recently, and I've come to the conclusion that I don't really like the display list in Actionscript. I would much rather have an update/draw loop and draw and manage everything manually like in XNA (C#).
What I do like in actionscript is the ease of use of events, movieclips animations and vector graphics.
What are the possibillites for this?
I would really like to be able to use animated movieclips, but I think that would be impossible without the display list, so I could settle with writing my own animation system with spritesheets.
Rewriting the entire event system isn't something I look forward to though.
Are there any (molehill) frameworks that work without the display list?
You can do something similar by creating a Bitmap with the same size as the stage, attaching it to the stage as a child and using it like a "screen", by blitting your graphics on it every frame (on ENTER_FRAME event). I think it's even mentioned somewhere in the official Adobe documentation, as a method of efficiently animating a large number of objects.
I would advise you to muster up the courage and let go of C# when programming in ActionScript. As Bjarne Stroustrup wisely said in his book The C++ Programming Language:
...applying techniques effective in one language to another typically
leads to awkward, poorly performing, and hard-to-maintain code. Such
code is also most frustrating to write because every line of code and
every compiler error message reminds the programmer that the language
used differs from 'the old language.' You can write in the style of
[another language], but doing so is neither pleasant nor economical in a language
with a different philosophy.
I think that applies very well to the question you're asking here.