navigator.as2 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. var TEST_MODE = 0;
  2. if (TEST_MODE == 1)
  3. {
  4. var root_object_id = 11;
  5. var root_object_class = "bizPC";
  6. var root_relation = "neighboors";
  7. var xml_document_url = "http://localhost:81/pages/xml.navigator.php";
  8. var details_url = "http://localhost:81/pages/UI.php?operation=details";
  9. }
  10. else
  11. {
  12. var root_object_id = obj_id; // 11;
  13. var root_object_class = obj_class; // "bizPC";
  14. var root_relation = relation; // "neighboors";
  15. var xml_document_url = unescape(xmlUrl); // "http://localhost:81/pages/xml.navigator.php";
  16. var details_url = unescape(drillUrl); // "http://localhost:81/pages/UI.php?operation=details";
  17. }
  18. if (pWidth == undefined)
  19. {
  20. pWidth = 800;
  21. }
  22. if (pHeight == undefined)
  23. {
  24. pHeight = 800;
  25. }
  26. var K = 0; //0.02; // elasticity coeff
  27. var Q = 0; // Normally each element may have a specific "charge"
  28. var deltaT = 1; // delta time
  29. var solidFriction = 10;
  30. var radius = 25;
  31. if (customRadius != undefined)
  32. {
  33. radius = customRadius;
  34. }
  35. if (displayController != 'true')
  36. {
  37. _level0.Controller._x = -1000; // Make it invisible
  38. }
  39. var M = 1; // Mass of the object
  40. var frictionCoeff = 0.9; // Friction coefficient
  41. var bDrawForces = false;
  42. var aXPos = new Array;
  43. var aYPos = new Array;
  44. var aClips = new Array;
  45. var aLinks = new Array;
  46. var aWeights = new Array;
  47. var oItemsContextMenu = new ContextMenu();
  48. oItemsContextMenu.hideBuiltInItems();
  49. var menuItem = new ContextMenuItem ("Details...", DisplayObjectDetails);
  50. var menuItem2 = new ContextMenuItem ("Expand", Expand);
  51. var menuItem3 = new ContextMenuItem ("Drill down", DrillDown);
  52. function DisplayObjectDetails(oSelectedObject)
  53. {
  54. // Called by the context menu
  55. var fullUrl:String = details_url;
  56. if (fullUrl.indexOf("?",0) > 0)
  57. {
  58. fullUrl = fullUrl+"&class="+oSelectedObject.obj_class+"&id="+oSelectedObject.id;
  59. }
  60. else
  61. {
  62. fullUrl = fullUrl+"?class="+oSelectedObject.obj_class+"&id="+oSelectedObject.id;
  63. }
  64. getURL(fullUrl, "_top");
  65. }
  66. function DrillDown(oSelectedObject)
  67. {
  68. DoReload(oSelectedObject.id, oSelectedObject.obj_class, root_relation);
  69. }
  70. function Expand(oSelectedObject)
  71. {
  72. DoLoad(oSelectedObject.id, oSelectedObject.obj_class, root_relation);
  73. }
  74. oItemsContextMenu.customItems.push(menuItem, menuItem2, menuItem3);
  75. function DrawLinks()
  76. {
  77. oLinksMovie = _root.links;
  78. oLinksMovie.clear();
  79. oLinksMovie.lineStyle (5, 0xcccccc, 100);
  80. for(i=0; i<aLinks.length; i++)
  81. {
  82. x1 = aClips[aLinks[i].start]._x;
  83. y1 = aClips[aLinks[i].start]._y;
  84. x2 = aClips[aLinks[i].end]._x;
  85. y2 = aClips[aLinks[i].end]._y;
  86. dx = x2 -x1;
  87. dy = y2 - y1;
  88. l = Math.sqrt( dx*dx + dy*dy);
  89. //trace("Linking item "+aLinks[i].start+" to item "+aLinks[i].end+"; Line from: ("+x1+", "+y1+") to ("+x2+", "+y2+")");
  90. oLinksMovie.moveTo(x1, y1);
  91. oLinksMovie.lineTo(x2, y2);
  92. if (aLinks[i].bArrow)
  93. {
  94. dx = x2 -x1;
  95. dy = y2 - y1;
  96. l = Math.sqrt( dx*dx + dy*dy);
  97. x_mid = (x1+x2) / 2;
  98. y_mid = (y1+y2) / 2;
  99. oLinksMovie.lineStyle (3, 0x999999, 100);
  100. oLinksMovie.moveTo(x_mid, y_mid);
  101. oLinksMovie.lineTo(x_mid + 5*(dy-dx)/l, y_mid-5*(dx+dy)/l);
  102. oLinksMovie.moveTo(x_mid, y_mid);
  103. oLinksMovie.lineTo(x_mid - 5*(dx+dy)/l, y_mid-5*(dy-dx)/l);
  104. }
  105. }
  106. }
  107. function ComputeElasticForces()
  108. {
  109. var aForces = new Array;
  110. for(var i=0; i<aClips.length; i++)
  111. {
  112. aForces[i] = new Object;
  113. aForces[i].FxTotal = 0;
  114. aForces[i].FyTotal = 0;
  115. }
  116. // Elastic forces: each link applies a force proportional to its length (F = - K * x)
  117. for(var l=0; l<aLinks.length; l++)
  118. {
  119. dx = aClips[aLinks[l].start]._x - aClips[aLinks[l].end]._x;
  120. dy = aClips[aLinks[l].start]._y - aClips[aLinks[l].end]._y;
  121. //d = Math.sqrt(dx*dx + dy*dy);
  122. //Fx = -K * d * dx / d;
  123. //Fy = -K * d * dy / d;
  124. // Links with more weight attached are more rigid !
  125. weightCoeff = (aWeights[aLinks[l].start] + aWeights[aLinks[l].end])/2;
  126. Fx = -K * weightCoeff * dx;
  127. Fy = -K * weightCoeff * dy;
  128. aForces[aLinks[l].start].FxTotal += Fx;
  129. aForces[aLinks[l].start].FyTotal += Fy;
  130. aForces[aLinks[l].end].FxTotal -= Fx;
  131. aForces[aLinks[l].end].FyTotal -= Fy;
  132. }
  133. return aForces;
  134. }
  135. function ComputeElectrostaticForces()
  136. {
  137. aForces = new Array;
  138. for(var i=0; i<aClips.length; i++)
  139. {
  140. aForces[i] = new Object;
  141. aForces[i].FxTotal = 0;
  142. aForces[i].FyTotal = 0;
  143. }
  144. // Each items applies a force to all the others, in proportion to the inverse of the square
  145. // of their distance: (F = Q / x2)
  146. for (var i=0; i<aClips.length; i++)
  147. {
  148. for(var j=0; j<aClips.length; j++)
  149. {
  150. if (i != j) // no force on itself !!
  151. {
  152. dx = aClips[i]._x - aClips[j]._x;
  153. dy = aClips[i]._y - aClips[j]._y;
  154. d2 = (dx*dx + dy*dy) / (radius * radius);
  155. d = Math.sqrt(d2);
  156. if (d2 < 0.05)
  157. {
  158. d2 = 0.05;
  159. }
  160. Fx = Q * dx / d2;
  161. Fy = Q * dy / d2;
  162. aForces[i].FxTotal += Fx;
  163. aForces[i].FyTotal += Fy;
  164. }
  165. }
  166. }
  167. return aForces;
  168. }
  169. function DrawForces()
  170. {
  171. oForcesMovie.clear();
  172. oForcesMovie = _root.forces;
  173. // Draw elastic forces in red
  174. oForcesMovie.lineStyle (1, 0xff0000, 100);
  175. aElasticForces = ComputeElasticForces();
  176. DrawForcesVectors(aElasticForces);
  177. // Draw electrostatic forces in blue
  178. oForcesMovie.lineStyle (1, 0x0000ff, 100);
  179. aElectrostaticForces = ComputeElectrostaticForces();
  180. DrawForcesVectors(aElectrostaticForces);
  181. // Compute resulting forces and draw them (in green)
  182. aForces = new Array;
  183. for(var i=0; i<aClips.length; i++)
  184. {
  185. aForces[i] = new Object;
  186. aForces[i].FxTotal = aElasticForces[i].FxTotal + aElectrostaticForces[i].FxTotal;
  187. aForces[i].FyTotal = aElasticForces[i].FyTotal + aElectrostaticForces[i].FyTotal;
  188. Vx = frictionCoeff*(aClips[i].Vx + aForces[i].FxTotal / M * deltaT);
  189. Vy = frictionCoeff*(aClips[i].Vy + aForces[i].FyTotal / M * deltaT);
  190. V = Math.sqrt(Vx*Vx + Vy*Vy);
  191. if (V < solidFriction)
  192. {
  193. c = 0;
  194. }
  195. else
  196. {
  197. c = (V - solidFriction) / V;
  198. }
  199. aClips[i].Vx = c * Vx;
  200. aClips[i].Vy = c * Vy;
  201. }
  202. oForcesMovie.lineStyle (2, 0x00ff00, 100);
  203. DrawForcesVectors(aForces);
  204. UpdatePositions();
  205. }
  206. function DrawForcesVectors(aForces)
  207. {
  208. if (bDrawForces)
  209. {
  210. for(var i=0; i<aClips.length; i++)
  211. {
  212. oForcesMovie.moveTo(aClips[i]._x, aClips[i]._y);
  213. //trace("Resulting force on item"+i+": ("+aForces[i].FxTotal+", "+aForces[i].FyTotal+").");
  214. Fx = aForces[i].FxTotal;
  215. Fy = aForces[i].FyTotal;
  216. strengh = Math.sqrt(Fx*Fx + Fy*Fy);
  217. if (strengh > 1) // if less than 1 pixel, don't draw it
  218. {
  219. // Draw the arrow: main line
  220. oForcesMovie.lineTo(aClips[i]._x + Fx, aClips[i]._y + Fy);
  221. // Head of the arrow
  222. oForcesMovie.lineTo(aClips[i]._x + Fx + 5*(Fy-Fx)/strengh, aClips[i]._y + Fy - 5*(Fx+Fy)/strengh);
  223. oForcesMovie.moveTo(aClips[i]._x + Fx, aClips[i]._y + Fy);
  224. // Head of the arrow
  225. oForcesMovie.lineTo(aClips[i]._x + Fx - 5*(Fx+Fy)/strengh, aClips[i]._y + Fy - 5*(Fy-Fx)/strengh);
  226. }
  227. }
  228. }
  229. }
  230. function DrawItems()
  231. {
  232. aForces = ComputeForces();
  233. DrawLinks(true);
  234. DrawForces(aForces);
  235. }
  236. function DoStartDrag()
  237. {
  238. this.bInDrag = true;
  239. if (this.iTimeout != 0)
  240. {
  241. clearTimeout(this.iTimeout);
  242. this.iTimeout = 0;
  243. }
  244. this.startDrag()
  245. }
  246. function DoReleaseDrag()
  247. {
  248. this.stopDrag();
  249. this.bInDrag = false;
  250. if (this.lastclick - (this.lastclick=getTimer()) + 250 > 0)
  251. {
  252. //do doubleclick action
  253. trace("double");
  254. DoReload(this.id, this.obj_class);
  255. }
  256. else
  257. {
  258. //do singleclick action
  259. trace("single");
  260. }
  261. }
  262. function DoRollOver()
  263. {
  264. trace("Roll Over: "+this.name);
  265. var iTimeOut:Number;
  266. iTimeout = setTimeout(ShowTooltip, 500, this);
  267. this.iTimeout = iTimeout;
  268. }
  269. function DoRollOut()
  270. {
  271. trace("Roll Out");
  272. if (this.iTimeout != 0)
  273. {
  274. clearTimeout(this.iTimeout);
  275. this.iTimeout = 0;
  276. }
  277. HideTooltip();
  278. }
  279. function UpdatePositions()
  280. {
  281. var MIN_MOVE_LIMIT = 0.3; // Whatever moves of less than 0.3 px per cycle, remains frozen to spare some CPU
  282. for(var i=0; i<aClips.length; i++)
  283. {
  284. if (!aClips[i].bInDrag)
  285. {
  286. //trace("Speed: ("+aClips[i].Vx+", "+aClips[i].Vy+")");
  287. if ( (Math.abs(aClips[i].Vx * deltaT) > MIN_MOVE_LIMIT) || (Math.abs(aClips[i].Vy * deltaT) > MIN_MOVE_LIMIT) )
  288. {
  289. aClips[i]._x += aClips[i].Vx * deltaT;
  290. aClips[i]._y += aClips[i].Vy * deltaT;
  291. }
  292. }
  293. }
  294. }
  295. function CreateItem(id, obj_class, icon, name, x, y, parentId, oNodeDetails)
  296. {
  297. trace("CreateItem(id:"+id+" , parentId:"+parentId+")");
  298. var i = aClips.length; // Add new elements at the end of the array
  299. var sMovieName;
  300. switch (icon)
  301. {
  302. case "application":
  303. sMovieName = "Item_application";
  304. break;
  305. case "business_process":
  306. sMovieName = "Item_business_process";
  307. break;
  308. case "chemicals":
  309. sMovieName = "Item_chemicals";
  310. break;
  311. case "contact":
  312. sMovieName = "Item_contact";
  313. break;
  314. case "contract":
  315. sMovieName = "Item_contract";
  316. break;
  317. case "change":
  318. sMovieName = "Item_change";
  319. break;
  320. case "database":
  321. sMovieName = "Item_database";
  322. break;
  323. case "db_instance":
  324. sMovieName = "Item_db_instance";
  325. break;
  326. case "desktop":
  327. sMovieName = "Item_dekstop";
  328. break;
  329. case "incident":
  330. sMovieName = "Item_incident";
  331. break;
  332. case "interface":
  333. sMovieName = "Item_interface";
  334. break;
  335. case "laptop":
  336. sMovieName = "Item_laptop";
  337. break;
  338. case "network_device":
  339. sMovieName = "Item_nw_device";
  340. break;
  341. case "printer":
  342. sMovieName = "Item_printer";
  343. break;
  344. case "server":
  345. sMovieName = "Item_server";
  346. break;
  347. case "wireless_device":
  348. sMovieName = "Item_wireless_device";
  349. break;
  350. default:
  351. sMovieName = "Item";
  352. }
  353. aClips[i]= _root.links.attachMovie(sMovieName, "r"+i, i+10);
  354. aClips[i]._x= x;
  355. aClips[i]._y= y;
  356. aClips[i].parentId = parentId;
  357. aClips[i].details = oNodeDetails;
  358. aClips[i]._xscale = radius;
  359. aClips[i]._yscale = radius;
  360. aClips[i].onPress = DoStartDrag;
  361. aClips[i].onRelease = DoReleaseDrag;
  362. aClips[i].onRollOver = DoRollOver;
  363. aClips[i].onRollOut = DoRollOut;
  364. aClips[i].Vx = 0; // No inital speed
  365. aClips[i].Vy = 0; // No inital speed
  366. aClips[i].bInDrag = false;
  367. aClips[i].id = id;
  368. aClips[i].icon = icon;
  369. aClips[i].name = name;
  370. aClips[i].obj_class = obj_class;
  371. aClips[i].menu = oItemsContextMenu;
  372. aWeights[i] = 1;
  373. trace("Element added: index="+i+", id="+id+", obj_class="+id+", obj_class="+name+", icon="+icon+newline+"details: "+aClips[i].details.values);
  374. return i;
  375. }
  376. function GetParentAngle(oClip:MovieClip)
  377. {
  378. var angle:Number = 0;
  379. trace("GetParentAngle oClip.parentId: "+oClip.parentId);
  380. if (oClip.parentId != undefined)
  381. {
  382. oParentClip = aClips[oClip.parentId];
  383. dx = oClip._x - oParentClip._x;
  384. dy = oClip._y - oParentClip._y;
  385. trace("GetParentAngle dx: "+dx+", dy:"+dy);
  386. if ((dx == 0) && (dy == 0))
  387. {
  388. angle = 0;
  389. }
  390. else
  391. {
  392. angle = Math.atan2(dy, dx);
  393. }
  394. }
  395. trace("GetParentAngle returned: "+((angle*360)/(2*Math.PI)));
  396. return angle;
  397. }
  398. function FindItemByIdAndClass(id, obj_class)
  399. {
  400. var result = -1;
  401. var i = 0;
  402. while ( (i < aClips.length) && (result == -1))
  403. {
  404. if ((aClips[i].id == id) && (aClips[i].obj_class == obj_class))
  405. {
  406. result = i;
  407. }
  408. i++;
  409. }
  410. return result;
  411. }
  412. function AddLink(sourceIndex, destinationIndex, bArrow)
  413. {
  414. trace("Adding link between srcIndex:"+sourceIndex+" and destIndex:"+destinationIndex+" (arrow:"+bArrow+" )");
  415. aLinks[aLinks.length] = { start: sourceIndex, end: destinationIndex, bArrow: bArrow };
  416. }
  417. oLinksMovie = _root.createEmptyMovieClip ("links", -1);
  418. oForcesMovie = _root.createEmptyMovieClip ("forces", 9999);
  419. oLinksMovie.onEnterFrame = DrawItems;
  420. oForcesMovie.onEnterFrame = DrawForces;
  421. ////////////////////////////////////////////////////////////////////////////
  422. // Experimenting with the load of an XML file
  423. ////////////////////////////////////////////////////////////////////////////
  424. // Create a new XML object.
  425. var myLoader:XML = new XML();
  426. // Set the ignoreWhite property to true (default value is false).
  427. myLoader.ignoreWhite = true;
  428. // After loading is complete, trace the XML object.
  429. myLoader.onLoad = function(success)
  430. {
  431. DumpClips("Beginning of (asynchronous) load");
  432. if (success)
  433. {
  434. myXML = new XML();
  435. myXML.parseXML(myLoader);
  436. oRootNode = myXML.firstChild;
  437. trace("root node: "+oRootNode.nodeName);
  438. if (oRootNode.attributes.title != undefined)
  439. {
  440. StaticContainer.Schema_title = oRootNode.attributes.title;
  441. }
  442. else
  443. {
  444. StaticContainer.Schema_title = "";
  445. }
  446. oFirstNode = oRootNode.firstChild;
  447. oStartPoint = {x:0, y:0};
  448. var placement = "";
  449. switch (oRootNode.attributes.position)
  450. {
  451. case "top":
  452. oStartPoint.x = pWidth/2;
  453. oStartPoint.y = 2*radius;
  454. break;
  455. case "left":
  456. oStartPoint.x = 2*radius;
  457. oStartPoint.y = pHeight/2;
  458. break;
  459. case "center":
  460. default:
  461. oStartPoint.x = pWidth /2;
  462. oStartPoint.y = pHeight /2;
  463. placement = "surround";
  464. }
  465. LoadNode(oFirstNode, undefined, oStartPoint.x, oStartPoint.y, placement);
  466. }
  467. else
  468. {
  469. trace("Failed to load XML data:"+newline+myLoader);
  470. }
  471. _level0.LoadingAnimation._alpha = 0;
  472. _level0.LoadingAnimation.stop();
  473. DumpClips("End of (asynchronous) load");
  474. }
  475. function LoadNode(oXmlNode:Object, parentIndex:Number, x:Number, y:Number, placementMethod:String)
  476. {
  477. trace("Loading Node: "+oXmlNode);
  478. var nodeId = oXmlNode.attributes.id;
  479. var nodeClass = oXmlNode.attributes.obj_class;
  480. var nodeName = oXmlNode.attributes.name;
  481. var nodeIcon = oXmlNode.attributes.icon;
  482. var nodeIndex = FindItemByIdAndClass(nodeId, nodeClass);
  483. var nodeZlist = oXmlNode.attributes.zlist;
  484. var aNodeZlist = nodeZlist.split(',');
  485. var oNodeDetails = { names: new Array(), values: new Array() };
  486. for(var att_index=0; att_index<aNodeZlist.length; att_index++)
  487. {
  488. oNodeDetails.names[att_index] = aNodeZlist[att_index];
  489. oNodeDetails.values[att_index] = eval("oXmlNode.attributes.att_"+att_index);
  490. }
  491. trace("ZList:"+nodeZlist);
  492. trace("oNodeDetails.values:"+oNodeDetails.values);
  493. oXmlNode.attributes.zlist;
  494. if (nodeIndex == -1)
  495. {
  496. nodeIndex = CreateItem(nodeId, nodeClass, nodeIcon, nodeName, x, y, parentIndex, oNodeDetails);
  497. trace("Node inserted: nodeIndex = "+nodeIndex);
  498. }
  499. else
  500. {
  501. trace("Node (id:"+nodeId+" , class:"+nodeClass+", name:"+nodeName+" ) already loaded...");
  502. placementMethod = "";
  503. }
  504. var oLinks = oXmlNode.firstChild;
  505. trace("oLinks: "+oLink);
  506. if (oLinks != undefined)
  507. {
  508. var iCount:Number = 0;
  509. for(var i=0; i<oLinks.childNodes.length; i++)
  510. {
  511. var oCurrentLink = oLinks.childNodes[i];
  512. var arrow = oCurrentLink.attributes.arrow;
  513. trace(oCurrentLink.nodeName);
  514. var oChildNode = oCurrentLink.firstChild;
  515. var childId = oChildNode.attributes.id;
  516. var childClass = oChildNode.attributes.obj_class;
  517. var childIndex = FindItemByIdAndClass(childId, childClass);
  518. var oChildPt:Object;
  519. if (placementMethod == 'surround')
  520. {
  521. angle = 2*Math.PI / (oLinks.childNodes.length);
  522. }
  523. else
  524. {
  525. angle = Math.PI / 8;
  526. }
  527. if (childIndex == -1)
  528. {
  529. trace("Placing child: id:"+chidlId+", class:"+childClass+", name:"+childName);
  530. oChildPt = PlaceChild(aClips[nodeIndex], iCount, angle);
  531. iCount++;
  532. }
  533. else
  534. {
  535. oChildPt.x = aClips[childIndex]._x;
  536. oChildPt.y = aClips[childIndex]._y;
  537. }
  538. trace("iCount: "+iCount);
  539. trace("============= DOWN ONE LEVEL ==============");
  540. childIndex = LoadNode(oChildNode, nodeIndex, oChildPt.x, oChildPt.y);
  541. trace("============= UP ONE LEVEL ==============");
  542. AddLink(nodeIndex, childIndex, arrow /* bArrow */);
  543. }
  544. }
  545. return nodeIndex;
  546. }
  547. function DoReload(id, obj_class, relation)
  548. {
  549. _level0.LoadingAnimation.gotoAndPlay(1);
  550. _level0.LoadingAnimation._alpha = 35;
  551. trace("Reloading for id = "+id+", obj_class = "+obj_class);
  552. var icon = "";
  553. var name = ""
  554. var oDetails = {};
  555. for (var i=0; i < aClips.length; i++)
  556. {
  557. if ( (aClips[i].id == id) && (aClips[i].obj_class == obj_class) )
  558. {
  559. icon = aClips[i].icon;
  560. name = aClips[i].name;
  561. oDetails = aClips[i].details;
  562. }
  563. aClips[i].removeMovieClip();
  564. }
  565. aClips = new Array;
  566. aLinks = new Array;
  567. aWeights = new Array;
  568. DumpClips("Before recreating any item");
  569. CreateItem(id, obj_class, icon, name, 100, 400, undefined, oDetails); // Re-create the root node
  570. DumpClips("After creating the first item");
  571. var sLoadUrl = xml_document_url+"?class="+obj_class+"&id="+id+"&relation="+relation;
  572. trace("Reloading from: "+sLoadUrl);
  573. myLoader.load(sLoadUrl); // Load the rest of the items
  574. }
  575. function DoLoad(id, obj_class, relation)
  576. {
  577. _level0.LoadingAnimation.gotoAndPlay(1);
  578. _level0.LoadingAnimation._alpha = 35;
  579. trace("Expanding id = "+id+", obj_class = "+obj_class);
  580. var sLoadUrl = xml_document_url+"?class="+obj_class+"&id="+id+"&relation="+relation;
  581. trace("Loading from: "+sLoadUrl);
  582. myLoader.load(sLoadUrl); // Load the rest of the items
  583. }
  584. function PlaceChild(oClip:MovieClip, iChildIndex:Number, deltaAngle)
  585. {
  586. var angle:Number = GetParentAngle(oClip) + GetAngle(iChildIndex, deltaAngle);
  587. x = oClip._x + 7*radius*Math.cos(angle);
  588. y = oClip._y + 7*radius*Math.sin(angle);
  589. trace("Child "+iChildIndex+", angle: "+(angle*360/(2*Math.PI))+" placed at { x: " +x+", y: "+y+" }");
  590. return { x:x, y:y, angle: angle };
  591. }
  592. function GetAngle(iChildIndex:Number, deltaAngle)
  593. {
  594. return (1-2*(iChildIndex % 2))*Math.floor( (iChildIndex+1) / 2) * deltaAngle;
  595. }
  596. function DumpClips(message)
  597. {
  598. trace("******** aClips - "+message+" **********");
  599. for (var i=0; i<aClips.length; i++)
  600. {
  601. trace("aClips["+i+"] = { id: "+aClips[i].id+", obj_class: "+aClips[i].obj_class+", name: "+aClips[i].name+", type: "+aClips[i].type+" }");
  602. }
  603. trace("*************************");
  604. }
  605. function ShowTooltip(oClip)
  606. {
  607. // Show the Tooltip next to the mouse cursor
  608. var mouse_point:Object = {x:oClip._xmouse, y:oClip._ymouse};
  609. oClip.localToGlobal(mouse_point);
  610. Tooltip_movie._x = mouse_point.x;
  611. Tooltip_movie._y = mouse_point.y;
  612. Tooltip_movie._alpha = 60;
  613. Tooltip_movie.oldDepth = Tooltip_movie.getDepth();
  614. Tooltip_movie.swapDepths(999);
  615. Tooltip_movie._visible = true;
  616. trace(Tooltip_movie.Properties_grid);
  617. for(var index = 0; index <50; index++)
  618. {
  619. Tooltip_movie.Properties_grid.removeItemAt(0);
  620. }
  621. trace("Clips details: "+oClip.details.names);
  622. for(var index = 0; index <oClip.details.names.length; index++)
  623. {
  624. Tooltip_movie.Properties_grid.addItem({Name: oClip.details.names[index], Value: oClip.details.values[index]});
  625. }
  626. Tooltip_movie.Properties_grid.spaceColumnsEqually();
  627. oClip.iTimeout = 0;
  628. }
  629. function HideTooltip()
  630. {
  631. Tooltip_movie._visible = false;
  632. Tooltip_movie.swapDepths(Tooltip_movie.oldDepth);
  633. }
  634. // Load the XML into the myLoader object.
  635. //myLoader.load(xmlUrl+"?class="+root_object_class+"&id="+root_object_id);
  636. myLoader.load(xml_document_url+"?class="+root_object_class+"&id="+root_object_id+"&relation="+root_relation);