Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Question Regarding The Eval Function



I'm working on a Flash document that will let my coworkers create Flash navigation without all the dirty mess. It will dynamically create it's various levels of navigation, etc, by evaluating the length of the arrays that contain the link data.

Anyway, I am having some problems with the eval function, which allows you to use variables when calling objects.

The code!




Code:
var toplevel_orient:Boolean = true;
//True = Horizontal, False = Vertical
//Attaching nav movie clips and setting to invisible. This is for evaluating the properties of the movieclip
//to be used later when dynamically laying the nav out.
this.attachMovie("mc_toplevel", "mc_toplevel_eval", this.getNextHighestDepth(), {_visible:false});
var toplevel:Array = Array();
toplevel[0] = "Sup";
toplevel[1] = "Hooooola";
toplevel[2] = "Blarg";
for (i=0; i<=toplevel.length; i++) {
var xvalue:Number = mc_toplevel_eval._width*i;
var yvalue:Number = mc_toplevel_eval._height*i;
//trace(xvalue);
this.attachMovie("mc_toplevel", "mc_toplevel_"+i, this.getNextHighestDepth());
if (toplevel_orient) {
eval("mc_toplevel_"+i)._x = xvalue;
} else {
eval("mc_toplevel_"+i)._y = yvalue;
}
eval("mc_toplevel_"+i).createTextField("toplevel_text_"+i, this.getNextHighestDepth(), 0, 0, mc_toplevel_eval._width, mc_toplevel_eval._height);
mc_toplevel_0.toplevel_text_0.text = "hello";
eval("mc_toplevel_"+i).eval("toplevel_text_"+i).text = "test";
trace(eval("mc_toplevel_"+i).eval("toplevel_text_"+i).text);
}


As you can see near the bottom, when I try to use multiple eval functions to reference different layers of movie clips on the same line, the code breaks, somehow, and doesn't ever actually target what it's supposed to (as far as I can tell it targets nothing). I know that the TextFields are being created properly, because as a debug, I have hard coded "hello" into the first one.

Is there a better way to do this? Eval seems primative, but is exactly the type of function I need to pull off what I am attempting to do.

Thanks.



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-31-2007, 02:42 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Pls Help ..... Eval Function
var are loaded frm a txt file ....i want to concatenate 2 var into 1

eval("both") = fname add " " add lname; not working with dynamically loaded variables

kaustubh

Eval Function
Hi,
how can I access loaded variables from LoadVars object if I need dynamicaly generate variable names with eval function. i.e. :

text = myLoadVars.eval("smth" add "smth");

doesn't work. Maybe it's another way how to resolve this problem? Or I'm using bad expression or smth?

Eval Function
Hi,

I have somehow manage to decompile some of the swf files online to have some reference on how they code their flash actionscripts.

However, I have encountered a flash that have most of the code that looks like
if (eval("x01") == 10) ? What does it mean? Is it encrypted or something? Please advise

Eval Function With Arrays
Hi, does anyone know the correct actionscript if i want to reference an array with a dynamic name using eval/[]? At present i have this code but it doesnt seem to work.

this["qinst"+m+[i]]

for example for m = 2 and i = 1 i want to reference the following array element: qinst2[1]

Many thanks
JOhn

The Speed Of Eval() Function
I need to get your thoughts on the speed of the actionscript eval() function. From all my readings there usually is little mention of the eval() function and I swear that once or twice i heard that it never the best thing to use, Ive always considered it a special case function when all other options fail, and i hear its slow as well (lots of overhead).

I have a huge piece of code i have to debug (the CPU runs at 100%, bogging down any system it runs on). It is mostly procedural code with functions (about 3200+ lines of code). There is heavy use of the eval() function. I think this may be a key piece as to why the application it taking up so much CPU power.

What are your thoughts on the eval() function?

Can You Call A Function Using Eval()?
I know that eval is taboo. That aside, is it possible to call a function using eval? The following simple code (on the first and only frame of my movie) didn't work:

==
function myFunction(){

trace('Called!');

}

function useEval(){
eval('myFunction()');
//myFunction();
}

useEval();

==

Please let me know if you have any suggestions. Thanks!

Is There Workaroud To Eval() Function?
Flash animation consist of al lot of objects in library with exported names
obj1, obj2, ... objN. Depending on user action some of this items may be
created. Because there is necessity to create a couple of successive objects
at once my intention is to do it in loop like this:

