Howto:Coding a simple Nasal Framework: Difference between revisions

m
Line 83: Line 83:
Once these changes are in place, you can easily initialize your members/fields using a single foreach() loop, i.e. instead of having something like this:
Once these changes are in place, you can easily initialize your members/fields using a single foreach() loop, i.e. instead of having something like this:
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
canvas.parsesvg(pfd, "Aircraft/747-400/Models/Cockpit/Instruments/PFD/PFD.svg", {'font-mapper': font_mapper});
curAlt1 = pfd.getElementById("curAlt1");
curAlt1 = pfd.getElementById("curAlt1");
curAlt2 = pfd.getElementById("curAlt2");
curAlt2 = pfd.getElementById("curAlt2");
Line 98: Line 100:
  new: func() {
  new: func() {
  var m = {parents:[PrimaryFlightDisplay]};
  var m = {parents:[PrimaryFlightDisplay]};
m.pdf = {};
canvas.parsesvg(m.pfd, "Aircraft/747-400/Models/Cockpit/Instruments/PFD/PFD.svg", {'font-mapper': font_mapper});
  m.symbols = {};
  m.symbols = {};
  foreach(var symbol; ['curAlt1','curAlt2','curAlt3','vsPointer','curAltBox','curSpd','curSpdTen','curAlt1','spdTrend',])
  foreach(var symbol; ['curAlt1','curAlt2','curAlt3','vsPointer','curAltBox','curSpd','curSpdTen','curAlt1','spdTrend',])