Skip to main content
Inspiring
April 20, 2007
Question

swapping values of two vars

  • April 20, 2007
  • 10 replies
  • 459 views
is it possbile to simutaneously swap two values of vars
ex:
var me:Number=1;
var you:Number=0;
_root.me.swap[you]
trace('me: '+me+'\n'+'you: +you);
/*result:
me: 0
you: 1
*/
Is this possible... im guessing its just this easy.
This topic has been closed for replies.

10 replies

_Vee_Author
Inspiring
April 20, 2007
Its almost Happy Hour.
kglad
Community Expert
Community Expert
April 20, 2007
i can't think of a more useless piece of information (related to flash) than swapping variable values without creating a third variable. i don't even think this would have been useful in the days when ram was limited to 64k.
_Vee_Author
Inspiring
April 20, 2007
it is funny. given the discussion in the other thread, im wondering if it is!
Inspiring
April 20, 2007
lol. Case of mistaken identity. Good to hear it has some practical application!
_Vee_Author
Inspiring
April 20, 2007
Thats great. I thought this would be something that everyone uses and I just hadnt got around to implementing it. And for the record I wasn't going out for that job, I am using it for a slideshow that use two mc with a back and forward button. Given the order of events the user either keeps the existing holder and loads a new image into it or switches to the other holder to load into.
thanks for your help again, see you around.

Hope he got his job =)
Inspiring
April 20, 2007
I don't think it was a negative comment, well at least not one directed at you anyway.

It was (as I interpreted it) a comment directed at the type of company that would require you to know something like this in an interview in order to be considered as a potential candidate. Its almost an academic style challenge, without (in my opinion) a lot of practical benefit.

That said, I (and a couple of others) enjoyed the distraction it offered when someone else asked recently. I think this link should take you there.

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid=1260959&enterthread=y
Inspiring
April 20, 2007
Discussed yesterday. Search the forum.


Inspiring
April 20, 2007
rotfl. The interview must not have went well :)


_Vee_Author
Inspiring
April 20, 2007
//
kglad
Community Expert
Community Expert
April 20, 2007
are you all being interviewd by the same yokel for the same job?