for (i=50; i<100; i++)
addChild(new ("obj"+i));

Of course it will not working under AS3. Is any way to avoid using following
construction:

for (i=50; i<100; i++)
{
switch(i)
{
case 1: obj=new obj1(); break;
case 2: obj=new obj2(); break;
...
case N: obj=new objN(); break;
}
addChild(obj);
}

Eval Function And Arrays
Hi,

I'm trying to build and populate an Array using string based expressions, so I thought I could use eval(). The problem is that the result is always "undefined".

Here it is some code that I've writtten to test this:

var Answer:Array = new Array();
Answer[0] = "Answer 1";

var i:Number = 0;

trace(eval("i")); //Shows 0
trace(eval("Answer["+i+"]"));//Shows undefined

Can you tell me what am I doing wrong?

Thanks in advance,
RCMS

Eval To Invoke A Function
Hello,

I have some functions named like sixtoone() sixtotwo() sixtothree() etc..

I am returning a value from those functions like this;


ActionScript Code:
this.cur = "six" // if this is onetosix() function for example
    return(this.cur)


so what I am doing next is to add this value to invoke the other function on a button action like this;


ActionScript Code:
planning.onRelease = function() {
    gimme = cur+"toone()"
    trace(gimme) // this gives me sixtoone() but it don't invoke the funtion.
   
};
 
so you have already guess, how should I use eval to get this function invoke..
 
thanks in advance.
 
ik

Eval Function Problem
here's the problem - this line works


PHP Code:





eval("poziom"+biezacyPoziom).linia1 = "info 1"; 







but this one

PHP Code:





eval("poziom"+biezacyPoziom).eval("linia"+1) = "info 1"; 







doesn't (i get "Left side of assignment operator must be variable or property." error). how to make the second line work?? (i need to replace 1 with a variable "i". eg. if i=4, then i need to set poziom1.linia4 to "info 4".

Eval-function Not Working Correct?
Hi,
I use the eval function because I want to evaluate some external expressions (parsed XML) with arrays in Flash.

For simplifying I use the following example code:

Name = new Array("A", "B");

Name2 = eval("Name[0]");
Name3 = eval("Name");
Name4 = eval("Name")[0];


Name2 returns an undefined value
Name3 returns A,B
Name4 returns A

Why is Name2 undefined?
I can't use the code for Name4 because the "[0]" is part of my external string expression and here it would be outside the string.
I would really appreciate any help!

Quick Question About Eval Function.
Ok I have flash talk to my PHP and the flash movie does recieve the information perfectly, because I had a text box with a specific variable attached to it, where it would display the data it just recieved from the PHP script. So far there are 4 sets of information that gets loaded to flash.

username1, 2, 3, 4

numr = (sets of info)

Right?

Ok, now this is what I tried to do....

I had a textbox with a variable 'infob' and I used this code.

loadVariablesNum ("script.php",0);
for (a=0; a<numr; a++){
infoa = "username"+a;
infob = eval(infoa);
}


Now when I used this, nothing happened.... I then took out the for statement and wanted to see if the eval functioned worked on it's own.

infoa = "username"+1;
infob = eval(infoa);

Still nothing... Now I copied the two lines onto a second frame without a stop message, then after awhile it would actually update the textbox that had the variable infob.

Now I wondered to myself thinking that maybe it's taking time to update the info from PHP, so I left a textbox with a direct variable 'username1' to display if it's been updated or not. Well to my surprise, the textbox displayed the username and it still took a couple more seconds for the eval function to pull through.....

What am I doing wrong? Is there a simpler way to get this to work?

-Anthony

Do I Use Eval To Pass These Variables Into A Function?
I'm getting the impression that actionscript isn't exactly like JavaScript.

When I do the following below, it doesn't work. Do I need to use an eval() statement?


console.b_r1_1.onRollOut = function(){
removeBox("r1_1");
}

function removeBox(box){
"_root.console.attachBox_" + box + ".removeMovieClip()";
}

Many thanks in advance!!!![color=red]

[F8] Equivalent Of Javascript Eval Function
Hey All,

Have they added an equivalent to the javascript eval() function to actionscript yet? I know the actionscript eval() doesn't do the same thing, for instance you if you have eval(someString); that string with not be evaluated as action script and executed. This is what I need. Thanks.

