Coding Fri, 07 Aug 20 21:47:45 +0100 Coding en-CA about xml Mon, 12 Nov 2012 17:50:31 +0000 Nardo 49@/forum/discussions Hello,

I'm trying to parse some .xml to extract datas, so  I tried you're xml-testing.jsfl and xml.jsfl, in Codes Examples.
And read you're support about xml.
If I try this (xmlTest.jsfl) :

var xml = <xml> <a id='a' vowel="true"/> <b id='b'/> <c id='c' class="test" /> <d id='d' class="test"> <e id='e' vowel="true"> <f id='f' class="test" /> </e> </d> </xml>
var nodes = xml.find('a');
trace("nodes :  " + nodes);

trace >>

nodes : undefined

 If I try 

 xml.remove('.test', true);


trace >>

XML > processing path ".test": Object (depth:4, objects:0, values:7, time:0.0 seconds)
object => Object
match: ".test"
operator: "."
node: "test"
index: ""
filter: ""
attribute: ""
matchIndex: 0
  <a id="a" vowel="true"/>
  <b id="b"/>
  <c id="c" class="test"/>
  <d id="d" class="test">
    <e id="e" vowel="true">
      <f id="f" class="test"/>


I suppose I use a wrong method to access to nodes (?)
Thank's for this great framework. 

Nested elements Wed, 09 May 2012 15:16:49 +0100 fried 38@/forum/discussions Hi there,
I have been messing around with JSFL and xJSFL for about a week now. Going through the documentation and finding my way around. The reason for doing so is basically to streamline my workflow. The current project I'm working on requires me to open files, optimise bitmaps, create movieclips from elements and add scripts.
The files are exported from Indesign as XFl files (CS4). Here is the code I have so far, some are snippets found on the net and mostly vanilla JSFL.

var files = [];
var assetPath = "file:////Users/.../"
var pathToFLA = "file:////Users/.../";
//TODO - investigate xjsfl opening XFL files? Seems to not work correctly.
var folder = new Folder(assetPath).each(
var doc = fl.openDocument("file:///" + files[0].path)

var mc = $("*").select();


function checkNames(item)
	//sets compression type of each bitmap in the library
	item.compressionType = 'photo';

function optimiseRaster()
	//creates an item collection array of the bmp's in the library
	var collection = $$(":bitmap");
	//save the file

function nestedCollection()

function saveFile()
	//TODO - get the file name and use it to name the save file
	var docName =;
	var append = "youth_1.fla"
	var docURI = pathToFLA + append;

function publishFile()
	var profileXML = document.exportPublishProfileString('Default');
	profileXML = profileXML.replace("1", "0");
	profileXML = profileXML.replace("1", "0");
	profileXML = profileXML.replace("1", "0");
	var findString = "";
	var startIndex = profileXML.indexOf(findString) + findString.length;
	findString = "";
	var endIndex = profileXML.indexOf(findString);
	var curName = profileXML.substring(startIndex, endIndex);
	var publishPath = "../swf/" +".fla","");
	trace("This file is publishing to " + publishPath  + ".swf")
	profileXML = profileXML.replace(curName,publishPath);

//TODO - add layer script
function addLayer()


Firstly, how could I optimise this code a bit, any suggestions would be much appreciated.

Secondly, How do I access nested elements? I have been struggling with this. I don't fully understand Iterators and have been getting errors when working through the tutorials. I have to access the elements inside the main movieclip because they are placed in the correct position. If I convert them to movieclips in the library, I would have to place them stage and check x and y positions and these differ from file to file.

Thank you and sorry for the long post. Also, xJSFL is a great framework, just need to get my head around it all :D
$$() selector examples? Fri, 04 May 2012 01:23:47 +0100 HughC 36@/forum/discussions I'm struggling to get anything beyond the most basic (read: targeting the current timeline) element selectors working.

As soon as I try to use the second context param, it fails, whether a string, or a library item (see code below) it fails.

Each time, all I get is a silent JS error.


