# \<! JSFL -loop through selection

**URL:** https://forum.kirupa.com/t/jsfl-loop-through-selection/125160
**Category:** Uncategorized
**Created:** [October 11, 2004, 2:53am UTC](https://forum.kirupa.com/t/jsfl-loop-through-selection/125160 "2004-10-11T02:53:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wainui](https://avatars.discourse-cdn.com/v4/letter/w/ecc23a/32.png) [@wainui](https://forum.kirupa.com/u/wainui)
#### Post date: [October 11, 2004, 2:53am UTC](https://forum.kirupa.com/t/jsfl-loop-through-selection/125160/1 "2004-10-11T02:53:03Z")

</div>

Hi I am trying to be a build a copy and paste attributes extension for MX…

I can get it to work with only one item selected bbut am struggling to be able to loop through my selection… can any one help… At present I have the following…

```auto
sel = fl.getDocumentDOM().selection;
i = sel.length;
fl.trace("sel length = " + sel.length);
fl.trace("selection = " + sel)
while (i--) {
	fl.trace("element type = "+sel*.elementType);
	with (sel*) {
		if (sel*.elementType == "shape") {
			fl.getDocumentDOM().enterEditMode();
			fl.getDocumentDOM().selectAll();
		// other actions go here to paste attributes...
			fl.getDocumentDOM().exitEditMode();
		}
	}
}

```

I figure the problem might be with my “with” statement… any ideas???