Faster Code (eval Function)
Hi, I'm checking out a code that make some calls to "eval" function, known to be slow. Is it worhty checking out this entire code, changing eval for something else like:

change

Code:
eval("_root.images." + imageNameVar + "._x")
to

Code:
_root.images[imageNameVar]._x
How much this second choice will make the code faster? (assuming t will...)

Passing MC In Function Paramter? EVAL?
hi guys,i got this movieclip called mfInfoPop and in it i have dynamic textfields html enabled called info1 - info5.

I have it set up as a hyperlink with an asfunction and what i'm doing since asfunction only accepts 2 parameters, is i'm passing in the function name and 4 paramters.

I take those 4 parameters, and i array split them. One of the parameters i'm passing is the name of the textfield that was clicked on. so basically, in the function variables[0] (after the split) includes info5. I want to be able to change the text in the function

however, eval("mfInfoPop." + variables[0]).htmlText = "blahblah";

doesn't work and neither does

this["mfinfoPop." + variables[0]].htmlText = "blah blah."

i did a trace on the object and the result was _level0.mfInfoPop.info5

anyone know how i can pass the info5 textfield, and change the text of it in the asfunction??


Thank you for any clues, tips, or answers.

Flash Eval And Callback Function
Hello friends,
I'm quite new in flash and I'm finding it very stressful to write as codes.
I've written a flash interface class for loading movies, but I'm stuck with callback and eval functions, so If anyone can help me, I'd be much appreciated.

Basically, I'm calling a class member function like this:

this.call({
name : "window",
pos : [x,y,w,h],
target : _root.frame,
onComplete: function(p1,p2){
trace('hello' + p1);
}
});

............... somewhere in timeline when movie loaded........

mcl.onLoadComplete=function(mc){
eval (caller.onComplete)
}

I just want to ask if I can evaluate the onComplete function in that way?
Thank you in advance for any comments,
Alex

PHP Like Eval Function In AS3? (String Calculation)
Hi,

I have a string with a calculation let's say "(5+5)*10", is there a way to calculate this?

In PHP you have an eval function, but is there something similar in AS3 (or a workaround)?

I wouldn't like it if I have to call a php file with the eval function in. Because that would mean I have to call that file a 1000x times...

Dynamic Function Call With Eval Not Working
Ok flash masters. Here is another question for you. I am trying to make function calls by using the eval() method.

how do I get that to work?
I have tried
var x = 'fncName';

eval(fncName());

Can this be done and if so how?

Using Eval To Declare A Function On A Movieclip Event
make sence? anyways heres the code:

code: function getMenu(){
delete _root.menuModule;
_root.createEmptyMovieClip("menuModule", 2);

menuModule._x = 0;
menuModule._y = 0;

baseNode = menuXML;
//trace(baseNode);
var menuItems = Array();

for (var x=0; x < baseNode.childNodes.length; x++) {
thisNode = baseNode.childNodes[x];
var children = Array();

for (var z=0; z < thisNode.childNodes.length; z++) {
newNode = thisNode.childNodes[z];
children[z] = Array(newNode.attributes['Text'], newNode.attributes['URL']);
//trace(children[z]);
}

menuItems[x] = Array(thisNode.attributes['Text'], thisNode.attributes['URL'], children);
//trace(menuItems[x]);
}

//populate main menu

for (var y=0; y < menuItems.length; y++){
if(y==0){
x=0;
}else{
z = y -1
x = eval("menuItem" + z + "._x");
x = eval("menuItem" + z + "._width");
//trace(x);
}
_root.createTextField("menuItem" + y, _root.getNextHighestDepth(), x, 0, 105, 18);
this["menuItem" + y].text = menuItems[y][0];
this["menuItem" + y].selectable = false;
this["menuItem" + y].border = true;
this["menuItem" + y].autoSize = "left";

this["menuItem" + y].onRollOver = getSubMenu(y);
}
//trace(menuItems[2]);

}

function getSubMenu(y){
trace("gogo");
}

The problem is in the last loop,

code: this["menuItem" + y].onRollOver = getSubMenu(y);
}
//trace(menuItems[2]);

}

function getSubMenu(y){
trace("gogo");
}
Now what happens is when the script is run, it traces "gogo" twice. (twice because thats how many menuItems there are). They are loaded from a database using php / mysql. Anyways the swf is www.pro-ladder.com/index.swf if you are interested. Im trying to create every element dynamic so joeUser can make his own site. Why does onRollOver run while its going through the loop, but not actually when the mouse "rolls over"?

