what happens when i say arrayCollection.addItemAt(object,0); - actionscript-3

Lets say i have an Array collection, filled with some elements. If i say
myArrayCollection.addItemAt(object,0);
What exactly happens here? Does all the elements gets shifted rigthwards? or element at 0th position gets replaced with new one?

To summarize, the reason there are two different methods, addItemAt() and setItemAt(), is because one of them adds a new item (not replacing any of the existing ones), and the other sets/overwrites the existing index.
For more info, check out the ArrayCollection documentation.

Related

GTK+ Overlay not display childs in correct order

https://github.com/nintyfan/V2BlankBrowser
In file main. See at v1UI_integration branch and init_v1_ui and real_new_tab code. I known, there is big amount of code, so I do not paste it here.
Problem is, when trying to add more than two children to GtkOverlay, one of it always get at index 0 and I cannot reorder it with gtk_overlay_reorder_overlay. I try with different approach by use three overlays (one root and two children) and it worked, but problem was I cannot interact with items, even when setting gtk_overlay_set_overlay_pass_through to children. What i do wrong?

how to make a form designer

The Problem in Hand:
I want to make a form designer where user can drag and drop fields of different type and design the layout too, some what similar to wufoo form builder but here the layout is limited to single column whereas I want to make something where user can make the layout as they want.
I understand how to do in single column view, but could not understand how to achieve multiple column layout eg: row 1 there could be 3 elements, row 2 one element stretched to full length, row 3 there could be just 2 elements etc.
What I tried:
I have tried with jquery UI sortable to make a single column layout with using div where new elements can be dragged and repositioned.
Any suggestion on how to proceed further will be helpful
I have tried searching StackOverFlow and google but could not find any link on a similar topic. If anyone could point me to the same, it will be also helpful.
When you reorder elements on wufoo form builder, you can only drag'n'drop up or down. Remove that restriction and as soon as one element is dragged across a certain threshold, it "belongs" to the next column. If the "old" column was the first or last one and the line that the element was moved over was to the "outside" of the form, add a new column there, until the maximal number of columns is reached.
If the used drags the last element of a column into another column, remove the now empty column on element-drop.
You could also remove the dynamic adding/removing of columns and juist have a button ("remove column" & "add column") to do it by code.
An example for the dropping in another column can be found here: http://jqueryui.com/sortable/#connect-lists
Hope this helped!
Edit:
http://jqueryui.com/sortable/#portlets and http://jqueryui.com/sortable/#empty-lists also have elements that you could look into. Good luck! Sounds like a nice project. Can we see any progress or beta?

AS3 Removing an object from an array?

