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








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.




KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 09-15-2005, 12:10 PM


View Complete Forum Thread with Replies

Sponsored Links:

Paramter From Url
I'm trying to pass a paramter to a flash through the url (eg. www.foo.html?uid=10). I remember seeing something about _url to access data that is passed in the url. Any advice?

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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!

View Replies !    View Related
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.

View Replies !    View Related
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);
}

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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".

View Replies !    View Related
Pass Url Paramter To Flash
Hello,

I'm trying to pass a url variable to a Flash file to determine where to start the movie. Within the Actionscript, there is a variable, "page=02", where I need to replace the 02 with a url parameter. I've tried the loadVars() with no luck. Also, I tried using the _root.pagenumber and it doesn't completely work. Any help would be appreciated.

Jim

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
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]

View Replies !    View Related
[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.

View Replies !    View Related
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...)

View Replies !    View Related
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

View Replies !    View Related
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...

View Replies !    View Related
Dynamic Text Field Using Paramter Tag
I am trying to populate a dynamic text field using the paramater tag.

like this <param name="FLASHVARS" value="text=Matts Meats&slogan=hurry and eat&font=&color=" />

works fine when I have two text fields with both var names, but I need be able to dynamicallly change from 3- 5 embeded fonts.

I an unsure whether to create the text box with AS or how I would go about embedding the fonts... if its even possible doing it in this manor.

any help would be much appreciated.

View Replies !    View Related
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?

View Replies !    View Related
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"?

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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!

View Replies !    View Related
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:


Code:
package
{
import flash.events.*;
import flash.net.*;

public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
// var loader:URLLoader = URLLoader( event.target );
// trace( "Par: " + loader.data.par );
// trace( "Message: " + loader.data.msg );
//}

private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}



And is running the following code in my flash:


Code:
import SendAndLoad;
import flash.net.URLVariables;

function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );

//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}

var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();

sal.sendData( url, vars, loadUsername );



As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.

As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?

View Replies !    View Related
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:

Code:
package
{
import flash.events.*;
import flash.net.*;

public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
// var loader:URLLoader = URLLoader( event.target );
// trace( "Par: " + loader.data.par );
// trace( "Message: " + loader.data.msg );
//}

private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}


And is running the following code in my flash:

Code:
import SendAndLoad;
import flash.net.URLVariables;

function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );

//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}

var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();

sal.sendData( url, vars, loadUsername );


As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.

As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?

View Replies !    View Related
Mysql->PHP->FLASH Function. (Passing Function To A Package)
I've just started with ActionScript3.0, and is currently working on a flash that is to communicate with a mysql database and have found a great deal of example code online that I've started to work with.
Currently I have the following package added to my project:
quote:package
{
import flash.events.*;
import flash.net.*;

public class SendAndLoad
{
public function SendAndLoad()
{}
public function sendData( url:String, _vars:URLVariables, completeFunc:Function ):void
{
var request:URLRequest = new URLRequest( url );
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener( Event.COMPLETE, completeFunc );
loader.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
loader.load(request);
}
//private function handleComplete( event:Event ):void
//{
//var loader:URLLoader = URLLoader( event.target );
//trace( "Par: " + loader.data.par );
//trace( "Message: " + loader.data.msg );
//}

private function onIOError(event:IOErrorEvent):void
{
trace("Error loading URL.");
}
}
}

And is running the following code in my flash:
quote:import SendAndLoad;
import flash.net.URLVariables;

function loadUsername( event:Event ):void
{
var loader:URLLoader = URLLoader( event.target );

//userNameText.text = "ffff";
userNameText.text = loader.data.user;
}

var url:String = "pages/test.php";
var vars:URLVariables = new URLVariables();
var sal:SendAndLoad = new SendAndLoad();

sal.sendData( url, vars, loadUsername );


As you can see I am trying to seperate the function to be called when the return value of the page I am accessing returns with a value, so I wont need to pass all different actions to be called on different pages I will be requesting throughout my flash program.
But as it is now, the function loadUsername, never even gets called, which I assume is because the package can't call the function outside it.

