| derkzer
Registriert seit: Jan 2004
Beiträge: 30
| Random-Werte zuweisen | laco-tween
Hallo Ihr,
bin gerade etwas am verzweifeln.
Ich tweene mehrere mc's mit den laco-tweens und möchte mittels random zufällige X&Y-Werte zuweisen (die auf jedenfall über 1000 liegen sollen (als bsp)). In der Flashhilfe habe ich das gefunden: PHP-Code: function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}
for (var i = 0; i < 100; i++) {
var n:Number = randRange(4, 11)
trace(n);
}
Das ganze habe ich dann einfach übernommen was natürlich nicht zu dem gewünschten Erfolg führte da immer die gleichen Werte für jeden mc rauskamen. PHP-Code: #include "lmc_tween.as"
////////////////////////////////////////////////////
var xKo = 40;
var yKo = 40;
var animationtype1 = 'easeOutElastic';
var animationtype2 = 'easeOutSlap';
////////////////////////////////////////////////////
function randRange(min:Number, max:Number, laufvariable:Number):Number {
var randomNum:Number = Math.floor(Math.random(laufvariable)*(max-min+1))+min;
return randomNum;
}
for (var i = 0; i<1; i++) {
var xwert:Number = randRange(-300, -600);
var ywert:Number = randRange(-300, -600);
trace(xwert);
trace(ywert);
}
////////////////////////////////////////////////////
this.onEnterFrame = function() {
t_bg1.tween('_y', yKo, 1, animationtype2, 2);
t_bg1.tween('_x', xKo+260, 1, animationtype2, 2);
t_bg1.tween('_width', 210, 0.5, animationtype2, 0);
t_bg1.tween('_height', 25, 0, animationtype2, 2);
t_bg2.tween('_y', yKo+25, 1, animationtype2, 2);
t_bg2.tween('_x', xKo, 1, animationtype2, 2);
t_bg2.tween('_width', 527, 0.5, animationtype2, 0);
t_bg2.tween('_height', 25, 0, animationtype2, 2);
t_bg3.tween('_y', yKo+50, 1, animationtype2, 2);
t_bg3.tween('_x', xKo, 1, animationtype2, 2);
t_bg3.tween('_width', 552, 0.5, animationtype2, 0);
t_bg3.tween('_height', 25.25, 0, animationtype2, 2);
t_bg4.tween('_y', yKo+75, 1, animationtype2, 2);
t_bg4.tween('_x', xKo, 1, animationtype2, 2);
t_bg4.tween('_width', 537, 0.5, animationtype2, 0);
t_bg4.tween('_height', 25, 0, animationtype2, 2);
t_bg5.tween('_y', yKo+100, 1, animationtype2, 2);
t_bg5.tween('_x', xKo, 1, animationtype2, 2);
t_bg5.tween('_width', 552, 0.5, animationtype2, 0);
t_bg5.tween('_height', 25, 0, animationtype2, 2);
t_bg6.tween('_y', yKo+125, 1, animationtype2, 2);
t_bg6.tween('_x', xKo, 1, animationtype2, 2);
t_bg6.tween('_width', 530, 0.5, animationtype2, 0);
t_bg6.tween('_height', 25, 0, animationtype2, 2);
t_bg7.tween('_y', yKo+150, 1, animationtype2, 2);
t_bg7.tween('_x', xKo, 1, animationtype2, 2);
t_bg7.tween('_width', 544, 0.5, animationtype2, 0);
t_bg7.tween('_height', 25, 0, animationtype2, 2);
t_bg8.tween('_y', yKo+175, 1, animationtype2, 2);
t_bg8.tween('_x', xKo, 1, animationtype2, 2);
t_bg8.tween('_width', 420, 0.5, animationtype2, 0);
t_bg8.tween('_height', 25, 0, animationtype2, 2);
t_bg9.colorTo(0xFFFFFF, 1, animationtype2);
t_bg9.tween('_y', yKo+215, 1, animationtype2, 2);
t_bg9.tween('_x', xKo, 1, animationtype2, 2);
t_bg9.tween('_width', 155, 0.5, animationtype2, 0);
t_bg9.tween('_height', 25, 0, animationtype2, 2);
t_bg10.colorTo(0xCCCC00, 1, animationtype2);
t_bg10.tween('_y', yKo+215, 1, animationtype2, 2);
t_bg10.tween('_x', xKo+170, 1, animationtype2, 2);
t_bg10.tween('_width', 41, 0.5, animationtype2, 0);
t_bg10.tween('_height', 25, 0, animationtype2, 2);
//////////////////////////////////////////////////////
klick1.tween('_y', yKo+215, 1, animationtype1, 3);
klick1.tween('_x', xKo+170, 1, animationtype1, 3);
delete this.onEnterFrame;
};
////////////////////////////////////////////////////
klick1.onRelease = function() {
beweg1();
};
////////////////////////////////////////////////////
function beweg1() {
t_bg1.tween('_y', ywert, 1, animationtype2, 2);
t_bg1.tween('_x', xwert, 1, animationtype2, 2);
t_bg1.tween('_width', 1, 0.5, animationtype2, 0);
t_bg1.tween('_height', 25, 0, animationtype2, 2);
t_bg2.tween('_y', ywert, 1, animationtype2, 2);
t_bg2.tween('_x', xwert, 1, animationtype2, 2);
t_bg2.tween('_width', 1, 0.5, animationtype2, 0);
t_bg2.tween('_height', 25, 0, animationtype2, 2);
t_bg3.tween('_y', ywert, 1, animationtype2, 2);
t_bg3.tween('_x', xwert, 1, animationtype2, 2);
t_bg3.tween('_width', 1, 0.5, animationtype2, 0);
t_bg3.tween('_height', 25, 0, animationtype2, 2);
t_bg4.tween('_y', ywert, 1, animationtype2, 2);
t_bg4.tween('_x', xwert, 1, animationtype2, 2);
t_bg4.tween('_width', 1, 0.5, animationtype2, 0);
t_bg4.tween('_height', 25, 0, animationtype2, 2);
t_bg5.tween('_y', ywert, 1, animationtype2, 2);
t_bg5.tween('_x', xwert, 1, animationtype2, 2);
t_bg5.tween('_width', 1, 0.5, animationtype2, 0);
t_bg5.tween('_height', 25, 0, animationtype2, 2);
t_bg6.tween('_y', ywert, 1, animationtype2, 2);
t_bg6.tween('_x', xwert, 1, animationtype2, 2);
t_bg6.tween('_width', 1, 0.5, animationtype2, 0);
t_bg6.tween('_height', 25, 0, animationtype2, 2);
t_bg7.tween('_y', ywert, 1, animationtype2, 2);
t_bg7.tween('_x', xwert, 1, animationtype2, 2);
t_bg7.tween('_width', 1, 0.5, animationtype2, 0);
t_bg7.tween('_height', 25, 0, animationtype2, 2);
t_bg8.tween('_y', ywert, 1, animationtype2, 2);
t_bg8.tween('_x', xKo, 1, animationtype2, 2);
t_bg8.tween('_width', 1, 0.5, animationtype2, 0);
t_bg8.tween('_height', 25, 0, animationtype2, 2);
t_bg9.colorTo(0x000000, 1, animationtype2);
t_bg9.tween('_y', ywert, 1, animationtype2, 2);
t_bg9.tween('_x', xwert, 1, animationtype2, 2);
t_bg9.tween('_width', 1, 0.5, animationtype2, 0);
t_bg9.tween('_height', 25, 0, animationtype2, 2);
t_bg10.colorTo(0x000000, 1, animationtype2);
t_bg10.tween('_y', ywert, 1, animationtype2, 2);
t_bg10.tween('_x', xwert, 1, animationtype2, 2);
t_bg10.tween('_width', 1, 0.5, animationtype2, 0);
t_bg10.tween('_height', 25, 0, animationtype2, 2);
}
So nun drehe ich alles hin und her aber komme nicht auf einen Ansatz der zu der Lösung führt wie ich mehrere Werte, mehreren mc's zuweise.
Vll hat von euch jemand einen Ansatz/Idee/was auch immer. Wäre sehr schön.
KD
|