Eval And How To Store A Function In A Array And Call It
I have a dynamic button navigation (its working fine) but i want to control what the link will do dynamically

some links (buttons) will open goto a frame and open a textfile, other buttons may just open a SWF file.

I am thinking i can store these in an array

example:

ActionScript Code:
sublinks_arr[0] = Array('gotoAndStop("homeframe");');
loadMovie("special.swf", myMC_loader);
_root.textfile="portfolio";
gotoAndStop("textloader");');
.
.
.
switch.....case 0:
eval(sublinks_arr[0]);

Basically I just need to know if its valid to do that, note that the 3rd option calls 2 functions.

Convert String To Function? (Emulate Javascript Eval)
(MX question)

I'm trying to create a mathematical function from a string input by user at run-time. E.g., if user enters "2*x - 1/x", I would like to
set up the function

Code:
function f(x) {
return 2*x - 1/x ;
}


I'm stumped on this. Considered writing to a text file, then reading that in, but can I define a function this way at run-time?

Any suggestions would be appreciated.

Can't Call Flash Function From Javascript Using ExternalInterface And Eval()
I have created a flash movie that loads external swfs as requested via javscript through ExternalInterface. I would like to be able to call functions on the loaded movie clip. So I am passing the statement I'd like to execute from javascript to Flash and am trying to use an eval statement in Flash to execute it, but it doesn't appear to be doing anything. I'm certain that the Flash function is being called, but the eval doesn't appear to work. Here's the code:

import flash.external.ExternalInterface;
ExternalInterface.addCallback("executeExternalJava script", this, executeExternalJavascript);


function executeFlashActionScript(strActionScript){
eval(strActionScript); //this didn't work
//_root.reportToJavascript_LoadProgress('executeFlas hActionScript called'); - that worked!
}

==

From javascript, I've tried passing calls in several ways and none of them seem to do anything. I've tried referring to the external movie clip loaded into a level directly like this:

executeFlashActionScript('_level1.stopSong()')

It doesn't work (although if I execute the _level1.stopSong() method from a function in the flash movie it works. It just doesn't work in the eval statement. I've also tried referring to global functions as _global. and _root, but that hasn't worked either.

Let me know if you have any ideas!

Using Eval Function And Variable In A Path (target Path)
Hello,

I have to reprogram some of my website and it calls to conjugate strings in a way that's beyond my understanding. Please help me with some suggestions. Kind regards.

the original code is:

code:
if (_global.useCount<10) {
//hide
var diff = 10-_global.useCount;
for (diff; diff>0; diff--) {
eval(String(11-diff))._visible = false;
}
}

There are buttons named 1 to 10 and this turns off the ones that are not used. Now I want to nest those buttons in subclip "buttonsRow", instead of having them on main timeline. How do I rewrite that code to make it work with new path?

I have already tried the "associative array" method, but it don't really know how to pack the whole eval function in there. I've tried many combinations, like:

code:
this.buttonRow[eval(String(11-diff))]_visible = false;
//or
this.buttonRow["eval(String(11-diff))"]_visible = false;
//or
buttonRow[eval(String(11-diff))]._visible = false;
//or
buttonRow["eval(String(11-diff))"]._visible = false;
//or
buttonRow[eval(11-diff)]._visible = false;
// or
buttonRow[8]._visible = false;
//the last one at least turns off button 8, lol

Some of those return syntax error and some just don't work. Anyone have any ideas? Thank you again.

Can't Call Function Created Via Eval Using ExternalInterface.call
I have created a flash movie that acts as an MP3 player. Using ExternalInterface, I pass an array containing cue points in the song to the flash move so that it makes a callback to javascript when it hits certain points in the song. Since I want to deal with these callbacks differently for each song, I have made it so that I can dyanmically change the function that is called from Flash (to Javascript). Here is the code for that piece:

ExternalInterface.addCallback("setCuePointFunction ToCall", this, setCuePointFunctionToCall);

var cuePointFunctionToCall:String='';
var intCurrentCuePoint:Number=0;

function setCuePointFunctionToCall(strFunctionName){
_root.cuePointFunctionToCall=strFunctionName;
}