As I said, I am just starting out with ActionScript 3.0, and is kind of stuck at this.
Any thoughts?





























Edited: 10/09/2008 at 08:46:50 AM by _TT_

View Replies !    View Related
Passing A Function Ref To A Function With Parameters
Can anyone tell me how to pass a function reference to a function WITH parameters?

I want to do something like this:

genericFunc = function(funcRef, params){
//do something that takes a while
//and when done...

//call my funcRef with params:
funcRef(params)
}
func1 = function(){
//trace("here's funct#1");
}
func2 = function(arg1, arg2){
//trace("here's func#2 with arguments "+arg1+" and "+arg2);
}

Test 1: genericFunc(func1);
Test 2: genericFunc(func2, ...) //this is where I lose it.

So, this works fine if I'm passing in a function call that requires no parameters (test 1). But what I really need to do is keep this flexible so that I can reference different functions with varying numbers of parameters (test 2).

View Replies !    View Related
Passing A Function To Another Function In A Loaded Swf
Here is the problem: to make it simple, I have two swf's, one loaded into a movie instance of another swf. In the loaded swf, there is a function called checkClient with a variable passed into the function. Here is the code for checkClient

function checkClient(userID)
{
_parent.isResultCompleted(checkClient(userID));
}

isResultCompleted is a function in the root swf with the code

function isResultCompleted(functionToBeChecked)
{
functionToBeChecked;
}//end function check result

The problem I'm having is that functionToBeChecked dosen't call the function checkClient. The code in red is where I know the problem lies. Any ideas?

I have been trying to get this to work for a while now and have looked all over this forum, but nothing seems to give me a result that works. Thanks in advance. KD

View Replies !    View Related
Passing A Function Handle To A Function...
How can I do the following:

So I add a new child to my stage and inside this movie I got a couple variables and button handling lines of code.

I set this variables on each of the created movies and I would like to also pass a reference to a function.

This reference function can than be called when a button is pressed inside any of those created movies on my stage...

//Pseudo code
this.clip34.setFunctionReference(displayMessage);//Here I pass my function handle... How can I do this?

function displayMessage(str:String)
{
trace(str);
}


function setFunctionReference(func:FUNCTION?)
{
func("Hey I was clicked!");
}


Hope you understand me... ^.^

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
Passing Value To A Function
Hi guys

im calling a function and passing a value (Unit41)

function passlist(param1){
mylist=param1
trace(param1)
//unit41

}


I have a list called unit41

unit41=[1,23,45,67,89,12]

i want to set mylist in the above function to

mylist=[1,23,45,67,89,12]

hope this makes sense. I need to point the parameter passed to my function
to a list with the same name

cheers

weblingo

View Replies !    View Related
Passing An MC Name To A Function
What I'm trying to do is something along the lines of this:


Code:
funtion someFunction(clipName) {
clipName.somethingInside.affectClip(1,2,3);
}

mc_01.button.onRollOver = someFunction("mc_01");
mc_01.button.onRollOver = someFunction("mc_02");
So I have the containing movie clip, a button in side, and another object inside that I would like to affect. Any help is greatly appreciated.

Thank you.

View Replies !    View Related
Passing A Url Var In A Function.
this does not work:

var soemthing = new Something("./something.html"); for some reason... when you want to pass that as a var... i do not want to hard code anything, though.

View Replies !    View Related
Passing A Value Into A Function
Im cant work out what in doing wrong. I have a function on the main root time line which is only one frame.

ActionScript Code:
function inertiaCalc (cheese) {
 
speed=1.8
 
if (_root.MCScale<>_root.MCTarget) {
_root.MCScale = Math.round (_root.MCScale+(_root.MCTarget-_root.MCScale)/speed);
_root.cheese._yscale = _root.MCscale;
}
 
}


where cheese variable i want to pass in a instance name of the MC i want to change scale.
On the MC itself, instance name square2, I have this code

