Last active
October 4, 2015 14:48
-
-
Save mauropm/2655813 to your computer and use it in GitHub Desktop.
Recursive clean of memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * An example of how to clean a window | |
| * Mauro Parra-Miranda | |
| * mauropm@gmail.com | |
| */ | |
| var win = Ti.UI.createWindow(); | |
| var view = Ti.UI.createView(); | |
| var label = Ti.UI.createLabel(); | |
| var label2 = Ti.UI.createLabel(); | |
| var image = Ti.UI.createImageView({ | |
| url:'KS_nav_ui.png', | |
| }); | |
| var view2 = Ti.UI.createView(); | |
| view2.add(label); | |
| view2.add(label2) | |
| view.add(view2); | |
| view.add(image); | |
| win.add(view); | |
| win.open(); | |
| function do_clean(e,c){ | |
| clean(c); | |
| e.remove(c); | |
| Ti.API.info( 'Deleted child at do_clean' ); | |
| return; | |
| } | |
| function clean(e){ | |
| if (e!=null){ | |
| if(e.children){ | |
| Ti.API.info( 'Number of children: ' + e.children.length ); | |
| for(var i = 0; i<e.children.length;i++){ | |
| do_clean(e, e.children[0]); | |
| } | |
| } else { | |
| return; | |
| } | |
| } | |
| } | |
| clean(win); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment