How to change z-index of the FlxSprite in FlxGroup? - sprite

I have a heterogeneous FlxGroup contains: 10 FlxSprite and 4 FlxText. I add all objects with add(obj) function and their z-indexes determined by add function.
I want to change z-index values of objects in my FlxGroup dynamically while program is running (ex: With mouse click).
I tried things like:
this.setChildIndex(object, i) but there is no function like this
this.add(object) tried to add object which is already added

With FlxGroups, the "z-index" is nothing but the array position of the object within the FlxGroup's "members" array. So if you have some FlxGroup "mygroup" it would be simply a matter of changing where your object is in the array "mygroup.members".
EDIT: And to be perfectly clear, it draws in order from the first element to the last, so array position 0 is the "bottom" of the stack.
EDIT 2: Also, just an FYI: FlxState's use the exact same method with their "members" array / add()/remove() logic as well. They're basically glorified FlxGroups themselves.

Related

get the outer element (LIST) to render anything other than a div

Is it possible to get List (or any other component from RV) to render itself like an UL>LI list or specifically like React Bootstraps ListGroup.
Currently I can not see an option to get the outer element (LIST) to render anything other than a DIV.
So my use case is really that each row should be a ListGroupItem (e.g. li with BS classes applied) and the container should be a ListGroup component.
Short answer: No. This is not supported.
Longer answer: List (like Table) uses a Grid internally. In order for windowing to work, Grid needs 2 wrapper elements around its cells. (Check out the source here. I also made a presentation slide about how it works, if you're interested, here.) Lists (ol, ul) only have 1 wrapper element.

Capybara Scope within element to create array of href

I'm writing tests that will look within an element which contains 4 href, and create an array of each href within it then click on each one in turn and expect a result.
Looking at the Capybara DSL docs, I can't see a way of scoping within, then calling all, kind of like this:
links = all(:href).within('id-of-element')
I would just leave it as just all(:href) but there are 3 elements containing 4 href, I need to be specific of the element I'm interacting with.
Is there a way to do this?
Capybaras within takes a block and is called on the session, it's not a method you can call on nodes or "array"s of nodes
within("#id") do
find(...) # result scoped to inside element with id
end
Your other option would be to just call find/first/all on a node which scopes it to that node
find("#id").all(...). # results of all are scoped to element with id

How do I access a repeat control from the outside e.g. via CSJS

How can/should I access a repeat control from outside? In my case I want to calculate some additional value(s) for the items in the repeat control and update each item with jquery.
In SSJS you always access a component with getComponent("id"). If your contents of the repeat are just a view than define the view data source at the XPage level, not the repeat and you can use the id of the datasource to get the view object, ie, view1.
From SSJS you can access the repeat control itself via getComponent(). However, if you want to access components within the repeat, it gets more challenging.
The default behaviour is to create a single "row" of components for the repeat and then, in the Render Response phase, iterate over them to generate the relevant HTML for the appropriate number of rows (rows property of the repeat control) from the relevant start point (first property of the repeat control, which may have been incremented by a pager), picking the data from the relevant data (value property of the repeat).
If the repeat has repeatControls="true" set, at page load the runtime creates a set of controls for the appropriate number of rows (rows property of the repeat control). However, accessing them may still be a challenge. This will also remove the ability to use a pager.
If you want to manipulate e.g. the appropriate view entries within the repeat, one option might be to load into viewScope the UNID / Note ID via a computed property within each row. E.g.
rendered="#{javascript:if (view.isRenderingPhase()) {
if (idex == 1) viewScope.put("myVar", new java.util.ArrayList());
viewScope.get("myVar").add(entry.getNoteID());
return true;
} else {
return true;
}"
This initialises (or re-initialises) the viewScope variable if it's the first row (please double-check first row has idex as 1, idex being the variable name you define for the indexVar property of the repeat control), and adds the NoteID to the list. So element 0 is the NoteID of the first row, element 1 the Note ID of the second row etc.
If you wish to manipulate values, you may be able to take a similar approach by using dynamic binding. There are various questions on StackOverflow about dynamic binding for repeat controls as well as blog posts, probably by either Tim Tripcony or Jesse Gallagher.
Beyond this, CSJS may be the easiest way to manipulate the contents of the repeat. Just be aware that if you do a partial refresh whose refreshId is the repeat, it may replace whatever you've done client-side.

Set z-index of shapes in a Kinetic.Group

How do I set z-index on the shapes that I'm adding to Kinetic.Group? My group contains rectangles and images. I want to do this:
rectangle.setZIndex(1);
image.setZIndex(2);
This gives me the following error: Uncaught TypeError: Cannot read property 'children' of undefined.
I'm using drag and drop and then grouping the objects together. I want the images to be on top of the rectangle. the moveToTop() method gives errors when I call it inside my code.
EDIT :
http://jsfiddle.net/Dcevd/ . Try this use case: drag&drop two rects, then drag the image and drop it on the first rect, then move it to the second one (when you do it inversely it works). it moves to top only on dragend.
Answer to your edit
You are calling moveToTop() on a child of the group, so it will only put the image on the op of that specific group. Once you place the second rectangle on the right stage, it gets a higher z-index then the first one your placed and will therefor be 'on top of' the first rectangle (including it's images). To solve this I've set the parent of the image (the group) to move to top on the dragstart, this fixes it for me:
cloneImg.on('dragstart', function(){
this.startX=this.x();
this.startY=this.y();
this.getParent().moveToTop();
});
See also the fiddle: http://jsfiddle.net/Dcevd/3/
PS. If you look in the KineticJS docs, you see that setZIndex is available on Kinetic images (as with all other Shapes). http://kineticjs.com/docs/Kinetic.Image.html

IHTMLSelectElement : not returning dynamically added items

I have added a ComboBox to my CHTMLEditCtrl by passing it in a HTML string.
Then dynamically I add the members(items) to it using IHTMLSelectElement.
Now I want to change the font of one of the items that I have just added.
But when I use item() method on this object, it returns a null. Also when I use get_size on the Object, it returns 0, even though all the items I added in the combobox are visible(and hence I infer all the items are added).
I am not able either to retrieve it using COM methods. Any idea?
Usually the DOM elements are available once the page render is complete.

Resources