I just realized my example wasn't 100% conclusive.  So do this instead:

private function buttonClick(e:Event):void {
trace('assigning value');
Result = someFunction('foo');

trace('if statement');
if (Result) {
  trace('bar');
}


Trace I get is:
assigning value
someFunction called
if statement
bar


--- In [email protected], "Jason" <[EMAIL PROTECTED]> wrote:
>
> I wasn't able to reproduce the behavior you're talking about.  Here's
> my code:
> 
> private function someFunction(data:String):Boolean {
>   trace('someFunction called');
>   return true;
> }
> 
> private var Result:Boolean;
> 
> private function buttonClick(e:Event):void {
> Result = someFunction('foo');
> 
> if (Result) {
>   trace('bar');
> }
> 
> 
> The even buttonClick is hooked up to a button click.  Each click of
> the button results in this trace:
> someFunction called
> bar
> 
> So someFunction is just called the one time.  Tracing through it
> didn't do anything weird for me, either.  Can you check and see if
> this code gives you the same problem?
> 
> 
> 
> --- In [email protected], "robbieshere" <robbieshere@> wrote:
> >
> > Hi. I have the following lines in an ActionScript code:
> > 
> > private var Result:Boolean;
> > result = someFunction(data);
> > 
> > if (Result){
> >    etc..
> > }
> > 
> > ..the function "someFunction()" returns a Boolean value. This code 
> > works fine, except when I perform a step trace, I notice that in the 
> > if statement, when it checks the value of Result, jumps to the line: 
> > result=someFunction(data)  ..and goes on to evaluate the function! 
> > Therefore I am wondering if it always evaluates someFunction(data) 
> > everytime I use the Result variable in my code.
> > 
> > If so, is there a way I can just extract the value so that I don't 
> > have to keep running the function? (say the function is a bunch of 
> > nested for-statements...that would take a lot of time to compute!)
> > 
> > Thanks for the help.
> > Rob Graham
> >
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Home is just a click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/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