How to remove MovieClip by selecting a row and pressing a delete button? - actionscript

I have a datagrid, where rows are added. Whenever a row is added, a movie clip is added to the stage. I added a button to remove a row in the datagrid if the row and button are clicked, and all of that works perfectly well.
However, when I try to remove the movie clip relating to that row in the datagrid, it does not work.
My code is:
function removeloaditem(event:MouseEvent) {
datagrid.removeItemAt(datagrid.selectedIndex);
removeChild(MovieClip(datagrid.selectedIndex);
}

removeChild(MovieClip(datagrid.selectedIndex);
You need to understand what this line of code is trying to do.
datagrid.selectedIndex
This variable is just a Number. So, you are trying to cast a Number to a MovieClip.
MovieClip(1)
That does not work. You need a reference to the actual MovieClip object. Wherever you are creating your MovieClip object, you will need to store a reference to that object. You can have a plain Object store all of your references.
var objectList:Object = {};
and then, wherever you are creating the MovieClip, add this line:
objectList["reference_" + datagrid.selectedIndex] = "movieclip variable";
Replace "movieclip variable" with the reference to your movieclip object. After that, replace your current removeChild line with these two lines:
var movieclip = objectList["reference_" + datagrid.selectedIndex]
moveclip.parent.removeChild(movieclip);

Related

Update whole data series for the graph

What I wanna do: I have a basic line chart which is initialy load with an array of data (series: [...]) which creates me lets say x lines. I will also render x checkboxes above the chart. On click on one of the checkboxes the corresponding line should disappear or appear. Therefor I am listening to the click event and then I want to add or remove a line.
The problem: I can not figure out how to replace the whole series with a new one. What I have found is the setData() method, but that only works on an item of the data array. I also found the methods addSeries() which will add an item. And remove() which will remove a specific item. The problem is, I dont know which item is which. What I would like is to hide a line or show them, but have the full x lines in the data series all the time. I think.
I also found the method update() which will let me pass a new configuration object to the chart, but its not working if i pass the option 'series: newData (array)'.
I am either looking for an option to pass the full data array at the beginning and then hide or show a line, or, to overwrite the full series data at any given them with a new array.
Hopefully thats understandable and someone can point out what I am missing! Thanks!
I have found a solution. I would load the whole data array in the beginning and show or hide certain series for the initial display with the option visible:false.
On click of the checkboxes I need to find the right series and then there are the methods show() and hide() to manipulate that visible property on runtime.
chart.series[myIndex].show();
chart.series[myIndex].hide();
You can use setVisible method for series and bind checkboxes with the series:
var checkboxes = document.getElementById('checkboxes').children;
for (var i = 0; i < checkboxes.length; i++) {
(function(i) {
checkboxes[i].addEventListener('change', function() {
chart.series[i].setVisible(this.checked);
});
})(i);
}
Live demo: http://jsfiddle.net/BlackLabel/ur31g4j5/
API Reference: https://api.highcharts.com/class-reference/Highcharts.Series#setVisible

Show newly added record as dirty i.e. red color on top

I am adding new record in grid like below
var newRow = Ext.create(gridModel);
rowEditPlugin.cancelEdit();
gridStore.insert(0, newRow);
reportGrid.getView().refresh();
reportGrid.getView().getSelectionModel().select(0);
//rowEditPlugin.startEdit(0);
rowEditPlugin.startEditByPosition({
row: newRow,
column: 0
});
I want this newly added record to be shown as dirty, user should know that this row is added newly i.e. red marks on top of each column.
You can supply a method to the viewConfig of your grid, called getRowClass. This method will allow you to customise the CSS class for the row.
You can tell if your record is newly inserted or not using the Model#phantom property
And, finally, you can modify the CSS for your application using SASS/Fashion to change the appearance of your newly added rows.

How to call object from a movie clip

How to call an object from a movie clip and display it to the next frame of the scene. With the same value of it like a health bar.
In the previous frame, you create your container (C) and add it to the display list. You also create an instance of your object 'o1', but this one is not yet added to the display list. On the other hand, this object needs to be a class to be called by the code, from the library. An instance of a class can't be called from a movieClip. (select it > Convert to symbol > Export for actionScript > Class:MyObject)
const C:Sprite = new Sprite();
this.addChild(C);
o1:MyObject = new MyObject();
Next frame, you add this object to the display list in it's container:
this.C.addChild(o1);

How to get the index or position of an item in Gtk.ListBox in vala?

I want a behavior like if you click on the first listitem open do a thing, if I click on the second listitem do other thing. Same thing for the third and second.
Similar to switchboard but not in iconview (I have the animason and gtk.stack set up):
https://www.youtube.com/watch?v=Lj2wKNYVFR8
This is the code:
var listbox = new Gtk.ListBox();
listbox.set_activate_on_single_click(true);
var l = new Watcher.List.ListItem("title", "subtitle");
listbox.insert(l, 0);
var l2 = new Watcher.List.ListItem("title2", "subtitle2");
listbox.insert(l2, 1);
"l" and l2 is a Gtk.ListBoxRow object so basically I add 2 listboxrow item into a listbox.
When I click on an Item do stuff:
listbox.row_selected.connect( ()=>{
stack.set_visible_child_name("new");
back.set_child_visible(true);
});
It will always show the stack child named "new" whether I click the first or second item in the list. I can acces the ListBoxRow index but that is just only for a specific Row.
I need to add custom formated items into a list and I was told that ListBox can do it. (Others can't?)
My ListBoxRow is just a grid with two labels in it but I want to add buttons and some more later.
Look at the reference for Listbox.row_selected(): You'll see that it has a ListBoxRow argument. You should update your row_selected closure to have that argument as well -- then you can use the row inside the closure to figure out which child you want to set visible.
If you really need to know the index of the row inside the listbox, you call row.get_index().

On buttonClick refresh the table with the new rows added

I have created a table and a button. On click of that button i need to add the row.
For that i have used buttonClick method in which i am adding a row in the Table.
The problem is that the row in added to the table (I can see in the logs),
but the screen becomes blank with just the button displayed.
If I exit and navigate again to the screen, then i can see the new row added.
How can i see the new row added immeditalety once added.
Some code would probably help to further see what might be wrong, but I would also recommend you to call the following code line directly after you have added a table row.
yourTable.setContainerDataSource(yourTable.getContainerDataSource());
This will update the datasource for your table and force a repaint. If you provide some code maybe more help can be provided
Using IndexedContainer to add new row in table during button click..
Example
Create IndexedContainer
-----------------------
private IndexedContainer getTblTerminals(IndexedContainer container)
{
container.removeAllItems();
container.addContainerProperty("Terminal_Id", String.class, defaultValue);
g_TermialPojo=ws.readAll();
for(Terminal pojo:g_TermialPojo)
{
Object itemId=container.addItem();
strTid=String.valueOf(pojo.getTid());
container.getContainerProperty(itemId,"Terminal_Id").setValue(strTid.toString());
}
return container;
}
//To add indexedcontainer in your table
-------------------------------------------
Example
table.setContainerDataSource(getTblTerminals((IndexedContainer)table.getContainerDataSource()));
table.setImmediate(true);

Resources