ActionScript Code:
onClipEvent (enterFrame) {
    cheese = square2
    _root.inertiaCalc (cheese)
}


On a separate button i have this

ActionScript Code:
on (rollOver) {
_root.MCTarget = 200
}
on (releaseOutside, rollOut) {
_root.MCTarget = 100   
}
on (press) {
_root.MCTarget = 400   
}
on (release) {
_root.MCTarget = 200
}


Now I know the function works because when i change cheese to square2 in the function on the root it it is perfect - i just cant get it to work when passing the instance name in variable cheese! help!

View Replies !    View Related
Passing MC Name To A Function ?
OK, I'm trying to figure this one out and if anyone can help, life would be a brighter place

Lets say i have a function in _root:

function changeText (mc) {
mc.myText_txt = "hello";
trace("should write hello");
}

and then I would have a MC with a instance name of "myClip" with a dynamic text field named myText_txt. On the first frame I calll the function in _root and pass the parameter with the name of this MC.

_root.changeText (myClip);


Why doesn't this work, and how can i pass MC names to functions to use them?

View Replies !    View Related
Passing Value To A Javascript Function
Hi,
can anyone tell me as to how i can pass the values of variables declared in a flash movie to a javascript function,called by the geturl command.
regards
jayant

View Replies !    View Related
Calling A Function And Passing A Var
hi,
i have a button (about_me_button)

on release, i want to:
1 call a function to play a short 'loading data' movieclip
2 then go to the appropriate label (about_me) AFTER the short mc has played

i have the following code in my buton:

on (release) {
_root.gts("playLoading"); //this calls the short movie

if (_root.playLoading_mc.finished=true) {
_root.gts("about_me"); //this goes to the label
}
}

i created a variable called finished in the short mc:
frame1: finished=false;
last frame: finished=true;

and i'm trying to get the buton code to check whether the mc has played BEFORE calling the function again and pssing it the labelName variable

please help

View Replies !    View Related
Passing Objects To A Function Yay
//---------->> Welcome to another one of my questions!
Ok this kind of plays off my previous question, so if you dont get that one take a crack at me now ;-) It appears to me that ActionScript.. being based off of JavaScript (which is based off of Java) is an OBJECT ORIENTED Language..

//---------->> havind said that**
I would like to create a function that passes an instance of whatever object to a function, and the object in turn does whatever that function says to do.. kind of like a filter in photoshop..

//---------->> for example
I make a function that moves the image 10 pixels to the right and alpha drops to 50%.. I pass an object to this function and it responds by moving 10 pixels to the right and fades its alpha by 50%

//---------->> and your reward
250,000 cool points since this question isnt as hard as my first one lol..



Thank you Flash Peeps!!!
N3MES1S

View Replies !    View Related
Passing XML.attributes To Function
I am writing a program that basically reads attributes from an xml document, stores them into a hash, then pulls data from the hash and adds them to a listbox.

However data is not being added to the hash whenever this happens:
//many lines deleted
for (i=0; i < this.firstChild.childNodes.length; i++) {
cityListMgr.addWorker ( this.firstChild.childNodes
[i].attributes["name"],
this.firstChild.childNodes
[i].attributes["job"],
this.firstChild.childNodes
[i].attributes["spec"],
this.firstChild.childNodes
[i].attributes["loc"]);
}
"cityListMgr" is the name of my hash and "addWorker()" is a prototype of CityListManager my user-defined data structure.
For some reason these values are not being added to the hash. But when I replace the above code with a manual addition:

cityListMgr.addWorker("john","cook","crab","brookl yn");

This person is added to the hash and his information is added to the listbox as an item. I am wondering if its some kind of data type conflict? attributes["attr"] is not a string but an xml Object type? Any information is gladly welcome -- thnx Dave
btw a sample piece of xml looks like this:

<city>
<worker name="john" job="cook" spec="crab" loc="brooklyn" />
</city>

View Replies !    View Related
Help Passing Unique Var Through Function
Quote:




Originally posted by astro_sk
Overview:
what I am basically trying to achieve is a simple function that can be called upon to move as many movie clips as I declare (the movement mimicing*spelling* inertia).

