Zurück   Flashforum > Flash > ActionScript > ActionScript 2

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 20-11-2006, 09:00   #1 (permalink)
Neuer User
 
Benutzerbild von Mapache
 
Registriert seit: Oct 2006
Beiträge: 64
Question Dynamische Object Property

Ich gerne ein Assoziatives Array erzeugen und verwende dazu ein Object Element. Ich übergebe meinem Konstruktor einen String und eine Number, namens typ und count.

Ich will jetzt in dem Objekt, zu einem bestimmten Typ den dazugehörigen count ablegen.

Code:
	public function Connection ( mytype:String, count:Number ) {
		this.type = new Object();
		//this.type.addProperty(mytype);
		this.type.mytype = count;
		trace(mytype+" - "+count);
Bei der Ausgabe, die ich an anderer Stelle laufen lasse, bekomme ich aber immer angezeigt, dass die property "mytype" heißt und eben nicht nach dem übergebenen String benannt wurde.

Code:
		for ( var i in this.type ) {
			var t = typeof ( this.type[i] );
			var c = this.type[i];
			trace("CON: "+i+" is "+t+" - "+c);	
		}
Ausgabe
Code:
CON: mytype is string - 1
CON: mytype is string - 1
CON: mytype is string - 3
Woran mag das liegen?
Kann ich in meinem Object nicht dynmisch properties erzeugen? Müssen die fest definiert sein?

Help
Mapache ist offline   Mit Zitat antworten
Alt 20-11-2006, 11:09   #2 (permalink)
Neuer User
 
Benutzerbild von Mapache
 
Registriert seit: Oct 2006
Beiträge: 64
Cool

Boa, ich habs ...

Code:
		
                this.type = new Object();
		this.type.addProperty(mytype);
		this.type[mytype] = count;
Trotzdem danke ... bye
Mapache ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 15:47 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele