How to call object from a movie clip - actionscript

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);

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

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

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);

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().

accessing an object from a pop up window in parent window

i have a pop up window in which there is a grid on rowselecting i have an object that is created that contains all the row elements. I want to assign these values to text boxes in the parent window can anybody please help me with this.
Regards
-Vishu
I don't understand exactly your question. because I don't know what language you are using. But, if you want using an object on popup window in parent window, you can set modifier of object in popup window is "public" and that object must be global variable. and you can use that object in parent window
example:
popupWindow{
public object A;
}
parentWindow{
popupWindow pWin = new popupWindow();
// here, you can use object A in parent window
pWin.A = ....
}
I hope it will help you.

Add simple table with text to screen

How do I add a simple plain table with data to existing screen?
The data is already parsed text from DOM. Can I do it with TableModel? Here's what I have now:
TableModel tm = new TableModel();
tm.addRow(doc.getElementsByTagName("id").item(0).getChildNodes().item(0).getNodeValue());
tm.addRow(doc.getElementsByTagName("id").item(1).getChildNodes().item(0).getNodeValue());
final MyScreen screen = new MyScreen();
Can I use something like:
screen.add(...)
Or it should I use something other than the TableModel container?
TableModel is merely a data model. To display the data, you'll need to use a Field that uses the data contained in the TableModel. I'd suggest making a custom field that accepts this TableModel object. You could also use a GridFieldManager and add LabelFields to it for each cell of the TableModel object.

Resources