adding a new class using a for loop to determine which class specifically to add - actionscript-3

I made this account to ask this question because researching strings and testing a whole ton of different things ended up with nothing working. You should be able to see what I am trying to do with this code piece here that is not working for me. If I hard type out "Level1" instead of "Level[i]" everything works fine.
for (var i = 0; i<=100; i++)
{
if (levelOn == i)
{
var Lv:Level[i] = new Level[i];
addChild(Lv)
}
}
I have 100 level files labeled "level1", "level2", etc in the project folder. I am trying to access a certain level via using a forloop to add a certain level to the screen (levelOn = 56 means the compiler would add the class "Level56" to the screen.)
I think I have the right idea but I cannot get it to work, all I get is this error
Line 24 1086: Syntax error: expecting semicolon before leftbracket.
If someone has a more efficient way of accessing a "level" in a application (where it has the same base class but minor differences) please send me in the right direction.
Thanks!!!!!

Try this:
var i:int;
var Lv:Level[i] = new Level[i];
addChild(Lv)
for (i=0; i<100; i++){
if(LevelOn=i)
}

Related

Cannot read properties of undefined (reading 'trim')

I have this section of code:
for (let i = 0; i < items.length; i++) {
//trim address to make sure there are no trailing whitespaces
const address = items[i].address.trim();
const token_uri = `${TOKEN_BASE_URI}/${tokenId}.json`;
Every time I run it I get the error:
TypeError: Cannot read properties of undefined (reading 'trim')
Could someone please tell me how to fix this, tia.
I tried adding various code snippets, defining the relevant const as a string, or as an empty string but nothing works. I don't know if I'm doing all the wrong things or I've done the right thing but the wrong way, but nothing has worked.

i am not able to iterate a json document in angular2

i have just started angular2, and got a problem. I am not able to iterate a json document in angular2.data is coming from backend i tried many ways, also used elipses (?) operator but not working for me. Please help
i want to print name under area array
in your .ts code, try the following:
ngOnInit() {
for(let i = 0; i < this.country.length; i++) {
for(let n = 0; n < this.country[i].area.length; n++) {
console.log(this.country[i].area[n].name);
}
}
}
You should get a list of all the names in the console
First get the json as a string; then simply call JSON.parse(myJsonString) and you have your json-object
If you meant anything else please clarify, as I (and obviously others too) don't find your question formualted 100% clearly (for example, add some code or what you have tried before)

p:lineChart - continuous line, without dots

how to remove the dots from p:lineChart and draw the chart as just the continuous line?
Thanks
For others with similar problem, I did:
<p:chart type="line" model="#{myController.model}"/>
and:
LineChartSeries serie = new LineChartSeries();
serie.setShowMarker(false);
and worked fine. I'm using PrimeFaces 5.1.
There is a showMarkers attribute that isn't working for me (I'm using PrimeFaces 3.4.2) but I found a way to hide them.
It's a bit hacky, I made it working on the showcase, you just need to replace widget_category by the widget of your chart. You can even test it online from the showcase using a javascript console if your web browser allows it (tested under chromium) :
// loop through the series
for (var i = 0; i < widget_category.cfg.series.length; ++i) {
// Hide markers
widget_category.cfg.series[i].showMarker = false;
// I'm not sure you want this when talking about 'continuous line'
// but you can make your chart smooth this way :
widget_category.cfg.series[i].rendererOptions = { smooth: true };
}
// Ask a refresh using the modified configuration object
widget_category.refresh(widget_category.cfg);

How do I get the twitter api trends json data into flash as3?

So I know how to get json data into flash with twitter's search api because the array names normally aren't weird, but I'm not really too experienced with json. For the trends api data, I'm not sure how to access it because the array name is the date and theres spaces and colons in it, and I'm not really sure what to do. Normally in flash to get the json data I'd do something like
json.trends[0].2012-01-21 01:20.name
but that doesn't work. Can someone tell me how to pull out the name data when the array name is the date. I apologize if I'm calling these things the wrong name, I'm not too sure on what their proper names are.
To get a better understanding of what I'm talking about copy this link https://api.twitter.com/1/trends/daily.json into this site http://jsonformatter.curiousconcept.com/ in order to format the JSON.
I hope my question makes sense and thank you very much in advance.
var result:Object = JSON.decode(urlLoader.data);
var trends:Object = result.trends;
// trends in an object here, not array
// loop to find the properties in trends
for(var date:String in trends){
// date is a property of trends
// trends[date] is the value of property date
// trends[date] is an array
var items:Array = trends[date];
//for (var i=0; i<items.length; i++){
// var item:Object = items[i];
// loop in the array to get each item
for each(var item:Object in items){
}
}
Try this json.trends[0]["2012-01-21 01:20"].name
x.y is pretty much just syntactic sugar for x["y"]
Try json.trends["2012-01-21 01:20"][0].name
trends is not an array.
Also, you would have to look out for that the time value (that gives an array) will change over time.
I wonder why twitter has chosen this kind of odd structure, where you would have to somehow look up the date and time used in the data, rather than accessing the array the same way on each call? If someone knows or can guess why, please tell in a comment.
{
"trends":{
"2012-01-21 10:40":[
{
"name":"#IReallyLike",
"query":"#IReallyLike",
"promoted_content":null,
"events":null
},
{
"name":"SOPA Is Dead",
"query":"\"SOPA Is Dead\"" ...

MediaWiki variant tabs

Anyone knows how to get the variant tabs to work as actual tabs and not as a drop down?
This is how sr.wikipedia.org has it:
and this is how I have it on my zablude.com/wiki/ page:
and I've tried everything I found and searched everywhere I could think of but I wasn't able to find a solution... anyone has any ideas how this works?
They hack it in JavaScript — see this piece of code at the bottom of Медијавики:Vector.js:
//to be able to switch the language variant (overrides the default buttons with more visible ones)
function tabWorkaround() {
if(mw.config.get('wgUserVariant') == 'sr') {
var tab_urls = {};
tab_urls[0] = document.getElementById('ca-varlang-0').getElementsByTagName('a')[0].href; //Ћирилица
tab_urls[1] = document.getElementById('ca-varlang-1').getElementsByTagName('a')[0].href; //Latinica
$('#p-variants').remove();
mw.util.addPortletLink('p-namespaces', tab_urls[0], 'Ћирилица');
mw.util.addPortletLink('p-namespaces', tab_urls[1], 'Latinica');
}
}
$(document).ready(tabWorkaround);
It would probably be cleaner to do it with a MediaWiki hook, though. The following code is untested, but should work if I haven't made any silly mistakes:
// show language variants as tabs in Vector skin
function tabWorkaround( &$skintemplate, &$links ) {
$links['namespaces'] += $links['variants'];
$links['variants'] = array();
return true;
}
$wgHooks['SkinTemplateNavigation::Universal'][] = 'tabWorkaround';
(In MW 1.17, this hook is only called from the Vector skin. In MW 1.18, it will affect all skins. If you don't want that, you could test whether $skintemplate->skinname == 'vector'.)
Try $wgVectorFeatures['collapsibletabs']['global'] = false;. That is intended for the dropdown on the other side, but might work for other dropdowns as well.