Copy link to clipboard
Copied
Hi I am trying to return a drop shadow filter on a property of an object by calling a function in another class called, "FilterClass." I have several properties I am trying to add filters to, or not add drop shadow filters to, depending on the Boolean perameter that tells the function in the FilterClass whether or not to add the filter to it. The problem is it is either making all the properties have the dropshadow filter or all of them not have it, regardless of whether the boolean value in the perameter is true or false. Here is the code from the filter class function:
public function dropShadowFilter(dropShad:Boolean):Object{
var _filterObject:Object = new Object();
if(dropShad){
_myShadow.distance = 10;
_myShadow.color = 0x000000;
_myShadow.blurX = 10;
_myShadow.blurY = 10;
_myShadow.quality = 3;
_filterObject.myShadow = _myShadow;
_filterObject.myShadow.alpha = 1;
}else{
_filterObject.myShadow = _myShadow;
_filterObject.myShadow.alpha = 0;
}
trace("_filterObject.myShadow.distance = "+_filterObject.myShadow.distance,dropShad);
return _filterObject.myShadow;
}
and the function that calls the dropShadowFilter function above is the following:
private function dropShadowFilter():void{
_filterObject.myControlsShadow = filterClass.dropShadowFilter(false);
trace("_filterObject.myControlsShadow.alpha = "+_filterObject.myControlsShadow.alpha);
_filterObject.myBackShadow = filterClass.dropShadowFilter(true);
trace("_filterObject.myControlsShadow.alpha = "+_filterObject.myControlsShadow.alpha);
trace("_filterObject.myBackShadow.alpha = "+_filterObject.myBackShadow.alpha);
_filterObject.myAddMoneyShadow = filterClass.dropShadowFilter(true);
_filterObject.myMusicShadow = filterClass.dropShadowFilter(true);
_filterObject.mySoundShadow = filterClass.dropShadowFilter(true);
_filterObject.myWhichLanguageShadow = filterClass.dropShadowFilter(true);
}
the trace statements show what is happening but I can't figure out why unless it's something to do with the filters I don't know about:
currentSystemState=14
_filterObject.myShadow.distance = 0 false
_filterObject.myControlsShadow.alpha = 0
_filterObject.myShadow.distance = 10 true
_filterObject.myControlsShadow.alpha = 1------>this property changes to 1 when I haven't programmed it to do so
_filterObject.myBackShadow.alpha = 1
if anyone knows why this is happening please let me know, thanks
Copy link to clipboard
Copied
it looks like you have one filter. you use multiple objects that appear to serve no purpose except make you think you have more than one filter.
why don't you create a new dropshadowfilter with each instance of your class, if that's what you want. though, even that looks pointless.
what's the purpose of your dropshadowfilter class? it doesn't appear to encapsulate anything.
Copy link to clipboard
Copied
I made the dropshadow class so I wouldn't have to add all the filter info to each property of the _fliterObject object by hand for each one. It's a menu screen and I want the option of being able to tell it if each word in the menu screen uses a filter or not. I'm thinking maybe I can add a number to each _filterObject.myShadow; that is being returned then they wouldn't all be the same object. Do you think that would work?
Copy link to clipboard
Copied
ok I changed the dropshadow funciton to this:
public function dropShadowFilter(dropShad:Object, addShadow:Boolean):Object{
var _myShadow:DropShadowFilter = new DropShadowFilter();
//var _filterObject:Object = new Object();
if(addShadow){
_myShadow.distance = 10;
_myShadow.color = 0x000000;
_myShadow.blurX = 10;
_myShadow.blurY = 10;
_myShadow.quality = 3;
dropShad = _myShadow;
dropShad.alpha = 1;
}else{
dropShad = _myShadow;
dropShad.alpha = 0;
}
trace("dropShad = "+dropShad);
return dropShad;
}
and the dropShad variable is each object I want to have the filter applied to, and it seems to work. Thanks
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now