Function:
_global.moveit = function(mc, numbered) {
//get the X position of mc
tsmc_x = getProperty(mc, _x);

/:gots_location = numbered;

shift_tsmc = /:gots_location-tsmc_x;
formulats= math.round(tsmc_x+(shift_tsmc/3));
setProperty(mc, _x, formulats);
/:formula=numbered;
};

whats in the first frame of the scene:

only one frame.
I have 5 boxes each named b1,b2,b3,b4,b5.
and a seperate mc named controller which calls upon the function from the scene.
in the mc, controller:
I have three frames
in the first frame I have the following script:
/ne = random(310)+20;
in the second frame I have the script:
moveit("/:b1", /ne);
moveit("/:b2", /ne);
moveit("/:b3", /ne);
moveit("/:b4", /ne);
moveit("/:b5", /ne);
in the third and last frame I have:
gotoAndPlay(2);
if (/:formula==/ne) {
gotoAndPlay(1);
}

Delema:
I have tried many different ways to get this to work. I believe that my problem is in creating a unique variable, equivalent to the /:formula variable, for each of the mc's passed.

Is the only way to do this to write the same function with different variables for each of the mc's?

thanx to all in advanced

View Replies !    View Related
Passing Variables To Function
Hi All,

function ovr() {
_root.b5.arrow.gotoAndPlay(1);
_root.b5.btn.gotoAndPlay(1);
_root.b5.text5.gotoAndPlay(1);
}

if i want to substitute the 5 beside the b5 to any other number depends on what i will pass to the function, how can i write it?

is it like this

function ovr(x) {
_root.b'+x+'.arrow.gotoAndPlay(1);
//or//_root.b+x+.btn.gotoAndPlay(1);
//or//_root.b"+x+".text5.gotoAndPlay(1);
}

or how? it gave me errors, how should i do it?

Thanks

View Replies !    View Related
Passing Params To A Function
Hi,

Thanks for taking the tim to read my post.

I seem to be having a problem with passing params to a function through myComboBox_cb.setChangeHandler("myFunction");. Shouldn't it seem possible to:

code: function calcHours(beginHour, endhour) {
begin = new Date(2003,0,1,beginHour);
end = new Date(2003,0,1,endHour);
diff = (end - begin)/1000/60/60;
}
myComboBox_cb.setChangeHandler("calcHours(4,12)");


I understand the root of the problem is that the function reference is a string. No params can be passed this way because Flash thinks I am referring to a function named "calcHours(4,12)" not "calcHours" with params 4 and 12.

Any workarounds for this?

View Replies !    View Related
Passing Function As Argument
I'm working on a function that checks the time it takes for a given function to run. I'm using Flash MX and the code looks like this:

function timeCheck(anyFunction){
var startDate = new Date();
anyFunction;
var endDate = new Date();
timeConsumed = endDate - startDate;
return timeConsumed;
}

The principle is that i check the current time, run the given function, then check the time again and take the time difference. My problem is that I don't know how to pass and run the function.

Is this possible to do, and if so, how?

Cheers,
Olle

View Replies !    View Related
Passing Var To Function And Using Attachmovie()
this should be simple. all I want is to pass a variable ("01") to a function and in that function use that variable as the idname for an attachmovie() like so:

function Thumbnail (x,y,pic) {
// Create a MC called "clip" that "thumb_mc" can attach to at x and y
createEmptyMovieClip("clip",1);
clip.attachMovie(pic,"",1);
clip._x = x;
clip._y = y;
}

// CREATE THUMBNAILS
var thumb1 = new Thumbnail(200,300,"01");

WHY DOESN'T THIS WORK?!?!?!

View Replies !    View Related
Passing Var To OnRelease Function
Isn't it supposed to work !!!!

Code:
i = 1;
some_mc.onPress = function(i){
trace(i);
}

seams like i is not passing to the function at all !!!

can anyone explain please ? plus maby some hints how to make it work

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved