Sure, make it a member variable and set it's target property.

import mx.core.UIObject;
import mx.effects.Dissolve;

var dissolve_effect:Dissolve;

// called from initialize
function onCreationComplete()
{
    dissolve = new Dissolve();
    dissolve.duration = 3 * 1000;
    dissolve.alphaFrom = 100;
    dissolve.alphaTo = 0;
    dissolve.suspendBackgroundProcessing = true;
}

function fadeSomething(o:UIObject):Void
{
    dissolve.target = o;
    dissolve.playEffect();
}

fadeSomething(yourButton);
fadeSomething(yourCow);

----- Original Message ----- 
From: "Karl" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Friday, December 30, 2005 2:11 PM
Subject: [flexcoders] Re: Setting effect via AS


Thanks for the reply. Is there anyway to set an effect on an object 
dynamically without having to create a new effect for each image 
that is added? Won't this method result in a new effect being 
created in memory for each image, as opposed to having one already 
created effect that you "attach" each image to? My effect is a 
sequence too, so it would actually be multiple effects for each 
image.

If I am thinking about this incorrectly, just let me know.

Thanks for your help.
Karl


--- In flexcoders@yahoogroups.com, "JesterXL" <[EMAIL PROTECTED]> wrote:
>
> Pass the image's ID into the effect's contructor:
> 
> var e:Dissolve = new mx.effects.Dissolve(imageID);
> 
> ----- Original Message ----- 
> From: "Karl" <[EMAIL PROTECTED]>
> To: <flexcoders@yahoogroups.com>
> Sent: Friday, December 30, 2005 11:46 AM
> Subject: [flexcoders] Setting effect via AS
> 
> 
> I need to set an effect (hideEffect) on a new object
> (mx.controls.Image) that I am creating via AS and the effect does 
not
> seem to be playing when expected (hiding of image).
> 
> What is the correct way of adding an effect to an object
> programatically? Is it treated like a property and takes a string 
of
> the name of the effect?
> 
> object.hideEffect = "effectName";
> 
> I have not had success with any of the ways I have tried. Thanks in
> advance for your help!
> 
> Karl
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com
> Yahoo! Groups Links
>







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



 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to