function reportToJavascript_CuePoint(intCuePointID:Number){
ExternalInterface.call(_root.cuePointFunctionToCal l, intCuePointID);
_root.intCurrentCuePoint++;
}

This works perfectly as long as the function that cuePointFunctionToCall refers to is defined in a script block on the HTML page. However, this project is an AJAX-style thing, and I need to be able to define the function that is triggered on a cue point in code that is dynamically executed at run-time via an "eval' call.

Here's the code that talks to actionscript. This appears in a script block on the main page (not via eval).

function setCuePointFunctionToCall(strFunctionName) {
thisMovie("PushPuppets_Media_Center").setCuePointF unctionToCall(strFunctionName);
//alert(strURL);
}

function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

Here's the code that is dyamically being executed via an eval statement in javascript:

setCuePointFunctionToCall("cuePointNew");

function cuePointNew(lngCuePointID) {
alert('New function, cue point: ' + lngCuePointID);
}

This does not work. But if I copy the above function block to the main page (not in the code that is executed via an eval) it does work. I am certain that setCuePointFunctionToCall is being executed properly via the eval - it is definitely changing the function that actionscript will call. This is apparent since it is calling the right function when the function is declared on the HTML page (not in the AJAX-style eval call). So I'm guessing that this has something to do with the scope in which eval operates.

I encountered a very similar problem when I tried redefining a function in the eval call that was already defined on the main page. It just didn't take.

Please let me know if you have any suggestions.

Thanks,

Erich

A Function Like "eval" In JavaScript?
The documentation says, that i cannot use the eval-function is Actionscript like the eval-function in JavaScript. Does anyone know what i can use instead? IŽd like to evaluate some strings as a statement.

Thanx

Henning

Using "eval" To Call A Function - Help
Hey all. Ok, I'm working on a knob control, and I'm making it as configurable as possible. I'll be sure to post it to FK as soon as I get it 100% done.

Here's the situation: When you click and drag the mouse, the knob rotates and sets it's rotation angle as well as the scaled output value. Since the knob can be used for almost anything from color values, volume, pan, scroll, etc, I wanted to add a variable that would hold the name of the function to which the knob sends it's current output value.

So what I was trynig to to was something like this:

************************************
begin code example
************************************

var updateFunction = '_root.setVol';

function getVal(){
... code for setting the scaled output value from the knob rotation ...
}

... code goes here for the knob...

// time to broadcast the value of the
// knob to it's handler function
eval(updateFunction + '(' + getVal() + ')');

************************************
end code example
************************************

what the eval code *should* do is evaluate the string to be a function call with the knob value. For instance, if the knob output value was 10, then the eval would result in:

_root.setVol(10);

However, this just istn' working. Has anybody had any experience/success with calling functions this way?

Before you post about just updating the code in the movie clip, remember that I'm trying to make this a configurable component, so you want it as hands off as possible where you set variables with an API instead of editing each clip.

Anyway, hopw I get an answer.... anybody out there?

Eval() "function Help"
Hi folks, I have a movie on flashkit here that is a database driven combo box. I use the eval(); function in several places, yet MX doesn't like the coding.
I haven't taken the MX leap, but if anyone can look at it and tell me why the eval function won't work in MX or if they can propose a work around, I would be much greatful. I would be pleased to repost an updated menu with a co-author.
Cheers.

The file can be found here at flashkit at:
http://www.flashkit.com/movies/Scrip...6957/index.php
Mark

"eval" Function
Ok I made this post a lot simpler

ActionScript Code:
listItem_text = eval("currentListItem_text"+i);
     listItem_info = eval("currentListItem_info"+i)
I'm trying to evaluate an expression on the right, but I want the receiving variable on the left to keep the value of [i] and append the value of that to the end of the variable (so that it would be passed on as listItem_text1 or listItem_text2, etc.). Is this possible? This is all in a for loop so it runs over about 10 or 11 times or so ... I need the value of the i on the end so I can pass the whole variable as a function parameter. I once tried to send the eval expression as a parameter and, although it doesn't create any syntax errors, it doesn't work.

I tried this for the heck of it:

ActionScript Code:
listItem_text[i] = eval("currentListItem_text"+i);
     listItem_info[i] = eval("currentListItem_info"+i)

but that doesn't work of course.

Does all that make sense? If not I'm sorry, I'll try to explain more then, I'm only an intermediate AS'er. Thanks!

