2 Replies Latest reply on Sep 30, 2010 3:51 AM by ariv.l

    why dynamic image control's setStyle property not working properly? help me... plz

    ariv.l

      I created an image control dynamically in actionscript and i set style property to it as

      img.setStyle("rollOverEffect",glowImage); img.setStyle("rollOutEffect",unglowImage);

      Now my problem is "rollOutEffect" is not working....

      help me and thanks in advancd...

        • 1. Re: why dynamic image control's setStyle property not working properly? help me... plz
          BhaskerChari Level 4

          Hi ariv,

           

          I have created a sample and tested it ...but I find no problem as you said..See the sample code below...

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
          <mx:Script>
            <![CDATA[
             import mx.controls.Image;
            
             private function onCreationComplete():void
             {
              var img: mx.controls.Image = new  mx.controls.Image();
              img.source = "img1.jpg";
              this.addChild(img);
              img.setStyle("rollOverEffect", glowImage);
              img.setStyle("rollOutEffect", unglowImage);  
             
             }
            ]]>
          </mx:Script>
              <mx:Glow id="glowImage" duration="1000"
                  alphaFrom="1.0" alphaTo="0.3"
                  blurXFrom="0.0" blurXTo="50.0"
                  blurYFrom="0.0" blurYTo="50.0"
                  color="0x00FF00"/>
              <mx:Glow id="unglowImage" duration="1000"
                  alphaFrom="0.3" alphaTo="1.0"
                  blurXFrom="50.0" blurXTo="0.0"
                  blurYFrom="50.0" blurYTo="0.0"
                  color="0x0000FF"/>

             
          </mx:Application>

           

           

          If you are facing the problem with the above code you can try out another code below..

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
          <mx:Script>
            <![CDATA[
             
             private function onCreationComplete():void
             {
              var img: mx.controls.Image = new  mx.controls.Image();
              img.source = "img1.jpg";
              this.addChild(img);
             
              glowImage.target = img;
              unglowImage.target = img;
              img.addEventListener(MouseEvent.ROLL_OVER, onImageRollOver);
              img.addEventListener(MouseEvent.ROLL_OUT, onImageRollOut);
             }
             private function onImageRollOver(event:MouseEvent):void
             {
              glowImage.play();
             }
             private function onImageRollOut(event:MouseEvent):void
             {
              unglowImage.play();
             }
            ]]>
          </mx:Script>
              <mx:Glow id="glowImage" duration="1000"
                  alphaFrom="1.0" alphaTo="0.3"
                  blurXFrom="0.0" blurXTo="50.0"
                  blurYFrom="0.0" blurYTo="50.0"
                  color="0x00FF00"/>
              <mx:Glow id="unglowImage" duration="1000"
                  alphaFrom="0.3" alphaTo="1.0"
                  blurXFrom="50.0" blurXTo="0.0"
                  blurYFrom="50.0" blurYTo="0.0"
                  color="0x0000FF"/>
           

             
          </mx:Application>

           

          Thanks,

          Bhasker

          • 2. Re: why dynamic image control's setStyle property not working properly? help me... plz
            ariv.l Level 1

            Hi BhaskerChari,

             

                 Nice work, Thanks for your response. It helps me to continue my taks...