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




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



Ultrashock Forums > Flash > ActionScript
Posted on: 2004-10-11


View Complete Forum Thread with Replies

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

Invoke Function In As3
Hi,

Simple with as2... but i can't with as3..
How can i invoke a function in a parent mc... from one of its childs mc??

I've a child MC with 2 frames... in the second one i want to invoke a funtion mostrarHorario(), that is located in the parent MC of this...

Please... help me
thanks.

Invoke A Global Function From A MC?
Hi,

I know this might be a question for the Newbie forum but here goes anyway -

In MX, I have a function on the main time line, which fades in a MC:

Code:
inertia = 5;

function Fadein(by) {
this._alpha += (by - this._alpha)/_root.inertia;
}
How do I call it from an onClipEvent handler?
Will it even work?
Do I have to target the MC I'm invoking it from?

Arrrggghhhhh help!

I know I'm missing the obvious.

Actually I may have approached it in the wrong way, so this is what I'm trying to do:

I have about sixty movieClips which fade (and eventually spin ,move, etc) in at various times in this projector - I just want to write a global function, so I don't have to re-write all the code in an onClipEvent handler every time.

Cheers in advance for any help.

Stu

Invoke A Function In An External Swf
Okay, I know it has to be possible one way or another...I want to be able to invoke a function in an external file from the host file and vis-a-versa. Here is what I have...three files:

Main Movie
External A
External B

The Main Movie loads in External A. In External A I have a button. On click it tells Main Movie to load in External B. I also want it to tell Main Movie to call a function within External B. Is there anyway to make this happen or really, anything that might help me?

Thanks...

Invoke Function After OnResize
hi.
i'm writing a dynamic scrollbar class and have run into some problems regarding the Stage.onResize function.
resizing itself works very well, though i would like to call a function _after_ (!) the resizing is done, like a callback.

ive been reading, googling and asking round but i cant get it straight.
is it impossible? i mean, come on, there must be workarounds..

i would rather not use an interval or an onEnter here (cpu issues), eventhough i know it can be solved with this..


thanks,
fred

Function Invoke B4 OnPress
Code:
goto = function(where:String) {
getURL("http://esample.com/"+where+".htm","_self");
}

button1.onRelease = goto("home");
when the movie loads, flash immediately 'getURL' BEFORE i press my button1. how come the code execute even before i press it 1st? what's wrong with my code?

thx in advance.

Function Invoke B4 OnPress
Code:
goto = function(where:String) {
getURL("http://esample.com/"+where+".htm","_self");
}

button1.onRelease = goto("home");
when the movie loads, flash immediately 'getURL' BEFORE i press my button1. how come the code execute even before i press it 1st? what's wrong with my code?

thx in advance.

Can I Simply Invoke A Function Every Time A Var Changes?
Say I wanted to do something like this (not possible):
aNumber=99
aNumber.onChange=function(){
dNumber=aNumber
}

How would I do something like this?

Invoke Funtion Inside A Function
Hi,

How can I invoke a function (in the main timeline) from another function in a movieclip timeline?

I set that function as global, but he never goes to that function in the main timeline.

Thanks.

How To Invoke A Function On DynamicTextField Change
Hi all!

Im looking for a way to invoke a function automatically on TextField value change... something like this:


Code:
TextField.prototype.onChanged = function(){
trace("Changed!")
}
_root.createTextField("myTF", _root.getNextHighestDepth(), 10, 10, 100, 40);
myTF.type = "input";
myTF.text = "sdfsdf";
That script working great with Input TextField on keyboard press... i need the same thing but with Dynamic TextField - on TextField value change...

10x for advanced....

<a Href> Tags That Invoke AS Function
hi everyone,
i need your help on how to call a actionscript function using <a href> tag....is this possible?

i have an example link here http://www.kirupa.com/web/xml/examples/searchbestof.htm
this is supposed to be what i want but i need to load an AS function or load it within flash not URL..

any idea would greatly appreciated...

please help me....

thanks

Invoke An As Function From A Button In An Html Page?
i need to bascally call a function in a flash file from a button in a seperate html page. is this possible?
really need the help!
michael

VB Call To Invoke Level0 Flash Function
Can anyone help me with