Using Eval( )
I have a grid of objects all the same into which I'm creating a second object. This second object has an array which I want to access from somewhere else, and when I try to reach the array info using the below I get nothing.

blar = eval("_parent.TheGrid." + thecell + "." + source + ".lblarray[" + i + "]");

Anyone got any idea why, and what I can do about it?

Cheers
Mat

Help With Eval()
Can anyone help. I am trying to: text="new"
here is the code.


text="old";

t=eval("text");

trace("____________");
trace(text);
trace(t);

t="new";
trace(text)

Thanks!

~Sunny

If Else / Or... Eval?
Hi Gang,

I have a loadmovie command been loaded by the input of a textfield "text" like so;

on (release) {
loadMovieNum (text+".swf", 2);
}

How can I tell if a movie has been found, then if not print in another textfield "result" , "No Results found"?

It will kinda work like a search thing as long as you roughly know what the user is inputting its fine.
I suppose a database of the filepaths would be the best with PHP or something but I am new to that stuff, though I am trying to learn.

Thanks in advance

Planethouse

Eval / This ?
Hi every one I am really frustrated two days I have been trying to figure out why this has not worked:

count = 5
for (i=0;i<count;i++){
eval("name"+count)= "bob";
}

kept getting this error:

Left side of assignment operator must be variable or property.

so finally I read up and they switched from "eval" to "this"
http://www.macromedia.com/support/fl...nment_area.htm

well when I did there sample it got rid of the errors, but it will not trace out

this["TextField" + "One"] = "string1"
trace("TextFieldOne")
which should trace out to string1, but I get undefined

the for loop and eval stament above I have used a thousand times before can any one tell me how to make this worl in flash MX

much thanx dave

Help Using The EVAL
i use to use this code on flash 5 and it works without any error but then when i tried using the same code on flash mx.. doesn't work... any idea on how to solve this? this is the code:

for(myCtr=0;myCtr=10;myCtr++){
eval("test"+myCtr)=myCtr;
}

the error on flash mx is:
Left side of assignment operator must be variable or property.


however, that code works on flash 5

Eval Help
can someone tell me why this doesnt work

a = "getURL('asdasdas')";
eval(a);

is there another way to do this?

im using flash mx btw

Help With Eval...
Hi... I need a little help with the eval function.

I want to do something like:
_root.zIMC.activateZone(0);

But I wanted to do it with:

eval("_root.z"+zoneChar+"MC.activateZone(0);");
// where zoneChar would have the "I" (or any other value I want)



I supose this should be easy..... but I'm not being able to do it.

Can anyone tell me where I'm doing the mistake?


Thanks for all the help!

Eval
i have:

var city = london;
var citytext = eval(city+"text");


that works well.

now i have

var city = londontext;
var city = eval(city-"text");

that doesnt give me the result i was looking for.

is there a way to do this?

Eval How Not To Use It?
This file i've got that's using eval wont work now that Flash MX is here! I remember one of the Flash God's taught me how to do it from Macromedia that time when they were in the flashkit.


I know eval is supposed to be depretiated. But cant think of how its supposed to be coded to make it up to date with the Flash MX code now.

All it simply is, is a button(s) numbered 0 to 10 when you press on the button(s) it puts the chr code or (number) in the input text field that has focus.

How do you convert this to Flash MX?

