AW: Bestimmte bereiche einer fla laden und den rest im hintergrund. geht das ?
hmm ich da ne schwierigkeit ....
das mit dem wasserfall hat super geklapt, nur warum werden alle objekte die ich vor dem wasserfall platziere (überschwämmt) :'( ?
ich wollte nämlich am fuße des wasserfalls nochmal eine kleine nebelbank platzieren, damit man die gerade kannte nicht sieht.
Aber jeder versuch ist gescheitert. Jemand ne idee warum das so ist ?
- Z-Ebenen stimmen, hab die in beide richtungen ausprobiert.
hier al der code vom wasserfall
---------------------------------
package com.flashandmath.dg.display {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import com.flashandmath.dg.objects.*;
import com.flashandmath.dg.display.RainDisplay;
public class Waterfall extends Sprite {
public var blur:BlurFilter;
public var colorFade:ColorTransform;
public var dropsToAddEachFrame:int;
public var bgColor:uint;
public var angle:Number;
public var display:RainDisplay;
public var leftMargin:Number;
public var topMargin:Number;
public var waterTopWidth:Number;
public var displayHeight:Number;
public var displayWidth:Number;
public var minAngle:Number;
public var maxAngle:Number;
public var minMagnitude:Number;
public var maxMagnitude:Number;
public var flowOn:Boolean;
private var _dropAlpha:Number;
private var _splashDropAlpha:Number;
private var _targetColor:uint;
private var _fadeAmount:Number;
private var magnitude:Number;
private var origin
oint;
private var bitmapData:BitmapData;
private var bitmap:Bitmap;
public function Waterfall(_displayWidth=650, _displayHeight=400, transparency = false) {
super();
origin = new Point(0,0);
dropsToAddEachFrame = 8;
displayHeight = _displayHeight;
displayWidth = _displayWidth;
topMargin = 20;
leftMargin = 2;
waterTopWidth = 235;
minAngle = Math.PI/12;
maxAngle = Math.PI/3;
minMagnitude = 0.7;
maxMagnitude = 1.3;
_splashDropAlpha = 0.3;
_dropAlpha = 0.45;
display = new RainDisplay(displayWidth,displayHeight,false);
blur = new BlurFilter(3,3);
_targetColor = 0x33B2FF;
_fadeAmount = -1;
var colorTargetR:Number = (_targetColor >> 16);
var colorTargetG:Number = (_targetColor >> 8) & 0xFF;
var colorTargetB:Number = _targetColor & 0xFF;
colorFade = new ColorTransform();
colorFade.redMultiplier = Math.pow(colorTargetR/255,0.03);
colorFade.greenMultiplier = Math.pow(colorTargetG/255,0.03);
colorFade.blueMultiplier = Math.pow(colorTargetB/255,0.03);
colorFade.alphaMultiplier = 1;
colorFade.alphaOffset = _fadeAmount;
/*
display.defaultDropColor = 0xffffff;
display.randomizeColor = false;
*/
/*
display.colorMethod = "random";
*/
/*
display.colorMethod = "gradient";
display.gradientColor1 = 0xaaaaff;
display.gradientColor2 = 0xffffff;
*/
display.colorMethod = "gray";
display.minGray = 0.9;
display.maxGray = 1;
display.defaultDropThickness = 1;
display.splashThickness = 1;
display.gravity = 0.1;
display.initialVelocityVariancePercent = 0.5;
display.initialVelocityVarianceX=0;
display.initialVelocityVarianceY=0;
display.dropLength = "long";
display.defaultDropAlpha = _dropAlpha;
display.splashAlpha = _splashDropAlpha;
display.splashMaxVelX = 0.8;
display.splashMinVelX = -0.8;
display.splashMinVelY = 0.4;
display.splashMaxVelY = 1.8;
display.minSplashDrops = 2;
display.maxSplashDrops = 3;
display.removeDropsOutsideXRange = false;
if (transparency) {
bitmapData = new BitmapData(display.displayWidth, display.displayHeight, true, 0x00000000);
}
else {
bitmapData = new BitmapData(display.displayWidth, display.displayHeight, false, 0x000000);
}
bitmap = new Bitmap(bitmapData);
bitmap.x = 0;
bitmap.y = 0;
this.addChild(bitmap);
display.wind = new Point(0,0);
flowOn = false;
this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageListener);
this.addEventListener(Event.ADDED_TO_STAGE, addedToStageListener);
}
private function addedToStageListener(evt:Event):void {
//When waterfall is added to stage, we start the animation.
this.stage.addEventListener(Event.ENTER_FRAME, onEnter);
}
private function removedFromStageListener(evt:Event):void {
//If the waterfall is removed from the stage, we should stop animating it.
this.stage.removeEventListener(Event.ENTER_FRAME, onEnter);
}
public function set dropAlpha(a:Number):void {
_dropAlpha = a;
display.defaultDropAlpha = _dropAlpha;
}
public function get dropAlpha():Number {
return _dropAlpha;
}
public function set splashDropAlpha(n:Number):void {
_splashDropAlpha = n;
display.splashAlpha = _splashDropAlpha;
}
public function get splashDropAlpha():Number {
return _splashDropAlpha;
}
public function set targetColor(c:uint):void {
_targetColor = c;
var colorTargetR:Number = (_targetColor >> 16);
var colorTargetG:Number = (_targetColor >> 8) & 0xFF;
var colorTargetB:Number = _targetColor & 0xFF;
colorFade = new ColorTransform();
colorFade.redMultiplier = Math.pow(colorTargetR/255,0.03);
colorFade.greenMultiplier = Math.pow(colorTargetG/255,0.03);
colorFade.blueMultiplier = Math.pow(colorTargetB/255,0.03);
colorFade.alphaMultiplier = 1;
colorFade.alphaOffset = _fadeAmount;
}
public function set fadeAmount(n:Number):void {
_fadeAmount = n;
colorFade.alphaOffset = _fadeAmount;
}
public function set noSplashes(b:Boolean):void {
this.display.noSplashes = b;
}
public function get noSplashes():Boolean {
return this.display.noSplashes;
}
public function startFlow():void {
flowOn = true;
}
public function stopFlow():void {
flowOn = false;
}
private function onEnter(evt:Event):void {
if (flowOn) {
//add water drops
for (var i:int = 0; i <= dropsToAddEachFrame-1; i++) {
angle = minAngle + Math.random()*(maxAngle - minAngle);
magnitude = minMagnitude + Math.random()*(maxMagnitude - minMagnitude);
var thisDrop = display.addDrop(
leftMargin+waterTopWidth*Math.random(),
topMargin,
magnitude*Math.cos(angle),
-magnitude*Math.sin(angle));
}
}
//update drops
display.update();
bitmapData.colorTransform(bitmapData.rect, colorFade);
bitmapData.applyFilter(bitmapData,bitmapData.rect,origin,blur);
bitmapData.draw(display);
}
}
}
-----------------------------------------------------------------------
"config datei" vom wasserfall
-------------------------------
import com.flashandmath.dg.display.*;
var waterfall:Waterfall;
init();
function init():void {
waterfall = new Waterfall(900,525,true);
waterfall.x = 593;
waterfall.y = 20;
waterfall.z = 250;
addChild(waterfall);
waterfall.startFlow();
}
--------------------------------------------------------------------
hoffe es kann jemand was damit anfangen.
grüße waldmannvonritter