# Eval replacement in AS3

**URL:** <https://forum.kirupa.com/t/eval-replacement-in-as3/229673>\
**Category:** flash\
**Created:** [June 19, 2007, 12:55pm UTC](https://forum.kirupa.com/t/eval-replacement-in-as3/229673 "2007-06-19T12:55:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lambros](https://avatars.discourse-cdn.com/v4/letter/l/eb9ed0/32.png) [@lambros](https://forum.kirupa.com/u/lambros)\
**Post date:** [June 19, 2007, 12:55pm UTC](https://forum.kirupa.com/t/eval-replacement-in-as3/229673/1 "2007-06-19T12:55:48Z")

</div>

> var currentPage=“contentHome\_mc”;

contentHome\_mc.gotoAndPlay(“on”);

//Functions  
function animateOn(page:String) {  
eval(page).gotoAndPlay(“on”);  
}

function animateOff(page:String) {  
eval(page).gotoAndPlay(“off”)  
}

function onHomeclick(evt:MouseEvent) {  
if (currentPage != “contentHome\_mc”) {  
animateOff(currentPage);  
animateOn(“contentHome\_mc”);  
currentPage=“contentHome\_mc”;  
}  
}

function onAboutclick(MouseEvent) {  
if (currentPage!= “contentAbout\_mc”) {  
animateOff(currentPage);  
animateOn(“contentAbout\_mc”);  
currentPage=“contentAbout”;  
}  
}

function onProductsclick(MouseEvent) {  
if (currentPage!= “contentProducts\_mc”) {  
animateOff(currentPage);  
animateOn(“contentProducts\_mc”);  
currentPage=“contentProducts”;  
}  
}

//Menu Button actions  
home\_mc.addEventListener(MouseEvent.CLICK, onHomeclick);  
products\_mc.addEventListener(MouseEvent.CLICK, onProductsclick);  
about\_mc.addEventListener(MouseEvent.CLICK, onAboutclick);

hey guys can anyone help me out please ? i am watching the learnflash building a flash site with flash 8 video and i am trying to make the exact things but instead of actionscript 2 with AS3.so far i did great but now that the functions and variables started gettind involved for lots actions it seems that there are many dieferences…

what can i put instead of the “eval” so i can havce the same result as the eval ??? everything else works just that. please tell me how to do it…

if you didn’t understand my problem is how can i make the variable of the function gets a value from the event listeners…and convert the string it gets to a code so to complete the function!