I used this line of code to remove an element:
tiles.splice(tiles.indexOf(tiles[i]), 1);
Yet afterwards when I'm checking the value, it's still not null, in fact, it still contains the movieclip it had inside of it.
This worked though:
tiles[tr] = null;
The question is, is it still okay to do it like that?
I have movieclips added and removed to this array and I type removeChild(tiles[tr); before removing it from the array.
I just don't want to encounter some terrible performance in the future,
Thanks.
splice cuts out the element from the Array, and all the above elements move one stept down. Which also reflects in the Array's length.
So the element you are finding is the next element.
Just nulling it will do just that. Leave the rest of the Array as is with an empty position.
Also you dont need to call indexOf if i is already the position you need.
tiles.splice(i, 1)
will do.

How can I access an element by using its DOM hierarchy(parent element)?

I want to access an element using a DOM hierarchy Node structure, through its parent nodes.I am trying to find the DOM hierarchy through firebug; want something like, <parent_node1>.<child_node1>.<child_node2> (not by document.getElementByID, getElementbyname) to access an element.
I want to automate a scenario like, I have column headers and corresponding values. Want to test, whether the values present under each column header, is correct...
I am thinking of using DOM as a method of automating this case...But, how can I find the DOM hierarchy...?
What I see through Inspect Element in Firebug is something like, list of events, elements and is not looking like a hierarchy node structure...Can somebody help in this regard please?
As discussed, you probably mean the DOM Element properties like element.childNodes, element.firstChild or similar.
Have a look at the DOM Element property reference over at JavaScriptKit, you'll get a good overview there how to access the hierarchy.
var currentTD = document.getElementsByTagName("td")[0];
var currentTable = document.getElementsByTagName("table")[0];
currentTD.parentNode // contains the TR element the TD resides in.
currentTable.childNodes // contains THEAD TBODY and TFOOT if present.
DOM Tables even have more properties like a rows collection and a cells collection.
A reminder of caution: Beware that these collections are live collections, so iterating over them and accessing collection.length in each iteration can be really slow because to get the length, the DOM has to be queried each time.
document.getElementById and document.getElementByTagname are using the DOM. They take an object within the DOM (specifically the document object, though you can also call both of those on elements) and return an object which is a single element or a collection of zero or more elements, respectively. That's a DOM operation. From there you can do other DOM operations on the results like getting children, parents or siblings, changing values etc.
All DOM operations come down to:
Take a starting point. This is often document though it's so often that the first thing we do is call document.getElementById or document.getElementByTagname and then work from the result that we could really consider that the starting point.
Find the element or elements we are interested in, relative to the starting point whether through startingPoint.getElementById* or startingPoing.getElementByTagname perhaps combined with some test (e.g. only working on those with a particular classname, if they have children of particular types, etc.
Read and/or change certain values, add new child nodes and/or delete nodes.
In a case like yours the starting point will be one or more tables found by document.getElementById(someID), document.getElementById(someID).getElementsByTagname('table')[0], or similar. From that table, myTable.getElementsByTagname('th') will get you the column headings. Depending on the structure, and what you are doing with it, you could just select corresponding elements from myTable.getElementsByTagname('td') or go through each row and then work on curRow.getElementsByTagname('td').
You could also just use firstChild, childNodes etc. though it's normally more convenient to have elements you don't care about filtered out by tagname.
*Since there can only be one element with a given id in a document, this will return the same if called on any element higher in the document hierarchy, so we normally just call this on document. It can be useful to call it on an element if we want to do something if the element is a descendant of our current element, and not otherwise.

AdvancedDataGrid : Conditionally change the icon of the leaf node

Introduction: I have a flat ArrayCollection of object's, which i group to create the dataProvider for an AdvancedDataGrid. In this AdvancedDataGrid i have different branches representing different type of tasks. I want to conditionally change the icon for the leaf nodes in the AdvancedDataGrid based on a date field stored in each object.
For this purpose lets say each Task object contains an id and an updatedDate (Representing when the task was last updated). If the task has not been updated in the last five days (updatedDate+5 < today) the icon of that leaf node(Task) should be red, in constrast to the opposite the leaf icon in the AdvancedDatagrid should be green, e.g. like the image below. In this case task 35 has not been updated in the last 5 days, while 13 and 39 have.
Question: How do i change the leaf icons in the ADG based on the updatedDate of the underlying object? I would think that i have to extend AdvancedDataGrid and override some method, but which and how? Any type of guidance for achieving this particular task is much appriciated!
I have seen easy ways of changing the open and closed icons on the web, but no way of conditionally changing an open node's icon :)
Update: After applying #takteek groupIconFunction solution which always returned the same icon:
The problem is that I need the leaf node's icons changed, and not the branches.
SOLVED: Used #takteek's answer, with the exception of using iconFunction instead of groupIconFunction, because i wanted to change the leaf node's icons, and not the groupIcons :)
Your two options are:
Specify agroupIconFunction for the data grid. This gets passed the current item and you return which icon to use, or null to use the default.
Create a subclass of AdvancedDataGrid and override makeListData. This function is responsible for creating the AdvancedDataGridListData object that gets passed to the renderers. You can change the icon and disclosureIcon properties on the list data to what you want. This is probably unnecessary unless you need more control.
Create your own item renderer based on AdvancedDataGridGroupItemRenderer.