function checkContents(item, index, items) {
    var collection = $('*', item);
var objects = $$('/characters/*:movieclip');

in the above example objects list() is successful, and other trace statements indicate it's dying on the $ selector (ie collection.list() never produces output. Any suggestions?

iterators, small fix and question on silent error Tue, 27 Mar 2012 04:10:22 +0100 madmatt 27@/forum/discussions Hi, first message, and first thank you for producing such a tool.

I have been experimenting with iterators and , if I understand the docs, I should be able to run this script



try {

var doc = fl.openDocument("file:////mypath/myfile.fla");

Iterators.items(true, null, processLayer, processFrame, processElement);
catch (err) {
function processLayer(layer, index, layers, context) {
trace('> ' +;


function processFrame(frame, index, frames, context) {
trace(' > ' + frame.startFrame);


function processElement(element, index, elements, context) {
trace(' > ' +;

in order to iterate through all the library elements of my source file.


First off, I had to fix what I believe is a bug in core/jsfl/libraries/flash/Context.jsfl:

diff --git a/core/jsfl/libraries/flash/Context.jsfl b/core/jsfl/libraries/flash/Context.jsfl
index e24989b..8da2662 100644
--- a/core/jsfl/libraries/flash/Context.jsfl
+++ b/core/jsfl/libraries/flash/Context.jsfl
@@ -61,15 +61,17 @@
- if(layer)this.setLayer(layer);
- if(this.layer.layerType !== 'folder')
- {
- this.setFrame(frame);
- if(this.frame)
+ if(layer){
+ this.setLayer(layer);
+ if(this.layer.layerType !== 'folder')
- if(element)this.setElement(element);
+ this.setFrame(frame);
+ if(this.frame)
+ {
+ if(element)this.setElement(element);
+ }
- }
+ }
return this;


because I was getting errors when this.layer was undefined and layer.layerType was tested.


With this small fix I am able to (sort of) run the Iterators.items code but I always get stuck with what I believe you guys call a silent error on the console:

The following JavaScript error(s) occurred:


that is, no exception raised, the code stops executing somewhere inside the iterator (doc.close(false) doesn't get called, nor the catch block), no debug info.

This can happen, depending on the file, right away or halfway through the library scan.

I can successully use the layers method on the same files with no issues.

At the moment I have reverted to using the old (and not so cool) library scan nested for loop found in various sample jsfl files, but it would be great if I could understand whether I'm doing something I'm not supposed to do, or whether there's a problem and I can help fix it.

Unfortunately, with no debug info and no exception raised I cannot really tell what's happening ...

Persisting data in xJSFL Wed, 30 Nov 2011 03:12:50 +0000 Rytis 18@/forum/discussions Hi Dave,

I have a question about xJSFL API. 

Is there any simple way to persist script data without explictly writing it to file? Something like SharedObject?


Debugging silent script errors Fri, 27 May 2011 13:22:43 +0100 Dave 6@/forum/discussions A Twitter user has been having some problems with silent errors, which are indeed a complete pain in the ass. My experience of silent errors has been only when running erroneous scripts via fl.runScript();

I do want as part of the framework have some kind of functionality that tackles this somehow, and this is my first test.

It's a function that attempts to eval the contents of the passed uri, then will print any error messages (instead of failing), then finally will run the uri directly using an undocumented method of FLfile to get the actual line number of the error (but this could be erroneous itself if a nested script relies on scoped variables that may already be disposed of).

fl.tryScript = function(uri)
// if the file exists, test it
// grab the passed-in file contents
var path = '"' + FLfile.uriToPlatformPath(uri) + '"';
fl.trace('Testing: ' + path);
var jsfl =;

// attempt to eval the JSFL

// if it fails, print the error, then run the file standalone
fl.trace('Running: ' + path);
var exec = fl.version.match(/\bMAC\b/i) ? 'exec ' + path : path;

// Let the user know the file doesn't exist
fl.trace('Error: uri not found: ' + uri);

var uri = 'file:///C|/temp/jsfl/bad-file.jsfl'


Comments welcome.