Prototype: Foreach [Flash 8]
| Beiträge: 2827 Wohnort: Bayern Registriert: Aug 2005
| 13.06.2007, 13:23
Auf jedes Item ein Callback Anwenden
Prototype:
ActionScript:1 2 3 4 | Array.prototype.foreach = function( callback:Function )
{
for( var index:String in this ) callback( index, this[ index ] );
}
|
Beispiel Aufruf:
ActionScript:1 2 3 4 5 6 7 8 | var myArray:Array = [ { name:'Hans', id:1 }, { name:'Wurst', id:2 } ];
function traceIt( index:String, item:Object ):Void
{
trace( item.name + '/' + item.id );
}
myArray.foreach( traceIt );
|
| |
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News
Regeln & Bedingungen
|