PDA

Volledige versie bekijken : alphaTween


chris80
%Europe/Berlin %043 %2005, 02:02
Beste mensen,

Ik probeer mijn externe ingeladen *.jpg in te faden. Dit wil ik doen met AlphaTween in actionscript. Nu krijg ik dit niet ingepast in mijn script. Heb zelf geen ervaring met actionscript. Er moet iemand zijn die mij een beetje op weg kan helpen. :o


Hier is mijn script:

createEmptyMovieClip("jpg_mc2", 8);
jpg_mc2._x = 15;
jpg_mc2._y = -350;
jpg_mc2.createEmptyMovieClip("container_mc2",0);
jpg_mc2.container_mc2.loadMovie("images/plaatje1.jpg");

this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
target_mc._x = 61.6;
target_mc._y = 1.8;
target_mc._alpha = 70;
target_mc.createEmptyMovieClip("container_mc",0);
target_mc.container_mc.loadMovie("images/button.jpg");
target_mc.onRollOver = function() {
target_mc._alpha = 100;}

target_mc.onRollOut = function() {
target_mc._alpha = 70;}

target_mc.onPress = function() {
createEmptyMovieClip("jpg_mc", 8);
jpg_mc._x = 15;
jpg_mc._y = -350;
jpg_mc.createEmptyMovieClip("container_mc",0);
jpg_mc.container_mc.loadMovie("images/plaatje.jpg");
};

this.createEmptyMovieClip("target_mc2", this.getNextHighestDepth());
target_mc2._x = 0.0;
target_mc2._y = 1.8;
target_mc2._alpha = 70;
target_mc2.createEmptyMovieClip("container_mc2",0);
target_mc2.container_mc2.loadMovie("images/button1.jpg");
target_mc2.onRollOver = function() {
target_mc2._alpha = 100;}

target_mc2.onRollOut = function() {
target_mc2._alpha = 70;}

target_mc2.onPress = function() {
createEmptyMovieClip("jpg_mc2", 8);
jpg_mc2._x = 15;
jpg_mc2._y = -350;
jpg_mc2.createEmptyMovieClip("container_mc2",0);
jpg_mc2.container_mc2.loadMovie("images/plaatje1.jpg");

};

Groetjes, Chris

The_One
%Europe/Berlin %850 %2005, 21:25
hoi,

Plaats dit stukje script op je 1e frame:
MovieClip.prototype.alphaTo = function(startA:Number, stopA:Number, speed:Number) {
this._alpha = startA;
this.onEnterFrame = function() {
this.alpha = (stopA-this._alpha)/speed;
if (Math.abs(this.alpha)<.05) {
this._alpha = stopA;
delete this.onEnterFrame;
} else {
this._alpha += this.alpha;
}
};
}

en vervang dit:
target_mc.onRollOver = function() {
target_mc._alpha = 100;}

target_mc.onRollOut = function() {
target_mc._alpha = 70;}

door dit:
target_mc.onRollOver = function() {
this.alphaTo(this._alpha, 100, 5);
}

target_mc.onRollOut = function() {
this.alphaTo(this._alpha, 70, 5);
}

Je alpha waarde verandert nu redelijk soepel. Ga een beetje knoeien met de speed [3e parameter [1e parameter = vanaf welke alpha waarde er getweend moet worden, en de 2e parameter = naar welke aplha er getweend moet worden]]

Suc6:)!

chris80
%Europe/Berlin %719 %2005, 18:15
Werkt prima

Super Bedankt!!!!!!!!! Sorry maar ik was niet helemaal duidelijk geweest welke plaatjes ik wilde infaden. Het moet namelijk het andere plaatje zijn.sorry, sorry Ik heb er nu dit van gemaakt.

MovieClip.prototype.alphaTo = function(startA:Number, stopA:Number, speed:Number) {
this._alpha = startA;
this.onEnterFrame = function() {
this.alpha = (stopA-this._alpha)/speed;
if (Math.abs(this.alpha)<.05) {
this._alpha = stopA;
delete this.onEnterFrame;
} else {
this._alpha += this.alpha;
}
};
}

this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
target_mc._x = 61.6;
target_mc._y = 1.8;
target_mc._alpha = 70;
target_mc.createEmptyMovieClip("container_mc",0);
target_mc.container_mc.loadMovie("images/plaatje.jpg");

target_mc.onRollOver = function() {
target_mc._alpha = 100;}

target_mc.onRollOut = function() {
target_mc._alpha = 70;}

target_mc.onPress = function() {
createEmptyMovieClip("jpg_mc", 8);
jpg_mc._x = 15;
jpg_mc._y = -350;
jpg_mc._alpha = 0;
jpg_mc.createEmptyMovieClip("container_mc",0);
jpg_mc.container_mc.loadMovie("images/looplicht.jpg");
jpg_mc.onEnterFrame = function() {
this.alphaTo(this._alpha, 100, 5);
};

};