# Pls help me to change code as2 to as3

**URL:** <https://forum.kirupa.com/t/pls-help-me-to-change-code-as2-to-as3/324846>\
**Category:** Uncategorized\
**Created:** [September 12, 2011, 5:02am UTC](https://forum.kirupa.com/t/pls-help-me-to-change-code-as2-to-as3/324846 "2011-09-12T05:02:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![msksanthu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@msksanthu](https://forum.kirupa.com/u/msksanthu)\
**Post date:** [September 12, 2011, 5:02am UTC](https://forum.kirupa.com/t/pls-help-me-to-change-code-as2-to-as3/324846/1 "2011-09-12T05:02:59Z")

</div>

// Folder interaction/placement  
function SetAtBottomOfParent(below\_mc){  
if (below\_mc.\_parent.\_height) {  
below\_mc.\_y = below\_mc.\_parent.getBounds(below\_mc.\_parent).yMax;  
}  
}  
function SetBelow(below\_mc, top\_mc){  
if (top\_mc != undefined) {  
below\_mc.\_y = top\_mc.getBounds(top\_mc.\_parent).yMax;  
}  
}  
function ArrangeContents(directory\_mc){  
var item = directory\_mc.firstChild;  
if (item != undefined){  
while (item = item.nextSibling){  
SetBelow(item, item.previousSibling);  
}  
var parent\_container = directory\_mc.\_parent.\_parent;  
if (parent\_container != undefined) ArrangeContents(parent\_container);  
}  
}  
function Fold(){  
if (this.\_parent.directory\_mc.\_visible){  
this.\_parent.directory\_mc.\_visible = false;  
this.\_parent.directory\_mc.\_yscale = 0;  
}else{  
this.\_parent.directory\_mc.\_visible = true;  
this.\_parent.directory\_mc.\_yscale = 100;  
}  
ArrangeContents(this.\_parent.\_parent);  
scrollbar.contentChanged();  
}  
function open(){  
//\_root.userName = “Tim”;  
//load\_here.loadMovie(“moon.swf”);  
}  
// define basic variables for setting up the menu  
var item\_indent = 15;

function GenerateFileListing(directory\_node, target\_mc){  
var directory\_mc = target\_mc.createEmptyMovieClip(“directory\_mc”, 1);  
SetAtBottomOfParent(directory\_mc);  
directory\_mc.\_x += item\_indent;  
directory\_mc.depth = 0;

```
var contents = directory_node.childNodes;

var item_mc, last_item_mc;
for (var k=0; k&lt;contents.length; k++) {

	item_mc = directory_mc.attachMovie("directory_item","item"+directory_mc.depth, directory_mc.depth);
	directory_mc.depth++;
	
	item_mc.name_txt.text = contents[k].attributes.name;
	item_mc.icon_mc.gotoAndStop(contents[k].attributes.type);
	
	if (last_item_mc == undefined) directory_mc.firstChild = item_mc;
	else item_mc.previousSibling = last_item_mc;
	last_item_mc.nextSibling = item_mc;
	last_item_mc = item_mc;
	
	if (contents[k].attributes.type == "directory"){
		item_mc.select_btn.onPress = Fold;
		GenerateFileListing(contents[k],item_mc);
	}
	if (contents[k].attributes.type == "actionscript"){
		item_mc.select_btn.onPress = open;
		GenerateFileListing(contents[k],item_mc);
	}
	
	ArrangeContents(directory_mc);
}

```

}
