Home Tutorial Flex Flex4 Components Apply MX Effect using setStyle() method in Flex4

 
 

Apply MX Effect using setStyle() method in Flex4
Posted on: July 1, 2010 at 12:00 AM
In this example you can see how we can apply the effect using setStyle() method.

Apply Effect using setStyle() method in Flex4:

In this example you can see how we can apply the effect using setStyle() method. in this example we use a rollOverEffect and rollOutEffect by using setStyle() method. The syntax of setStyle() method is componentstance.setStyle()

Example:

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx"

minWidth="955" minHeight="600"

creationComplete="applyTrigger(event);">

<fx:Declarations>

<mx:Blur id="imageBlurON"

blurXFrom="0.0"

blurXTo="20.0"

blurYFrom="0.0"

blurYTo="20.0"

duration="500"/>

<mx:Blur id="imageBlurOFF"

blurXFrom="20.0"

blurXTo="0.0"

blurYFrom="20.0"

blurYTo="0.0"

duration="500"/>

</fx:Declarations>

<fx:Script>

<![CDATA[

public function applyTrigger(event:Event):void{

// Apply Effect using setStyle() method

roseindia.setStyle('rollOverEffect', imageBlurON);

roseindia.setStyle('rollOutEffect', imageBlurOFF);

}

]]>

</fx:Script>

<s:Panel title="Apply MX Effect using setStyle() method"

width="423" height="268"

chromeColor="#000000" color="#CCCCCC">

<mx:ApplicationControlBar width="422" horizontalAlign="center">

<s:Label text="Take a coursor on image and show the effect."

fontFamily="verdana" color="#000000"/>

</mx:ApplicationControlBar>

<mx:Image id="roseindia" cacheAsBitmap="true"

source="@Embed(source='file:/C:/work/bikrant/image/orbit.png')"

x="146" y="64"/>

</s:Panel>

</s:Application>

Output:

Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code

Related Tags for Apply MX Effect using setStyle() method in Flex4:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.