Posted By

jknight42 on 08/13/11


Tagged

flash jsfl


Versions (?)

JSFL: Display simple heirarchy of a FLA file. Showing movie clips, text fields, bitmaps etc.


 / Published in: JavaScript
 

URL: http://www.cannedbanners.com

Spent a while working on this and it's still sort of halfway there, but probably helpful for some people. What it does is iterates thru each element in an FLA timeline displays instance names where available. It also goes into any movie clips and shows the elements in each movie clip too. The result is a pretty simple hierarchy of your FLA structure.

  1. var curr_doc = fl.getDocumentDOM();
  2. fl.outputPanel.clear();
  3.  
  4. var main_timeline = curr_doc.getTimeline();
  5. var tab = "\t";
  6. displayAllElements(main_timeline, tab);
  7.  
  8. function displayAllElements(theTimeline, theTab) {
  9. var i = 0;
  10.  
  11. while(i < theTimeline.layers.length){
  12. var j = 0;
  13. while(j < theTimeline.layers[i].frames[0].elements.length) {
  14.  
  15. if(theTimeline.layers[i].frames[0].elements[j].elementType == "shape") {
  16. fl.trace(theTab+"[no instance] shape");
  17. } else if(theTimeline.layers[i].frames[0].elements[j].elementType == "instance") {
  18. if(theTimeline.layers[i].frames[0].elements[j].instanceType == "bitmap") {
  19. fl.trace(theTab+"[no instance] bitmap");
  20. } else if(theTimeline.layers[i].frames[0].elements[j].instanceType == "symbol") {
  21. fl.trace(theTab+theTimeline.layers[i].frames[0].elements[j].name);
  22. } else {
  23. fl.trace(theTab+"--something else")
  24. }
  25. } else if(theTimeline.layers[i].frames[0].elements[j].elementType == "text") {
  26. fl.trace(theTab+theTimeline.layers[i].frames[0].elements[j].name);
  27. } else {
  28. fl.trace(theTab+"-something else");
  29. }
  30.  
  31.  
  32. if(theTimeline.layers[i].frames[0].elements[j].elementType == "instance") {
  33. if(theTimeline.layers[i].frames[0].elements[j].libraryItem.itemType=="movie clip") {
  34.  
  35. var curr_lib_item = theTimeline.layers[i].frames[0].elements[j].libraryItem.name;
  36. curr_doc.library.editItem(curr_lib_item);
  37. var new_timeline = curr_doc.getTimeline();
  38. displayAllElements(new_timeline, theTab+tab);
  39. }
  40. }
  41. j++
  42. }
  43. i++;
  44. }
  45. }

Report this snippet  

You need to login to post a comment.