Calling from VB to invoke a level0 function in Shockwave Flash.


Thanks


Dynamic Movie Clip Reference, Invoke Function In Mc
Happy new year all!!

I'd like to invoke a function inside a mc from it's parent, but I want to have the reference to the clip be dynamic. When I path the mc directly and invoke the function it works, how would I make that same reference work dynamically.

Here's a sample of what I'm trying to do:

Code:
var myArr:Array = new Array();
myArr[0] = "galleryContainer_mc.eventGallery1_mc.imgContainer_mc";
trace(myArr[0]);

// This works
toggle_btn.onRelease = function() {
galleryContainer_mc.eventGallery1_mc.imgContainer_mc.videoToggle();
}
// But this doesn't work
toggle_btn.onRelease = function() {
myArr[0].videoToggle();
}
I know I'm fried, but that seems like it should work, am I missing something really basic here? Any advice would be really helpful at this point. Thanks!

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!

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.

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 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!

Invoke Pdf Issue....
var myRPT = [[146, "RPT146.exe"]];

onRelease = function ()
{
for (var i = 0; i< myRPT.length; i++)
{
if (_root._currentframe == myRPT[i][0])
{
fscommand("EXEC", myRPT[i][1]);
break;
}
}
}


I have a dir called fscommand with invoke,proxy, the proxy is called RPT146.
a bat file called RPT146 that has the following line of code - invoke open RPT146.pdf

i have no idea why this will not work

any ideas?

northcode ?

Flash Gods, I Invoke You
in a nutshell:
i'm trying to move the 'playhead' on a timeline i created, thus changing the physical location of the playhead, and changing the values of dynamic text boxes which corrispond with the playhead's location.

(everything is already functional if you Drag the playhead along, but i'm trying to add an additional way to browse the
site, with a button that browses thru one spot on the timeline at a time)

****
this is what i want to do:

access the _x position of a MC called "1" (the playhead), find that number in the possible _x positions that "1" can snap to in an array called "xspot", and append that number's placement in "xspot"(0-9) to the variable "i".

i then add one to "i" (or go back to 0 if we are at the end of the array) and apply this value to the variable "nextstep"

now that i have "nextstep", i know which elements in the arrays "xspot" and another called "who" (both with 10 elements) contain the info for the next playhead position, both for the playhead's _x position "xspot", and the dynamic text's content "who"
****

this code is appended to a button, will that cause a problem?

something isn't working right...

got any clues? or better ideas to approach this oparation?

_____code_________________________________________ _______

