Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 05-05-2007, 19:15   #1 (permalink)
Neuer User
 
Registriert seit: May 2007
Beiträge: 1
Grass mit Maus bewegen

Hey Leute,

bin neu hier und habe folgendes Problem habe noch nicht viele Erfahrungen mit AS.
Von daher bin ich am lernen und um dies zu tun schaute ich mich bisschen im Netz um und fand ein Script für das bewegen von „Grass im Wind“. So da kam mir die Idee es in eine Webseite einzubauen. Keine Angst ist alles i.O. der Erstellter des Scripts gab es für diese Zwecke frei.

Nun habe ich aber zwei Probleme ich wollte euch Fragen ob einer mir helfen kann es so zu zu arbeiten das ich mit dem Mauszeiger Drüber gehen kann und so mit das Gras wegstreichen kann und Zweitens könnte mir jemand erklären wie das dort mit dem Ändern der Farben funktioniert. Ich verstehe es nicht drei Hexa Codes wo bei die ersten offensichtlich Addiert werden aber wieso dann der dritte was bewirk dieser? Ich hoffe ihr könnt mir hier ein bisschen weiter helfen und das Script vielleicht sogar gleich umschreiben. Der Umschreiber und der Ersteller werden selbstverständlich auf der Seite erwähnt.

Also bis denn dann Greatz Sling


Der Code

// Animated grass - Jim Bumgardner
//

DAMP = 0.9
TSPEED = 5 // turbulence (individual motion)
WSPEED = 2 // wind (common motion)

windx = 0; // Added these initializations for Flash Player 7
windy = 0;

MovieClip.prototype.drawBlade = function()
{
this.clear();
this.moveTo(-5,0);
this.beginFill(this.clr, 100);
this.curveTo(this.cx-5,this.cy,this.ex, this.ey);
this.curveTo(this.cx+5,this.cy, 5, 0);
this.lineTo(-5,0);
this.endFill();
}

function bladeMove()
{
this.vx1 += Math.random()*TSPEED-TSPEED/2 + windx;
this.vy1 += Math.random()*TSPEED-TSPEED/2;
this.vx2 += Math.random()*TSPEED-TSPEED/2 + windx;
this.vy2 += Math.random()*TSPEED-TSPEED/2;
this.vx1 *= DAMP; // damping
this.vx2 *= DAMP;
this.vy1 *= DAMP;
this.vy2 *= DAMP;
this.cx = this.cxR + this.vx1;
this.cy = this.cyR + this.vy1;
this.ex = this.exR + this.vx2 + windx;
this.ey = this.eyR + this.vy2 + windy;
this.drawBlade();
// Add these lines to travel horizontally
/*
this._x -= 3;
if (this._x < -5)
this._x += Stage.width+10;
*/
}

function windBlow()
{
windx += Math.random()*WSPEED - WSPEED/2;
windx *= DAMP;
}

for (var i = 0; i <= 200; ++i) {
var mc = this.createEmptyMovieClip("fish_mc_"+i, i);
mc._x = i*5;
mc._y = Stage.height -45;
mc.clr = (0x333333);
mc.cx = mc.cxR = Math.random()*10-5;
mc.cy = mc.cyR = -(40+Math.random()*35);
mc.ex = mc.exR = Math.random()*10-5;
mc.ey = mc.eyR = mc.cyR*2;
mc.vx1 = 0; // Added these initializataions for Flash Player 7
mc.vx2 = 0;
mc.vy1 = 0;
mc.vy2 = 0;
mc.onEnterFrame = bladeMove;
}

this.onEnterFrame = windBlow;


// Slider UI stuff - I usually prefer to roll my own sliders, rather than
// using components, since the code often ends up being nearly the
// same size, and I prefer having code I can see & understand.
// Nonetheless, I'm probably asking for trouble...
//

MovieClip.prototype.setupSlider = function(lab,min,max,val,changeFunc)
{
this.minv = min;
this.maxv = max;
this.range = max - min;
this.val = val;
this.changeFunc = changeFunc;
this.its_label.text = lab;
this.its_value.text = val;
this.knob_mc.useHandCursor = true;
this.knob_mc._x = (this.val - this.minv)*200/this.range;
this.changeFunc(this.val);
this.onMouseMove = function()
{
if (!this.dragging)
return;
x = this._xmouse;
if (x >= 0 && x <= 200)
{
this.knob_mc._x = x;
var r = x/200;
this.val = this.minv + r*this.range;
this.its_value.text = Math.round(this.val);
this.changeFunc(this.val);
}
};
this.knob_mc.onPress = function() { this._parent.dragging = true; };
this.knob_mc.onRelease = function() { this._parent.dragging = false; };
this.knob_mc.onReleaseOutside = function() { this._parent.dragging = false; };
}

function setTurb(t)
{
TSPEED = t;
}

function setWind(w)
{
WSPEED = w;
}

// Setup the 4 sliders...
slider1_mc.setupSlider('Turbulence',0,2, TSPEED,setTurb);
slider2_mc.setupSlider('Wind',0,3, WSPEED,setWind);
Sling2007 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 17:18 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele