Apply Filter with ActionScript : DropShadowFilter « Effects « Flex






Apply Filter with ActionScript

Apply Filter with ActionScript
           


<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



<!-- styles/ApplyFilterAS.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script> 
        import spark.filters.*; 
        private var dsf:DropShadowFilter; 
        public function toggleFilter():void { 
            trace(label1.filters.length); 
            if (label1.filters.length == 0) { 
                /* 
                The first four properties of the DropShadowFilter constructor are 
                distance, angle, color, and alpha. 
                */ 
                dsf = new DropShadowFilter(5,30,0x000000,.8); 
                label1.filters = [dsf]; 
            } else { 
                label1.filters = null; 
            } 
        } 
      </fx:Script>
    <s:VGroup>
        <s:Label id="label1" text="ActionScript-applied filter." />
        <s:Button id="b1" label="Toggle Filter" click="toggleFilter()" />
    </s:VGroup>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Apply DropShadowFilter to controlApply DropShadowFilter to control
2.Use ActionScript to apply DropShadowFilter to Label's filterUse ActionScript to apply DropShadowFilter to Label's filter
3.Apply a white shadow to the Label controlApply a white shadow to the Label control
4.DropShadowFilter for filtersDropShadowFilter for filters
5.Graphics DropShadowFilter