on (release) {
// xspot is an array which contains the diff. x positions my MC "1" can snap to/park at
for (var i = 0; i < _parent._parent.xspot.length; i++) {
// i have a feeling there is something funny about this line
if (_parent._parent.1._x == _parent._parent.xspot[i]) {
if (i <= 8) {
_parent._parent.nextstep = i++;
} else if (i == 9) {
_parent._parent.nextstep = 0;
}
break;
}
}
name = _parent._parent.who[_parent._parent.nextstep];
if (name = "billybob") {
_parent._parent.1._x = _parent._parent.xspot[0];
_parent._parent.pictext.scroll = 1;
_parent._parent.pictext = "Text";
_parent._parent.biotext.scroll = 1;
_parent._parent.biotext = "More Text";
// there are many names, each with it's own dynamic text content, and coorisponding playhead position on the timeline

______end of code_________________________________________


please help!!!

quazi

How To Invoke Auto-click In AS
Hello.

Is it possible to code in AS that a button has to be clicked? I have a swf with a button on it. I want in the first frame a code that clicks the button. Does someone know if there is such a code?

Thanx in advance.

Luut.

Can You Invoke Something After A Code Tween Is Done.
Just like animating something on a time line I did it with code. But would like to now if it is possible to do this or not?

I have my code tween here.

Code:
Landing_flying = function(){
var maxNumber_up = 80;
var easeType = mx.transitions.easing.Regular.easeOut;
var begin1 = 50;
var end1 = 180;
var time = 34;
var Body_mc1 = body;
Flying1 = new mx.transitions.Tween(Body_mc1, "_y", easeType, begin1, end1, time, false);
// After tween invoke new function
//stop_flying(); // stops wing animations.
}


Right after it reaches the destination at the end of its tween I would like to invoke a separate function. But only after the tween is done.

If this is possible if so can some one point me in the right direction can some on pint me in the right direction.

[F8] Manual ContextMenu Invoke?
Hi all, quick question -

Is it possible to manually display a context menu at a certain point in time? I'm making an app and would like the user to be able to invoke the right-click context menu I've created when they click on a certain button on the stage. Any ideas? Thanks.

-T

Can I Invoke MouseEvent With ContextMenuEvent?
I’m new to both Flash and AS3 so hopefully I can explain my problem correctly. And if anyone has ideas on how to better approach what I’m trying to accomplish, please offer up some suggestions.

I’m producing some training and have the students click through various ‘hot spots’ on several screen captures to simulate the actual steps. At one point they are required to right click and select an option which just takes them to the subsequent step. I’ve customized my context menu.

I have a showStep function call by MouseEvent.CLICK that advances through an image array and advances the array index. When the image is loaded a function then creates the hot spots. I’ve successfully added the custom menu to the correct hot spot and have an event listener using ContextMenuEvent.MENU_ITEM_SELECT that passes to a function I want to then invoke showStep again.

Here’s where I’m stuck. When I select the right menu item, it activates the contextMenuOwner hot spot that I can then click to advance the image. I want to advance the image by selecting the right menu item which calls the MouseEvent obj via showSteps.

Hopefully all of that made sense. Here are the snippets I think are appropriate.


Code:
//set hit areas
var newHitArea:Sprite;

//from customizingContextMenu
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var mainTimeline:MovieClip = this;
mainTimeline.contextMenu = myMenu;

//rc menu to be used with hit area
var newRCMenu:ContextMenu = new ContextMenu();
newRCMenu.hideBuiltInItems();

var createNode:ContextMenuItem = new ContextMenuItem("Create Node");
createNode.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doMenuEvent);

function doMenuEvent(evtObj:ContextMenuEvent):void{
var tgtObj:DisplayObject = evtObj.contextMenuOwner as DisplayObject;
var tgtMenuObj:ContextMenu = evtObj.currentTarget as ContextMenu;
tgtObj.addEventListener(MouseEvent.CLICK, showSteps);
tgtObj.dispatchEvent(new MouseEvent("CLICK"));
}

function showSteps(evtObj:MouseEvent):void{
stepImg.visible = true;
stepImg.load(new URLRequest("../images/"+imgArr[thisStep][0]));
stepImg.x = layerX;
stepImg.y = layerY;
addChild(stepImg);
makeHitArea(thisStep);
thisStep++;
}

function makeHitArea(currStep){
if (newHitArea){
removeChild(newHitArea);
}
newHitArea = new Sprite();
// ... make hit area
hitAreaType = imgArr[currStep][1];
if (hitAreaType == "rc"){
newHitArea.contextMenu = newRCMenu;
newRCMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);
}else{
newHitArea.addEventListener(MouseEvent.CLICK, showSteps);
}
addChild(newHitArea);
}

// borrowed from Adobe examples: Custom Context Menus
function menuSelectHandler(evtObj:ContextMenuEvent):void {
var obj:DisplayObject = evtObj.contextMenuOwner as DisplayObject;
var menuObj:ContextMenu = evtObj.currentTarget as ContextMenu;
menuObj.customItems = [];
menuObj.customItems.push(createNode);
}

Can You Invoke Something After A Code Tween Is Done.
Just like animating something on a time line I did it with code. But would like to know if it is possible to do this or not?

I have my code tween here.

ActionScript Code:
Landing_flying = function(){
    var maxNumber_up = 80;
    var easeType = mx.transitions.easing.Regular.easeOut;
    var begin1 = 50;
    var end1 = 180;
    var time = 34;
    var Body_mc1 = body;
    Flying1 = new mx.transitions.Tween(Body_mc1, "_y", easeType, begin1, end1, time, false);
    // After tween invoke new function
    //stop_flying(); // stops wing animations.
}

Right after it reaches the destination at the end of its tween I would like to invoke a separate function. But only after the tween is done.

If this is possible if so can some one point me in the right direction can some on pint me in the right direction.

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