[ascoders] gotoAndPlay Aufruf in einer Klasse?
- From: "Peter Oliver Geller" <nc-gellerpe@xxxxxxxxxxxxx>
- To: <ascoders@xxxxxxxxxxxxx>
- Date: Mon, 30 Jun 2003 16:11:39 +0200
Hallo,
ich habe hier eine Klasse für einen Schmetterling der durch die Gegend
fliegt.
Funktioniert soweit auch erstmal, allerdings musste ich feststellen das
ich eine gotoAndPlay Aktion
innerhalb des flynow Aufrufs nicht direkt auf das Objekt ausführen kann.
D.h. ich musste erst ein Unterobjekt erstellen, wo die Animation dann
drin ist und kann diese dann auch ansprechen
(this.butterfly_ani.gotoAndPlay(irgendwas)),
habe ich allerdings die Animation direkt im Mc kann ich leider nicht
(this.gotoAndPlay(irgenwas)) schreiben, dann passiert nämlich gar
nichts.
Warum ist das so?
Bei einer Reversefunktion hat das nämlich funktioniert, da sieht es dann
so aus this.gotoAndStop(this._currentframe-1);
Nur bei gotoAndPlay( name oder frame ) nicht.
//Butterfly constructor
butterfly = function () {
this.flySpeed = 20;
this.myBounds = _root.boundbox.getBounds(_root);
this.a = 6;
this.d = 1.2;
this.newX = this._x;
this.newY = this._y;
this.myXspeed = 0;
this.myYspeed = 0;
};
butterfly.prototype.fly = function() {
this.change = random(5); // randomize the movement
if (this.change) {
this.newX = this._x+random(this.flySpeed)-(this.flySpeed/2);
this.newY = this._y+random(this.flySpeed)-(this.flySpeed/2);
}
// check the bounds
if (this.newX>this.myBounds.xMax) {
this.newX = this.myBounds.xMax;
} else if (this.newX<this.myBounds.xMin) {
this.newX = this.myBounds.xMin;
} else if (this.newY>this.myBounds.yMax) {
this.newY = this.myBounds.yMax;
} else if (this.newY<this.myBounds.yMin) {
this.newY = this.myBounds.yMin;
}
// find the new point, and start moving in that direction
this.myXspeed = ((this._x-this.newX)/this.a+this.myXspeed)/this.d;
this.myYspeed = ((this._y-this.newY)/this.a+this.myYspeed)/this.d;
this._x -= this.myXspeed;
this._y -= this.myYspeed;
};
flynow = function () {
this.butterfly_ani.gotoAndPlay(10); // wenn hier direkt das Objekt ohne
Unterobjekt angesprochen wird klappts nicht (this.gotoAndPlay(10);
this.onEnterFrame = function() { this.fly() }
};
// Object gets class
butterfly_mc.__proto__ = new butterfly();
butterfly_mc.onRollOver = flynow;
Danke
Peter
::::::::::::::::::::::::::::::::::::::::::::::
Peter Oliver Geller
(design / development)
www.pixel-gallery.net
::::::::::::::::::::::::::::::::::::::::::::::
- Follow-Ups:
- [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- From: Michael Kneib
- [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- From: Michael Nisi
Other related posts:
- » [ascoders] gotoAndPlay Aufruf in einer Klasse?
- » [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- » [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- From: Michael Kneib
- [ascoders] Re: gotoAndPlay Aufruf in einer Klasse?
- From: Michael Nisi