I always found the effects behavior of Flex 2.0 Alpha 1 weird. I never had the feeling that it really worked like I wanted it to. It never appeared to be “reliable” in terms of that it did what I expected right away. Not to blame Macromedia for this, it might all be my fault but anyway… effects always have been difficult for me. I ran into timing issues and whenever I was sure that “this time I have assigned the effect to the right event” just to find out it does not work as intended.

 

I have created the following example for you. It’s not making use of a MXML Component but you might get the idea. Obviously you don’t need to call the ChangeText() method via Button controls. You can also do it programmatically. It should not be too difficult to wrap the behavior designed here into a self-contained component. Does that help? (Would be nice if you post the component once you’ve finished it.)

 

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

<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns:local="*" backgroundColor="#ffffff">

      <mx:Script>

            <![CDATA[

                  import flash.util.*;

                 

                  [Bindable]

                  public var theText:String = "My default text is boring.";

                  private var _t:String;

                 

                  private function ChangeProceed():Void

                  {

                        theText = _t;

                        lblDummy.visible = true;

                  }

                 

                  private function ChangeText(_s:String):Void

                  {

                        _t = _s;

                        lblDummy.visible = false;

                        setTimeout(ChangeProceed, 1700);

                  }

            ]]>

      </mx:Script>

 

      <mx:Label id="lblDummy" text="{theText}" showEffect="appearer" hideEffect="dissolver" />

      <mx:Button label="Text Change 1" click="ChangeText('This is impressive!')" />

      <mx:Button label="Text Change 2" click="ChangeText('This is even more impressive!')"  />

 

      <mx:Effect>

            <mx:Dissolve name="dissolver" alphaFrom= "1.0" alphaTo= "0" duration= "1000"/>

            <mx:Dissolve name="appearer"  alphaFrom= "0" alphaTo= "1.0" duration= "1000"/>

      </mx:Effect>

</mx:Application>

 

 

Ralf Rottmann | Director Sales & Marketing | VoicInt Telecommunications GmbH
m:+49-(0)170-914-5495 | f: +49-(0)231-557402-99 | e:
[EMAIL PROTECTED]
-------------------------------------------------------------------------------------------------------


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Ben Lucyk
Sent: Samstag, 10. Dezember 2005 00:22
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problem Adding Effects to Wrapped Label Control (Flex 1.5)

 

Hello,

 

I'm trying to have a bunch of dynamically updating Labels (think internationalization) all show a Fade effect when their "text" binding source is updated.  Since there is no default "change" event for the control, I've tried going down the path of wrapping the Label and implementing some of the code in my new control.  Doesn't work.  The code below does not fade the label when the button is clicked.  

 

Is it maybe possible to attach a default Fade Effect to my control's "show" Event via Action Script, and just toggle its visibility?

 

 

La code:

 

****************  MXML   ***************

 

<com:FancyLabel xmlns:com="com.*" text="{tempString}" id="lblFancyText"  />

 <mx:Button label="Change Text"
  click="tempString == 'bloo'? tempString='blah' : tempString='bloo';"  />

 

 

****************  Extended Label ***************

 

import mx.effects.*;
import mx.controls.*;

class com.FancyLabel extends mx.controls.Label {

    // Constructor
    public function FancyLabel() {
  
    }
 
   public function showLabel():Void {
      var textFade:Fade = new Fade(this);
      textFade.duration = 2000;
      textFade.alphaFrom = 0;
      textFade.alphaTo = 100;
      textFade.playEffect();
   }
 
     public function set text(val:String):Void {
        super.text = val;
        show Label();
    }
 
}

*************************************** 

Thanks in advance,
- Ben Lucyk



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to