//one btn example for number '0'.
code:
on (release) {
eval(_root.control.select) += chr(48);


//code on a mc to detect it and put the number in whatever input text field is currently has focus!!
code:
onClipEvent (enterFrame) {
variablename = Selection.getFocus();
if (variablename != null) {
select = Selection.getFocus();
if (t=Selection.getFocus()) {
}
_root.qe.gotoAndStop("menu");
}
}


A small example fla of the one working in Flash 5 is there if you need it. Dont worry about the error you get when if you test it, it just because ive named the buttons in the instance panel to start changing it over the Flash MX. But it's working Ok in flash 5 i really need it to be over in Flash MX.

Eval() Help
I can't seem to get eval() to work

I need it to dynamically set a var to Zero ...

I have a 130 spaces ... and I don't want to set each one by hand

example

User clicks space10 -> set spaceName to space10 -> use eval() to combine spaceName and "_amount" -> set to Zero

or

User clicks space130 -> set spaceName to space130 -> use eval() to combine spaceName and "_amount" -> set to Zero

code:
on (release) {
spaceName = _name
eval(spaceName+"_amount") = 0
}

Note: this action is inside a movieclip

is this possible ...

Help With EVAL
I'm trying to do the following. I've got 8 movie clips called "pile1" thru "pile8".

I'm trying to reference them in a for loop, but can't get the right script down to do it. Here's an example:


Code:
for(i = 1; i <= 8; i++){
baseX = eval(pile+i)._x;
baseY = eval(pile+i)._y;
...
}


Anyone know how to work this?

Thanks,

Eval?
why cant you do this??

one = "nav";
two = "text";



eval(one).eval(two) = "him";


i wont to set the "text" in the MC "nav"
eventuall y this will do this

for(z=0; z< 5; z++)
{
eval(one).eval(two+z) = somevarible;
}

help, im really stuck on this one

Eval?
why cant you do this??

one = "nav";
two = "text";



eval(one).eval(two) = "him";


i want to set the "text" in the MC "nav"
eventuall y this will do this

for(z=0; z< 5; z++)
{
eval(one).eval(two+z) = somevarible;
}

help, im really stuck on this one

Using This Instead Of Eval
I am trying to set (in old school):

tellTarget (eval("_root.case_study_mc.mc"+dispMC+".cs_short_m c")) {
gotoAndPlay("open");
}

I am trying to use:

this["_root.case_study_mc.mc" +dispMC+ ".cs_short_mc"] = theTarget
trace("theTarget = "+theTarget)
eval(theTarget).gotoAndPlay("open")

its not working, anyone help me out?

Eval(), Anyone?
AS 2.0

hey, i wrote a function to that takes a value and searches an array to see if that value already exists in that array. for some reason, though, eval() doesn't appera to be evaluating correctly...

if i trace only ob, it finds ob as undefined...


PHP Code:




ob = eval("arr["+i+"]");
trace (ob);







anyone have a clue?

PHP Code:




ret = distinctArr(groupsArr, "gName", myOb.product[i].group);
        if (ret == 0) {
            groupsArr.push({gName:myOb.product[i].group});
        }
function distinctArr(arr, fieldName, val) {
    for (i=0; i<arr.length; i++) {
        ob = eval("arr["+i+"]."+fieldName);
        if (ob==val) return 1;
    }
    return 0;
}

What Exactly Does EVAL(); Do?
Hey guys, i've seen eval(); been used in movies that i've downloaded, but i never understood what it ment, can some one tell me and give me an example of how it would be used. thanks a lot

Something Better Than Eval(...) ?
say i have the following code:

finalX = eval(item)._width/2;

where item is a string, which equals "_root.myMC.myInnerMC"

i've heard that eval is unclassy and inefficient. what is the best way to do this? oh, and item is being passed to the function which contains the above line of code as an argument. is there a better way to pass a reference to a movieclip than by using its target name and path as a string?

thanks.

Eval In AS3
function stick(btnname) {
if (current_btn != btnname) {
eval(current_btn).gotoAndPlay("out");
}
current_btn = btnname;
eval(current_btn).gotoAndStop("down");
}

I belive this would have worked in AS2, but I want to use AS3 and just wonder if there is anything similar to eval?

Eval
I'm trying to update some old script that uses the eval function, but can't seem to convert it over successfully so it works in AS2 player 8+...
For instance I tried replacing eval("subContainer"+j)._alpha = 0 with this["subContainer"+j]._alpha = 0 ... but it didn't want to function.
Here's the old script:
code: function resetMenu() {
for(j=0;j<=(9);j++){
eval("subContainer"+j)._alpha = 0
eval("subContainer"+j)._x = -1000000
eval("subContainer"+j)._y = 0
eval("mainButton"+j).JumpTo(j*mainSpace)
}
}

Eval() Help
I have an array I created called platforms(), which contains a listing of objects.

I can reference the array by platforms[i].name and have a value return. But since I am trying track where they user is I am trying to set the value to a pointer/variable, so can drill down and know were I am at within the array and object structures.

nestLevel = "platforms{" + i + "]"
trace(eval(nestLevel).name)

This give me undefined. What do I need to do so when I trace(platforms[i}.name) and trace(eval(nestLevel).name) I get the same values.

I need to track this data so it is dynamic because as I drop down into the menu, in theory there is a infinite level of submenus.

Copyright © 2005-08 www.BigResource.com, All rights reserved