Calling Variable To Check ==
OK this sounds simple but why does this not work.I have a quiz, simpleneeds to check answer, button value against variable value. The variable is set in that frames action, and it is getting it ok. I see it in the debugger.What gives?I have:Code: on (release) { if (eval("answer") == "a") { gotoAndPlay("correct"); } else { if (eval("user_try") == "2") { gotoAndPlay("wrong2"); } else { gotoAndStop("wrong1"); } }}The eval() code for the user_try is working.Anybody have a clue?Thanks
General Flash
Posted on: Sat May 06, 2006 1:40 pm
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamic Text Field Is Calling The Variable Name Instead Of Variable Content
I'm having a problem getting something to work. I'm sure it has something to do with string variables and my syntax, but can't figure it out.
I have variables named cust1, cust2, cust3, etc. that are being loaded from a text file (these are customer names that will display in a text ticker).
I want a dynamic text field to display the customer names in incremental order, so I created a variable that consists of the string "cust" + a numeric variable called custNumber. At the end of each pass of the movie, custNumber is increased by 1.
var custNumber = 1;
var custName = "cust"+custNumber;
I want the dynamic text field to call the variable custName, but I can't get it to work. It keeps displaying custName as a string ("cust1", "cust2", etc.).
So I created a new variable called scrollText for the dynamic text to call, and made scrollText = custName;. But it does the same as above.
How do I get my dynamic text to call the variable that I create with another variable?
I want my dynamic text field to display the variable cust1, cust2, cust3, which would be "Jones Plumbing," "Smith Electric" etc., but all I'm getting is "cust1", "cust2", "cust3" etc.
Thanks,
Thom
Calling A MC Using A Variable
Is it possible to request the actions of a movie clip using a variable.
For Example
if I have a variable x, and I want the movie clip myClip to play. Can I use a command like this:
x="myClip"
_root.x.play()
This may not seem practical but I want a certain MC to play depending on certain variable. In other words depending on what certain variables are I would have different values for x and thus different MCs playing.
Is this at all possible?
Calling A Variable
Hi guys,
This is proabably very easily solved, but I just can make sense of it so here goes:
In my frame actions I define a variable:
myvar = "empty";
trace(myvar);
that checks out fine, 'empty' is displayed in output.
I then have a draggable movieclip. Basically I want to say if movieclipA touches movieclipB AND myvar = "empty" then...
if _root.clipa.hitTest(_root.clipb)and(myvar="empty") ){
trace(myvar);
setProperty("_root.clipa", _x, "35.6");
setProperty("_root.clipa", _y, "284.6");
stopDrag();
For some reason though the trace(myvar); on the draggable movieclip comes back as undefined.
I thought maybe myvar needs defining as a global variable, so I changed all dropzone's to _global.myvar
As soon as I did this the trace(myvar); in the actions frame came back as undefined.
Hope I explained this okay (novice u c!) any ideas?
Calling Up A Variable From W/i A Mc?
im having a problem calling up a varible from w/i a mc, ive tryed making a linkage to the mc and tryed giving it a instance name, but i really cant get it to work, im kind of new to coding and ive understood the _root. thing, but im having problems w/ this, what i tryed is creating a linkage and instance name called gunmovement, and i try to call it up like gunmovement.gun1blts , is this correct or not, or do i have to use a simular thing to the _root.?
Calling Mc, With Variable
If I had mc's named bar1, bar2, bar3, etc...and had a variable named num. How could I target an mc's timeline using the variable num? I tried something along the lines of:
Code:
_root.bar["num"].gotoAndPlay(5);
But this didn't work. Any suggestions?
Calling A Variable + I;
I am trying to call a variable + i; this is what I have so far,
myVariable = myData["theVariable" + i];
since "i" equals the last entry I only want to pull that entry.
here is another variation that didn't work:
myVariable = myData.ref["theVariable" + i];
this worked
myVariable = myData.theVariable0;
I want it to work dynamically with "i" can anyone show my how to do this or point me in the right direction?
Thanks!
Quince
[MX] Calling Variable
Hi, I'm using AS1:
I have attached an mc (test1) to another mc called fotozw.
When I call this mc in another part of the movie. the address is:
_root.section_1_mc.vlak1.vlakOranje.fotozw.test1.r emoveMovieClip();
and this works fine.
However: I have a lot of attached mc's in the movie, and I would like to set the name of the attached mc's in a variable. That variable will be called in the same function as the line above.
The following line doesn't work, if I set _global.theVar= test1:
_root.section_1_mc.vlak1.vlakOranje.fotozw.theVar. removeMovieClip();
How should I code this line to properly address the attached mc, but then targeted with a variable name?
Thanx!
Help Calling A Variable URL
Hi, i'm trying to insert a variable JPG and URL into my swf. basically its a rollover button that i want to link to a popup window with a URL that i can define in my main html page. The variable jpg works but when i click on the thumbnail it opens a new window with the jpg image instead of going to a URL.
im still new at this so it might be something really simple, but i just cant seem to figure it out.
heres my AS code with the variable parts in bold:
Code:
import fl.transitions.*;
import fl.transitions.easing.*;
var borderSize = 10;
var photoURL:String = new String();
photoURL = String(this.loaderInfo.parameters.source);
var popupURL:String = new String();
popupURL = String(this.loaderInfo.parameters.source);
var imageLoader:Loader = new Loader();
var movOriginal:MovieClip = new MovieClip();
var movOver:MovieClip = new MovieClip();
var home:MovieClip = this;
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadedImage);
imageLoader.load(new URLRequest(photoURL));
function onLoadedImage(e:Event):void {
var g:Graphics = movOriginal.graphics;
g.clear();
g.beginFill(0x000000);
g.drawRect(0,0,imageLoader.width+borderSize*2,imageLoader.height+borderSize*2);
g.endFill();
var g2:Graphics = movOver.graphics;
g2.clear();
g2.beginFill(0x83C15C);
g2.drawRect(0,0,imageLoader.width+borderSize*2,imageLoader.height+borderSize*2);
g2.endFill();
movOver.alpha=0;
movOver.x = movOriginal.x = imageLoader.x-borderSize;
movOver.y = movOriginal.y = imageLoader.y-borderSize;
home.addChild(movOriginal);
home.addChild(movOver);
home.addChild(imageLoader);
}
imageLoader.x = 10;
imageLoader.y = 10;
imageLoader.addEventListener(MouseEvent.CLICK, doSomething);
imageLoader.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
imageLoader.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
function doSomething(Event:MouseEvent):void {
var _link:URLRequest = new URLRequest(popupURL);
navigateToURL(_link);
}
function mouseOverHandler(e:MouseEvent):void {
var myTween:Tween = new Tween( home.movOver, "alpha", Strong.easeOut, home.movOver.alpha, 1, 5, false);
}
function mouseOutHandler(e:MouseEvent):void {
var myTween:Tween = new Tween(home.movOver, "alpha", Strong.easeIn, home.movOver.alpha, 0, 5, false);
}
and heres my html code. i wasn't sure how to insert the desired URL (bird.html) that i want the popup to go to:
HTML Code:
<script type="text/javascript">
AC_FL_RunContent( 'type','application/x-shockwave-flash','data','project.swf?source=projects/bird.jpg','width','390','height','100','movie', 'project?source=projects/bird.jpg' );
</script>
Check Variable
HI, I have created a slider which the user can drag to a new position on a line, this results in a variable being changed . What I want to be able to do is when the variable reaches a certain number i.e. 100, I perform a goto action. I am finding this hard, any ideas??? Where should I put the if statement to make it work.
My if statement is:
if (locationAt==100) {
gotoAndPlay(75);
}
Plesae help
Michelle
What's The Best Way To Check The VALUE Of A VARIABLE?
I've been trying to figure this out for the last 24 hours.
I've set a variable, volume =3;
I have a button that
on(release){
if(volume>8){
volume = volume+1;
}
}
on frame one of the timeline I've placed the following script:
_root.volume_bars_mc = function() {
if (volume=3) {
_root.volume_bars_mc.gotoAndStop(1);
} else if (volume=0) {
_root.volume_bars_mc.gotoAndStop(2);
} else if (volume=1) {
_root.volume_bars_mc.gotoAndStop(3);
} else if (volume=2) {
_root.volume_bars_mc.gotoAndStop(4);
} else if (volume=4) {
_root.volume_bars_mc.gotoAndStop(5);
} else if (volume=5) {
_root.volume_bars_mc.gotoAndStop(6);
} else if (volume=6) {
_root.volume_bars_mc.gotoAndStop(7);
} else if (volume=7) {
_root.volume_bars_mc.gotoAndStop(8);
}
};
This doesn't want to work. I have no idea what I'm doing worng. Any HELP would be greatly appreciated.
Thanks! PETE
Check Value Of Variable
Hi,
I'm building a Flash navigation bar that will be used on an html site, the same nav will be used on each page but I want the button for the current page to be highlighted when you go to that page.
I've included a variable in the html (currentVar) that sends the name of the page to Flash...
<param name="movie" value="harkord_nav.swf?currentVar=home">
<embed src="harkord_nav.swf?currentVar=home">
I've tested it in Flash (using a dynamic text box with the variable name 'currentNav') and the variable is coming through fine but I'm having trouble getting Flash to check what the variable is and then to send an MC to the highlight position.
This code is on the MC I need to highlight...
code: onClipEvent (load) {
if (currentVar == "home") {
_root.homeNav_mc.falsebutton_mc.textbase_mc.gotoAn dStop(2);
}
}
Any idea where I'm going wrong?
Thanks,
Andy
Check Variable Then Act
I have a prob and i'm v new to programming in
flash (and in general) wondered if anyone could advise
have done the flash tut for making a webform / email
sender from my website. uses a php and once the
email is sent, the php tells the dynamic text box
(EmailStatus) to say "Complete - Your email has
been sent."
what i was trying to achieve is having an action script
that looks at the dynamic txt box and once it has said
"Complete - Message sent" it would continue
the movie, (animate and unload the movie)
My base movie is called main
my email form is on layer 5
and variable is called Email Status
-----------------------------------------------
i was playing with stuff like:
if (EmailStatus="Complete - Your email has been sent") {
gotoAndPlay (3);
} else {
gotoAndPlay (1);
}
------------------------------------------------
but its not having it!!!!!!
is this the right way to keep checking a variable?
and then continue movie?
aany help appreciated, Matt
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.554 / Virus Database: 346 - Release Date: 20/12/2003
Check Variable Value?
How can get flash to ((constantly)) check the value of a variable???
i have this so far...
Button
on (rollOver) {
arrow = "b";
}
on (rollOut) {
arrow = "b";
}
Movieclip
if (arrow == "a") {
play();
} else if (arrow == "b") {
stop();
}
Please Help
Check Or Variable Is Set
How can i check or a variable is set?
If you request the movie as http:\url.commovie.swf i want the movie to stop on the first frame, but if you reauest the movie as http:\url.commovie.swf?user=test i want the movie to start playing...
(sorry for asking such a simple question.... i think )
Variable Check
I got help with this movie before but have com across a problem
I need to check for a minimum bid and maximum bid
But i need it to check that if someone enters just 2 digits it understand it as pence and adjusts the decimal point etc
The movie i have attached works to a certain extent but it cant check for say a bid of 1.70 if i set the minium value to 10 it asumes its 10 and treat the bid as lower and not within the range.
Hope i explained the problem enough for someone to help
Check Box Variable
my radio buttons are not sending a variable
on (release) {
/:mrmiss = "Miss";
}
It's telling me that /: is not liked. when i remove them and test it on my webserver its not sending the variable to the php scirpt.
My check box isnt sending it either
whats the new way to do this?
Check Box Variable Help
I have a form that all the input text forms report to the CGI fine. I'm having problems with the check boxes.
How do I assign them a variable value so the CGI can see them and send true results?
Thanks!!!
Calling Variable Scene
I'm trying to call a scene dynamically, like this:
Scene_Name = "2";
gotoAndPlay (Scene_Name, 2);
But keep getting this message:
"Scene name must be quoted string"
Any ideas, kiddos? Thanks in advance!
How To Write A Variable Down In A Txt By Calling The Cgi
Hi,
I made a text field and seted its variable name as "guest". I want anyone can write his name in the text field and press a saving button to store it. Then, I can look the visiter name in order on the txt file.
Does anyone know how to make a cgi to store it in a txt.
Under poor description, I hope you know what's my problem.
Thank you for reading this post!!!
Calling External Variable..
Hi.. I really need some help please..
I am loading a variable from an external text file, the variable is called text. I can set this as the variable for a dynamic text field and it will work ok, but I can't access it elsewhere. I want to access it in a for loop like so and find it's length:
for (i=1; i < length(_root.text); i++)
but it won't access it, let alone find it's length..
I can't even assign a variable like
test = _root.text or test = _level0.text , this is on the 1st frame of the main scene so I don't see why there should be any problems.. any ideas?
Any help would be really appreciated..
Thanks
Calling A Frankensteined Variable
I have a variable I create like so:
Code:
set("note" + _root.noteID, _root.noteWindow.noteField);
and I know that it creates the variable properly becuase I can use a trace command and plug in the variable it creates and trace what I need, noteField, back alright. But when I use a trace command like so:
trace("note" + _root.noteID)
I just get back note1 (1 being what noteID is equal to) not what I want back which is the noteField variable. Any idea on how to signify that what I am creating is a variable and not a string?
[Edited by skierbit on 07-09-2002 at 06:22 PM]
Calling Functions From A Variable?
how do i call a function from a variable?????????
i want to call a function through a variable named"mode"
the function will change depending on which btn is pressed.
my function works fine but when i try to call it through the variable it does not work!!!! how do i do it
i establish the function
a button then defines "mode"
another btn triggers mode
this doesn't work.....why
//function1
function songplay(){ code}
//function2
function songcycle(){ code}
//mode btn 1
on (release) {
mode=function(){
songplay
}
}
//mode btn 2
on (release) {
mode=function(){
songcycle
}
}
//apply btn...is this right?
on (release) {
mode
}
Calling Functions With A Variable
Hi,
Is there any way to call a function whose name is returned by a variable.
say for example if u have three functions
function function1(){
trace("function 1");
};
function function2(){
trace("function 2");
};
function function3(){
trace("function 3");
};
and there is a variable x whose values will be "function1","function2","function3"
the question is ..... is it possible to execute the function by value x
like call(x); or something of that sort.
Please get back ASAP.
Regards
Venkat
Calling Variable Problem
Hi, I can't figure this one out:
Code:
slideInSpeed = 15
slideOutSpeed = 3
_level0.T1.startX= 240; _level0.T1.startY= 5;
_level0.T2startX= 360; _level0.T2.startY= 80;
--etc.--
mokbtn.onRelease = function(){
T1.enlargeTo(125,10,460,280,51,slideInSpeed,T1);
BSX = (Big+"startX")
Big.shrinkTo(BSX,Big.startY,75,45,21,slideOutSpeed,T2);
trace("Big_btn: "+Big);
trace("BSX: "+BSX);
trace("T2startX: "+ T2startX);
trace("var: " + ((Big+"startX")))
}
The problem is getting the right number in the bold section.
Big is a variable given to me by another function, basicly T1, T2, T3 etc.
Running this function gives me the following trace:
Code:
Big: _level0.T2
Big_btn: _level0.T2
BSX: _level0.T2startX
T2startX: 360
var: _level0.T2startX
I want it to say " 360" and not " _level0.T2startX ".
Please, Help (mouse-like frustated screaming voice )
Papermouse
Calling Variable In Txt File
I am creating a calendar and on a button click I want to call a variable in an external text file. For example:
01/01/05 button will retrieve data in
"canendar.txt"
from the
var010105 = this information
Any thoughts?
Calling An Instance Name Via A Variable...
Is it possible to call an instance of a movie clip on the main timeline through a variable? I thought this was possible, but it's not working. Here's what I have:
I have a movie clip on the main timeline with an instance name of "myMovie1".
In another part of my movie I call to it like this:
myInstance = "myMovie1";
_root.myInstance.gotoAndStop("myFrameLabel");
But this doesn't work.
If i replace the code to this:
_root.myMovie1.gotoAndStop("myFrameLabel");
THEN IT WORKS FINE...
Anybody know how to call an instance name through a variable???
Thanks!
Josiah
Trouble Calling A Variable
Hi,
I have a little problem, it is kind of hard to explain. What I need to do is place in a var the contents of another var on a different movie level. I will paste the code to show you what I mean:
test = _level0.main_content.aquisitions.aquisitionsCanvas .aquisition1.info;
I need to put the contents of the var info into the var test. The above example does work, but the problem is that where you see the number “1”, that is not a fixed number, it needs to be called from another var called “McNumber”. This is where I get stuck… I will type it again almost like I am typing out aloud to show you what I mean:
test = _level0.main_content.aquisitions.aquisitionsCanvas .aquisitionMcNumber.info;
As you can see I need to insert the number to make it work, but cannot work out how to do it.
Hope that makes sense, if it doesn’t then ill try and explain in more detail.
Thanks,
Ritchie
Problem Calling A Variable From PHP
I'm calling a couple of variables from a php page and one seems to be working fine, the other one isn't. Very stumped at this point. I hard-coded an output from the database in an "echo" statement to test the fla. Only my "unitPrice" variable is getting processed. The "ChkBx" variable isn't. When the "ChkBx" variable is equal to "1", the background should change to red. And when it's equal to "anything else" it should be gold. As stated earlier, the "unitPrice" variable is working and the prices are being process to the fla.
Can anyone help me out here? If you need more explaination (as I know this is kind of vague), please let me know. Attached are the fla and php files.
Thanks in advance.
Calling Variable While Preloading
hi
I want to preload a movie. that's working so far.
I built in a kind of a lock, where you have to enter the right digits, bevor you continue e.g. the loaded movie starts to play. This means, I'm preloading a external swf - while the user can enter the code. Easy so far. Now I don't get where to put the "if k==4" statement, which will allow the user to pass to the laoded movie.
Here's the files:
www.sirus.ch/external.fla
www.sirus.ch/preloader.fla
and i followed this tutorial to build the preloader:
http://www.webwasp.co.uk/tutorials/b...SWFs/index.php
Any help is apreciated..
Sirus
Calling Functions Using A Variable
Hello there,
I've been searching the internet for if this is possible. I want to do something like this:
---
function Fred()
{
trace ("hello");
}
var Jim:String = "Fred";
this[Jim]() //I am trying to call the function Fred using this variable
---
I want to do this so I can call the correct function out of lots of functions, by changing a variable. Yes, I know there's a long way of 'if (Jim == "Fred"){ Fred() } else if (Jim == "blahblah) then call another function etc...but if there are lots of functions it gets quite long.
Thank you!
Problem Calling Variable
I can't seem to write the syntax correct. Here's the code:
ActionScript Code:
init();
moveIn(plate1, 118.6);
var btnCounter:Number = 1;
//--Buttons -- I want to be moveIn(plate1, -550), but it won't work!
nextBtn.onRelease = function() {
moveIn("plate" + _root.btnCounter, -550);
_root.btnCounter++;
}
function init() {
btnCounter = 1;
easing = 0.25;
plate1._alpha = 100;
plate1._x = 872.3;
}
Anyone? Bueller?
Calling Variable From One Movie To Another
Can we refer a variable inside another movie from my main movie.
1) I have first movie with variables declared for ex:
var color = "mycolor";
2) I have a second movie - I am loading the first movie inside the second and if I assign this a text field does it work.
_root.mytext.text = color;
Like this it is not working so any possible way
Calling An Instance Name Using A Variable
Hello,
Does anyone know how to call an instance name using a variable?
Example the below works fine
tellTarget ("_root.mc_lift") {
gotoAndStop ("1");
}
but if i change it to a variable as follows it calls the frame number as opposed to the imstance name of where i want that movie clip to start.
var floor = "1"
tellTarget ("_root.mc_lift") {
gotoAndStop (floor);
}
Thanks,
Martin
Calling Constructor By Variable Name
Hi all
First time post, hope you can help with this.
I have 4 images with have linked to actionscript i.e. image1, image2 etc...
I can handle this via
var img1:image1 = new image1();
etc......
I was wondering if possible to loop it i.e.
Code:
for (var i:Number=1; i<5; i++) {
this["img"+i] = new "image"+i();
}
Can anyone tell me if it possible, the bit that does not work I have found out is the new "image"+i(); part.
Hope you can help, and I have made myself clear.
Regards
Wayne
Holiday Rentals
Calling Function With Variable Name
Hi guys,
I'm trying to call functions through variable names so that they execute different tasks when a specific button is pressed.
My buttons are named "b2" to "b7" and the code is placed on the first frame of the movie clip containing the buttons, when I trace(this._name+"exec") it gives me the name of the functions but when I use it to call them it doesn't work. Must be simple to solve, would appreciate your help!
Here's the code:
for (var i = 1; i<8; i++) {
this["b"+i].onRelease = function() {
this._name+"exec"();
};
function b2exec() {
_root.contents.yMove = -4060;
};
function b3exec() {
_root.contents.yMove = -3480;
};
function b4exec() {
_root.contents.yMove = -2900;
};
function b5exec() {
_root.contents.yMove = -2320;
};
function b6exec() {
_root.contents.yMove = -1740;
};
function b7exec() {
_root.contents.yMove = -4640;
};
Calling Variable To Set A Frame Of An Mc
I have a variable declared in my object tag...
now I want that variable to be called to make an mc (button) gotoAndStop on a frame.
How is this done? I seem to have a glitch
Thx
Calling Variable Set In Scene 1
apologies for the repost/redo but previous did not work as I thought it did!
I'm working with Scene 1 with 2 buttons, "Corporate" and "Editorial" and a movie clip, mcMainScreenArea. I want the buttons to set a variable which can be called in movie clip mcMainScreenArea. This variable is then used in mcMainScreenArea (and later also in another movie clip) to move the timeline along to a label string set in the variable by the buttons in Scene 1.
With the following scripts the mcMainScreenArea simply plays the timeline to the next clip - the variable does not appear to be defined and a trace(this.varSubject); in the code returns "undefined".
Code for Scene 1 is as follows.
stop();
//Navigation variables
var varSubject:String = "opening";
gotoAndStop(varSubject);
trace(varSubject);
function moveToCorporate(event:MouseEvent):void {
var varSubject:String = "corporate";
gotoAndStop(varSubject);
this.mcMainScreenArea.play();
trace(varSubject);
}
btn_corporate.addEventListener(MouseEvent.CLICK, moveToCorporate);
function moveToEditorial(event:MouseEvent):void {
var varSubject:String = "editorial";
gotoAndStop(varSubject);
this.mcMainScreenArea.play();
trace(varSubject);
}
btn_editorial.addEventListener(MouseEvent.CLICK, moveToEditorial);
The code for mcMainScreenArea is
stop(); //at labels named "corporate" and "editorial"
//and
gotoAndPlay(this.varSubject); //after the labels named "corporate" and "editorial"
Calling A Function With A Variable
I'm just getting the hang of AS2 OOP, after avoiding it for all this time, and I have set up my first couple of classes.
One class generates an array, and the other class takes this array, and uses it it to place MC's on the screen, and gives each mc an onEnterFrame function. I have a stack of these onEnterFrame functions, named 'avoidIt1()-avoidIt11()'
I want to choose the function randomly, at runtime. Is this possible?
here is a snippet of code from it: (I can't attach the whole thing, I'm at work, and I left a rather major section of the code at home.)
Code:
this.createEmptyMovieClip("block"+n,200+n);
var tt:MovieClip = this["block"+n];
if (targetarray[row][col]){
tt.beginFill(cl1);
} else {
//delete tt;
tt.beginFill(cl2);
}
tt.moveTo(-50,-50);
tt.lineTo(50,-50);
tt.lineTo(50,50);
tt.lineTo(-50,50);
tt.endFill();
tt._xscale = bsize;
tt._yscale = bsize;
tt.myscale = bsize;
tt._x = ax + gap*col;
tt._y = ay + gap*row;
tt.homeX = ax + gap*col;
tt.homeY = ay + gap*row;
tt.avoidIt8(); // this is where I need to bring in a random function
n++
I tried:
Code:
tt["avoidIt"+rnd_number+"()"];
But I guess that's just for referencing objects.
I'm sure it's just a syntax thing I haven't seen before, but I'm having the devil's own job trying to find out what it is.
Either that, or I'm going about this the wrong way.
Another solution I had was to use a great long CASE list, but this seems a bit messy.
Anyone have any ideas?
Calling A Function With A Variable
hi,
ny1 got a clue how to call a function with a variable in the name?
e.g.:
function CallMyFunction (cmd) {
eval(cmd);
}
CallMyFunction("trace("Hey!");");
this doesnt work; but perhaps someone knows how to get this to work.
GuZ
Calling Function Using Variable?
Is it possible to call a function using a variable name?
ActionScript Code:
function catClicked(categoryID:Number) {
//get section name from xml
var sSection:String = node[0].childNodes[categoryID].attributes.name;
trace("section: " + sSection);
//appending parentheses to
var sSectionName = sSection + "(" + categoryID + ");";
//somehow call the function using the variable?
sSectionName;
}
function section1(categoryID:Number){
//stuff happens...
};
function section2(categoryID:Number){
//other stuff happens...
};
//etc.
Obviously this doesn't work, but it would be really handy to be able to do... or maybe this is a dumb way of approaching it?
thanks!
Check Variable Problem
I have the following code
on (press) {
if((loginfirstname == null) || (loginsurname == null)){ _root.msgbox._visible = 1; _root.msgbox.gotoAndStop(55);} else{
loadVariables("file://c:/"+ loginsurname+".txt", _root.login); if(varloaded != "ok"){ _root.msgbox._visible = 1; _root.msgbox.gotoAndStop(60);} } }
When I enter a name that does not exist and press the resume button The msgbox becomes visible just like I want
I click the ok button and the msgbox becomes invisible.
I enter the correct name,press the resume button and it takes me to the frame I wanted to go(saved in the previous session as next one) but the msgbox pops up as well.
Why would that be?
Text Variable Check..? How To Do So?
hi,, I load a textfile with loadVariables(cool.txt,0);
..supoosing the variable in cool.txt is: value=ok
now if I want to check if the value is correct how do I do it? ex:
if (value=="ok") {
//blah blah
} else { //no blah blah..
}
does this work?
How Can I Check To See If A Variable Has Loaded?
Hello lovely flash people:
I have a question for you:
I am working on a form (eeek) and I need to create a thank you page, so when the user hits submit, it loads the variable (ASP file) and then checks to see whether the variable has been loaded and if it has then the user goes to the nextframe, with all the thank you stuff.
For the life of me, I have tried everything and I wish I was an actionscript wizard but (boo hoo) I am not(yet) so I need to pick your expert brains. Here is the code on the submit button:
on (press, release, keyPress "<Enter>")
loadVariables("http://64.50.149.196/EmailGen/SendEmail.asp", "", "POST");
EMAIL_FORMNAME = "BNI Contact Form";
EMAIL_TO = "welcome@9th.com";
EMAIL_SUBJECT = "BNI Contact Form"
}
}
I don't know how to check to see if it has loaded. I know, I need to somehow stop the movie and then do the checking and then go to the thank you page but it is really hurting my head, everything works but I need to redirect the user:
PLEASE, PLEASE, HELP ME. I am soooooooo close to finishing it!!! Thanks, and I owe you in advance. Have a great weekend all, and don't work too hard!!
How Do I Check The Existence Of A Variable?
Hi
How can I check whether my variable exists?
The deal is that the variable does not exist at all inside the swf, but is created when the page linking to the page that contains the swf passes both variable and value to the swf page via the url.
I've tried to check if variable == "" (nothing) but this doesn't seem to be working:
if (_root.source == "") {
displayfield = "MOVIE LOAD ERROR";
stop();
}
Basically I'm going to display a 'movie load error' message if no variable is passed (because the user opened the swf page directly). I can't define _root.source before I check it's value, because this would wipe the value obtained from the url (via javascript in the embed code).
Any tips?
Thanks
k!d
How To Check If Variable Is Numeric
in php we have a function called is_numeric(); ...this checks if the string is numeric or alphanumeric. what is ActionScript's alternative function similar to this?
Tea
Check Variable Through Loop
I have a loop that is check to see if three variables are true if so then play animation.
The problem with my code is it triggers the animation if one out of the three is =true; when it should check if all three are true then and only then should it play the animation
Code:
function loopShowsAnim() {
for (var i = 0; i < plantArr.length; i++) {
if (plantArr[i].deleted) {
trace("DELETED = "+plantArr[i].deleted);
animation.gotoAndPlay(1);
} else {
trace("ELse")
ranShowsAnim();
// ranShowsAnim calls the function again to see if all three variables called "deleted" are == true;
}
}
}
What happens is if one is ==true it plays the animation and also goes to the else statement which calls the function again.
I need to only play the animation if all three are true;
|