Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Strange happenings using filters

New Here ,
Aug 10, 2013 Aug 10, 2013

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

TOPICS
ActionScript
692
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2013 Aug 10, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2013 Aug 11, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2013 Aug 11, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 11, 2013 Aug 11, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines