Zurück   Flashforum > Flash > ActionScript > ActionScript 2

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 19-09-2011, 12:17   #1 (permalink)
Neuer User
 
Registriert seit: Jul 2011
Ort: Kiel
Beiträge: 16
Schneefall im bestimmten Bereich

Hallo Ihr Lieben,

hab ein Script für ein Schneefall, möchte diesen aber nur einem bestimmten Bereich sehen. Per einfacher Maske geht es nicht. Ich habe mir auch shcon schon die anderen Anfragen durchgelesen und weiß, dass ich im Code wohl ein MC festlegen kann. Aber egal was ich probiere, es kommt dabei leider nicht der gewünschte Effekt raus.

Anbei mal mein Script. Bin über jede Hilfe dankbar.

PHP-Code:
function schnee(pAnzahlpBreitepHoehe,pFlockenDim,pFlockenDichte) {
for (var 
0i<=pAnzahli++) {
this.attachMovie("fClip""flocke"+ii);
this["flocke"+i].skal 50+(Math.random()*pFlockenDim);
this["flocke"+i].alpha 20+(Math.random()*pFlockenDichte);
this["flocke"+i]._xscale this["flocke"+i].skal;
this["flocke"+i]._yscale this["flocke"+i].skal;
this["flocke"+i]._alpha this["flocke"+i].alpha;
this["flocke"+i].xpos this["flocke"+i]._x;
this["flocke"+i]._x = -10+(Math.random()*pBreite);
this["flocke"+i].zufall 1+(Math.random()*2);
this["flocke"+i]._y = -10+(Math.random()*pHoehe);
this["flocke"+i].wind = -Math.PI+(Math.random()*Math.PI);
this["flocke"+i].onEnterFrame = function() {
this.rad += ((this.wind/180)*Math.PI);
this._x -= Math.cos(this.rad);
this._y += this.zufall;
if (
this._y>=pHoehe) {
this._y = -5;
}
if ((
this._x>=pBreite) || (this._x<=0)) {
this._x = -10+(Math.random()*pBreite);
}
};
}
}
 
// Aufruf der Funktion (Schnee-Effekt ausführen)
schnee(100,Stage.width,Stage.height,100,50); 
PB2011 ist offline   Mit Zitat antworten
Alt 19-09-2011, 18:04   #2 (permalink)
AS3-boon
 
Benutzerbild von 3kleinemarder
 
Registriert seit: Sep 2011
Ort: Hesse
Beiträge: 12
hallo. einfacher weg:

dein script in ein mc schreiben. die groesse aendern und die dichte anpassen.
als beispiel eine flaeche 100*100

Code:
function schnee(pAnzahl, pBreite, pHoehe, pFlockenDim, pFlockenDichte)
{
	for (var i = 0; i <= pAnzahl; i++)
	{
		this.attachMovie("fClip","flocke" + i,i);
		this["flocke" + i].skal = 50 + (Math.random() * pFlockenDim);
		this["flocke" + i].alpha = 20 + (Math.random() * pFlockenDichte);
		this["flocke" + i]._xscale = this["flocke" + i].skal;
		this["flocke" + i]._yscale = this["flocke" + i].skal;
		this["flocke" + i]._alpha = this["flocke" + i].alpha;
		this["flocke" + i].xpos = this["flocke" + i]._x;
		this["flocke" + i]._x = -10 + (Math.random() * pBreite);
		this["flocke" + i].zufall = 1 + (Math.random() * 2);
		this["flocke" + i]._y = -10 + (Math.random() * pHoehe);
		this["flocke" + i].wind = -Math.PI + (Math.random() * Math.PI);
		this["flocke" + i].onEnterFrame = function()
		{
			this.rad += ((this.wind / 180) * Math.PI);
			this._x -= Math.cos(this.rad);
			this._y += this.zufall;
			if (this._y >= pHoehe)
			{
				this._y = -1;
			}
			if ((this._x >= pBreite) || (this._x <= 0))
			{
				this._x = -10 + (Math.random());
			}
		};
	}
}

// Aufruf der Funktion (Schnee-Effekt ausführen)
schnee(50,100,100,10,50); //hier geaendert.
den mc plazierst du dir dann da wo du ihn haben willst.
__________________
sine qua non
3kleinemarder ist offline   Mit Zitat antworten
Alt 19-09-2011, 19:10   #3 (permalink)
Flash-Designer
 
Benutzerbild von Martin Kraft
 
Registriert seit: May 2006
Ort: Wiesbaden
Beiträge: 6.162
Außerdem würde ich eine lokale Variable verwenden. Diese dynamischen Zugriffe sind nämlich relativ rechenintensiv und machen den Code ziemlich unübersichtlich:
PHP-Code:
var mc:MovieClip this.attachMovie("fClip""flocke" i,i);
mc.skal 50 + (Math.random() * pFlockenDim);
mc.... 
__________________
Viele Grüße // Martin

Martin Kraft // Interaktionsdesign

Hilfreiche Websites:
// Hilfe zur Adobe Flash Plattform
// ActionScript 2 Referenz
// ActionScript 3 Referenz
// ActionScript 3 Arbeitshandbuch
// weitere Flash Ressourcen

Bitte keine Flashfragen per PM oder Profilnachricht! Dafür ist das Forum da!
Martin Kraft 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


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Flash CS3] Nur bestimmten Bereich exportieren Futsch Flash Einsteiger 1 08-10-2009 14:07
Bestimmten Bereich überprüfen! velocity. Flash 8 1 30-06-2009 14:35
AS auf bestimmten Bereich begrenzen DirtyWorld Flash MX 2004 1 11-03-2005 07:08
Screenshot von bestimmten bereich in mc lilly26 ActionScript 1 3 21-11-2004 16:28
in einem bestimmten bereich melba008 Flash MX 5 05-11-2003 17:08


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:36 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele