Jeff,

In my experience, you can do this, but when you invoke the method, it does
not invoke within the memory space of the original component. It invokes the
method as if it were a free-standing method. Therefore, it does not have
access to THIS and VARIABLES scopes of the CFC.

This is what I have found when testing, but I may be wrong.

-ben 

.......................
Ben Nadel 
www.bennadel.com
Certified Advanced ColdFusion Developer

Need Help?
www.bennadel.com/ask-ben/


-----Original Message-----
From: Jeff Anderson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 14, 2006 1:58 PM
To: CF-Talk
Subject: Re: Dynamically calling methods in a CFC

Andy,

Try using this:

<cfset a = APPLICATION.imgObj[scaleMethod]/>

Then:

<cfset a(yourArgs) />

If you notice the methods live in the this and variables scopes in the CFC
along with any other variables. Becuase of that, you can treat the method as
a key in the scope struct and create a reference copy to the "a" variable.

HTH,

Jeff

>I'm using Rick Root's image.cfc which contains scaleX and scaleY methods.
>
>Right now I'm doing an if statement with two lines for the call to the CFC.
>
><cfif scaleMethod IS "scaleX">
>     <cfset a = APPLICATION.imgObj.scaleX()> <cfelse>
>     <cfset a = APPLICATION.imgObj.scaleY()> </cfif>
>
>But I'd like to condense it to this:
><cfset a = APPLICATION.imgObj[scaleMethod]()>
>
>But that method errors. I've tried these as well:
>
><cfset a = APPLICATION.imgObj["#scaleMethod#"]()>
><cfset a = APPLICATION.imgObj."#scaleMethod#"()>
><cfset a = APPLICATION.imgObj.#scaleMethod#()>
>
>But they also failed. I know it's got to be possible, but I'm not sure 
>how to do it...anyone?
>
><!----------------//------
>andy matthews
>web developer
>certified advanced coldfusion programmer ICGLink, Inc.
>[EMAIL PROTECTED]
>615.370.1530 x737
>--------------//--------->



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:253155
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to