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




Re-evaluating IF/Else



Im very new to actionscript and need some help on this question. Sorry if its a pretty stupid question.

I need some help getting this piece of code to continually re-evaluate the if/else command after it hits that stop function in there but stop re-evaluating when the if command returns true.

code: if (_root._currentframe>45) {
_root.print.postersanim.play;
} else {
_root.print.postersanim.stop(15);
}

Thanks



FlashKit > Flash Help > Flash Newbies
Posted on: 12-07-2004, 09:20 AM


View Complete Forum Thread with Replies

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

Evaluating Properties
hi,

i'm making a symbol rotate by using the setproperty function on a 3 frame loop. When a button is pressed, it goes to the start of these 3 frames.

The first frame (5) has the following action script:
Set Variable: "rotation" = GetProperty ( "/menu",_rotation )

The second frame (6) has:
Set Property ("/menu", Rotation) = rotation+5

And the third (7) has the evaluating statement that's not working:
If (GetProperty ( "/menu", _rotation ) eq 45)
Go to and Stop (1)
Else
Go to and Play (5)
End If

When it goes to frame 5, it restarts the animation, when it goes to frame 1, it stops the symbol in the last position it was in.

The problem is, the evaluating script doesn't work so it just keeps on rotating it indefinitely. I'm using this script i saw in an open source movie, adapted slightly and used for a different purpose. Can anybody help?

thanks in advacnce.

Evaluating A Variable ?
OK. i have a list of variables. . .

color1 = 0xFF0500
color2 = 0xFF0A00
color3 = 0xFF0F00
color4 = 0xFF1400
color5 = 0xFF1900

later in the code I use this. . .
myColor.setRGB(eval(color + x));
and it does not work ?? it only works when I use the literal variable such as:
myColor.setRGB(color3);
which takes out all of the flexability ! what am I doing wrong ?? I have also triedd the && also, but not successfuly. . .

please help. . .

Darin

Evaluating Statements
I need to know if I can assign an action to a variable and then have the action completed in another clip.

For example: _level99.mapLink = "_level1.gotoAndPlay("frameName");";

Then on level 99 I would have to have some kind of statement that would run this code. I am not sure what it would be. I thought something like

eval(mapLink);

However I am not sure this is right. Does any know if I can even do something like this?

Thank you
-Adam

Evaluating A String?
Hi
I have a the following code that refers to a variable on _level0:

"_level0.imageName"+imagecall

were Imagecall= a number

I want to convert the string to display the variable?

(e.g. say imagecall=3 - would lead to...
_level0.imageName3

imageName3 on _level0=this is what I want to display


Many thanks
Oll

Evaluating Values
I'm trying to figure out the best way to evaluate a set of values. I have variables fv1 - fv12. Each of these variables has a value from 0 to 5. I want to evaluate the values, and depending on which two have the highest value, play a movie clip to an associated keyframe. Does anyone know the best way to go about this. I thought of a nested if then statement, but it seemed like it would be extemely long and inefficient. Any ideas? Thanks in advance,

Shawn

Evaluating Two Variables
I am having problems trying to evaluate two variables within an if statement. basically I am loading an external variable txt file that contains the variables answr0101 and choice. In level4 I load a movie clip that is trying to see if these two variables are equal. Just before I check for equality a button sets the _level0.choice variable to a new value.

on (release) {
_level0.choice = "A";
gotoAndPlay("test");
}

then at the frame test I check for equality.
if (_level0.choice == _level0.answr0101) {
gotoAndPlay("correct");
} else {
gotoAndPlay("incorrect");
}

This did not seem to work and then acording to various source I tried to use the eval function to compare two variables.

if (eval(_level0.choice) == eval(_level0.answr0101)) {
gotoAndPlay("correct");
} else {
gotoAndPlay("incorrect");
}

For some reason this is always returning a value of true even if the values are different.

I then tried to put the two variables into an array and this as well always returned a value of true.

result=newArray(_level0.choice, _level0.answer0101);
if (result[0] == result[1]) {
gotoAndPlay("correct");
} else {
gotoAndPlay("incorrect");
}

So, I am bafled at this point. If anyone has any suggestions on this I would greatly appreciate it.

Thanks
R

Evaluating Code...
I'm not sure if this is the right place for this question, but I was wondering if it is possible to type code into an input box, and then have that code evaluated.(So if you were in the test .swf in Flash MX and you typed trace("test") into the box it would trace "test". once you hit another button to do the code)
Hope you can understand my question, thanks!

Evaluating Strings
I'm creating a file that searches through a database...all i need to know is how to create actionscript that will evaluate inputted data with information in an array. .

if (CourseNameArray[i] eq _root.keyword) {
_root.SearchCourseName = CourseNameArray[i];
}

I know the code above will only work if the exact "keyword" information is added, but i need it so if someone types in "Content" and the CourseNameArray[i] value is "Content Management System" then it will evaluate as true.

Is there anyway to evaluate strings like this?

[F8] Evaluating XML Data
Hello,

I'm running into a problem evaluating XML data. I've created a small scale version of the issue for illustration.

I'm bringing in XML data, and would like to do a simple "if" statement that evaluates the content of the XML file being parsed. In this instance, I'm simply trying to trace "Success!" if the node's value is "Value". When I trace the node value, it comes back "Value", but for some reason the "if" statement is still not returning true.

I've been stuck on this for a couple of days and am really at the end of my rope (know the feeling?) I have a feeling it's something very obvious, but for the life of me I can't figure out why this isn't working. Can anyone offer any assistance?

I have a very simple XML file with this layout:


Code:
<ITEM>
<ASSET>Value</ASSET>
</ITEM>
And my Actionscript which brings the XML data in and evaluates it is:


Code:
// Create XML object
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;

my_xml.onLoad = function(success){

// If data loaded successfully
if (success){

a = my_xml.firstChild.firstChild.firstChild;

trace(a);

if(a == "Value"){
trace("Success!");
}

}
else{
trace("XML Failed to Load.");
}
}

// Path to XML file
my_xml.load("test.xml");
I'm also attaching a .zip file to this message with the .fla and .xml file, if anyone would like to try it out for themselves.

Again, thanks for any assistance you can offer!

Evaluating Two Ranges
Hello!
I have problems trying to figure how to interpret this condition into AS.
the Pseudo would look something like this:

a=5;b=1;c=10;
If ( A is inside B and C range) {
}




If anyone could please help me interpret this to AS
I'll apreciate it a lot.

Evaluating String.
Hi,
I'd like to know one thing, that could make my life much easier. I need to evalueate a string as code... let me show you an example...

Lets say, that I have a string:


ActionScript Code:
string = "Math.cos(var1)*Math.sin(var2)";


And what I need to do, it to use its contents as code and not string like here:


ActionScript Code:
var3 = Math.cos(var1)*Math.sin(var2);// but I need to use something like... I know(I think)// that eval is not useable in this casevar3 = eval(string)
Any help wil be appreciated.

For Loop Not Evaluating?
hello all,
my code is pretty straight forward. i can't get the 'if...then' statement to fire correctly. var t DOES equal "_level0.item" + sel at some point, as seen in my second code snippet, but the for loop doesn't ever see it and only the false code is executed.




Code:
_global.heck = function(sel) //sel will be a number sent from another function


{
for(var i=0; i<numOfItems; i++)
{
var t:MovieClip = home["item"+i];
if(t != "_level0.item" + sel)
{
**do something**;
}
else
{
**do something else**;
}
trace(t);
trace("_level0.item" + sel);
} // end



'home' is a var equal to '.this' which equates to '_level0'...hence my 'if...then' statement.

here is what happens in the looping. you can see that there is a match! the first line is the t var and directly beneath is '_level0.item' + sel




Code:
_level0.item0


_level0.item4

_level0.item1
_level0.item4
_level0.item2
_level0.item4
_level0.item3
_level0.item4
_level0.item4 <-- here is the 't' var
_level0.item4 <-- here is the 'sel' var - they match!!!
_level0.item5
_level0.item4
_level0.item6
_level0.item4
_level0.item7
_level0.item4
_level0.item8
_level0.item4
_level0.item9
_level0.item4




i can even hardcode a value: if(t == _level0.item6) and it'll work just fine but try using a variable and it doesn't do a thing!


thanks!

Evaluating A Variable To A MC Name
I'm trying to define a target using a variable name. For example, whenever a MC lands on spot "Hot", it sets a var = myname. I want to tell the nested movie ("prog") inside "myname" to go to the next frame.

This is what I have that isn't working:


Code:
on (press){
bag.myname.prog.gotoAndStop(5);
}
I've also had no luck with:


Code:
on (press){
bag.eval(myname).prog.gotoAndStop(5);
}
}

Evaluating A String
Hi
I was wondering if there was a way to have a variable hold a string such as:
var="movieClipname._visible=false";

and then later run something that evaluated that whole string.  What I am trying to do is some how capture what a user does (like dragging clips etc) by storing each action as a string and then evaluate the whole thing in order to "replay" what they did.  I looked at using eval() but that seems to only evaluate the movieClip and not the entire string.  Any thoughts????  I've totally hit a dead end.

thanks in advance :)

Evaluating Dates
i have the following strings: "3/11/2003 11:12:54" and "12/15/2003 8:59:06"

how can i evaluate only the date portion to determine if the first date is before the second date.

doest that make sense?

thanx for your help.

Evaluating Equations In Flash 5
So I have a math-related movie (a slope-field program, if you wanted to know) in which the user inputs an equation. Then, when they click a button, the movie goes through and evaluates the equation for x's and y's. It basically says:

for(y=ymin;y<=ymax;y=y+(ymax-ymin)/40) {
for(x=xmin;x<=xmax;x=x+(xmax-xmin)/40) {

//then, in here, i need it to evaluate the equation they put in. so they might've put in "5*Y + X". I need the movie to put the values of x and y into that string that they input and give me an answer (the answer to this particular one when x=1 and y=1 would be 6, for example).

}
}

i thought of using eval(equation); but that didn't work. can anyone help me?

thanks
justin
(www.justinhaaheim.com)

Evaluating Conditions Of A Loaded SWF/ Is It Possible?
OK this is what I want to know????????????????????????????????????????????

Is it possible to evaluate the "_currentframe" of an SWF I load into a blank movieClip placed on my _level0 timeline (I’m wanting to perform this action from _level0). If the evaluation brings a value of "true" I then want to perform a "gotoAndStop" action on another movieClip placed on my _root timeline. If this evaluation brings a value of "false" I want to move on and look at another condition with a "else if" action, also targeting (for evaluation) the SWF loaded into my blank movieClip.

Also, (considering this same scenario) Is it possible to control sound variables from this SWF (loaded into my blank movieClip) that lives on _level0.

How would the targeting script look???
How would I script an “if” statement (from _level0 targeting an SWF loaded into a blank movieClip also on _level0)?????

Help???

Evaluating _visibile In 4MCs
Hi all,

I'm creating a word-find activity. I have(eg)four MCs making up a word with initial visibility set to false, that when button is clicked, sets visibility to true. This part fine.

What I am trying to script, not at all successfully, is when the four MCs _visible == true, that it sets the visibility of another MC (line1, used as a strike through line on the word list) to true.

Not being an AS whiz, I've tried various ways, from setting a variable, myLine and attempting to concatenate the four MCs then use evaluate to set the visibility of line1 (on ClipEvent (mouseUp) to true, can get line showing, but not as result of the four clips together, it is if any one of them is clicked. Have also tried If statements.

Any advice?

Megs

Evaluating _currentframe In ONE Scene. HELP ME PLEASE
I got one question It might be easy.

How do you evaulate the number of frames in ONE scene

I set a variable like so

x = _currentframe;

Now I have two scenes.
One scene with 93 frames in it and that's the intro scene.
The following scene is called home with has 45 frames

I wanted the variable to start evaluating in the HOME scene.
When I set the variable in the home scene with this

x = _currentframe;

It evals the total frames played I think because I made a textbox to display the variable with dynamic text and it started on frame 94 which would be the next frame in the total movie. Because the first frame scene is 93 and the next frame played it 1 on the HOME scene. 93 + 1 = 1. obviously...

I want the _currentframe to equal 1 on the home scene.

CAN YOU GUYS PLEASE HELP ME OUT!

Eclypse_2025@hotmail.com

I have msn.......if sumone could help me.

Thanks.......

Evaluating String/array Help
I know I am doing this wrong...please help. In the following, the variable, _root.currentSection equals "mc_home" on the root. The value changes throughout the navigation.

I need to get the value from the following:
_root.mc_homebox_Xpositions[i]

The dynamic version would be something like this:
"_root."+_root.currentSection+"box_Xpositions" +"["+[i]+"]"

But what I get is the string and not the value:
_root.mc_homebox_Xpositions[1]

I tried this but it comes up undefined:
this["_root."+_root.currentSection+"box_Xpositions" +"["+[i]+"]"]

What am I doing wrong?

Thanks

A Question About Evaluating Variables
Good day! I'm trying at this point to figure out the process of taking two numerical variables fetched from an external document, total them and display them as a third variable. So far I've been able to come up with a nice handy NaN. Anyone know how to do this?

The Files in Question are here

Evaluating/executing A String
I was wondering if there was a way to have flash execute a string..

for example if I had a variable that stored a bunch of commands as a string like:
a="movieclip._visible=false"

I could at somepoint evaluate it and have the whole line executed. The reason I am doing this is because I want to record what people do by tracking actions in a variable, and then replay them by evaluating it - but the actions could be different every time so it needs to be dynamic. If there is another way to do this.. any help would be greatly appreciated!

Evaluating Expressions For HitTest
Hello, how do you evaluate expressions in Flash MX? I get an error with the following code:
if(this.hitTest(_root.["ball"+x])){
}

I know this worked in Flash 5, but how would you do this in MX 2004?

Evaluating Multiple Variables
I am trying to make a simple game where images are dragged into areas on a grid and if they are in the right order, the user wins.

I have set up my project so that that each grid cell sends a string value to a variable when a clip is dragged onto it, for example:

topleft = "trees";

Could someone please tell me how to set up an 'if' statement to check if multiple variables contain certain strings.

I have tried:

if ((topleft == "trees") and (topmiddle == "leaves") and (topright == "seeds")) {

also:

if ((topleft == "trees") && (topmiddle == "leaves") && (topright == "seeds")) {

but with no luck

maybe I am way off here; I am open to any suggestions.

Any takers?

Dynamically Evaluating Checkboxes
I have a movie that has 4 checkboxes. I want to change the color of some dynamic text that corresponds to each checkbox when each checkbox is turned on. (As if to show that the interface for that item is enabled or disabled when the checkbox is on or off)

I am having trouble figuring out how to dynamically determine which corresponding text field to change the color of. I get as far as to figure out which checkbox was checked, but can't get from there to changing the color of the corresponding text field.

Thanks for any insight, sorry if the code is shakey:

// Listen to see if checkboxes are turned on or off to activate categories
listenerObject = new Object();
listenerObject.click = function(eventObject){
updateContractText();
activateDeactivateMaterialCategories(eventObject);

}
shoes_activated_checkbox.addEventListener("click", listenerObject);
socks_activated_checkbox.addEventListener("click", listenerObject);
gloves_activated_checkbox.addEventListener("click" , listenerObject);
hats_activated_checkbox.addEventListener("click", listenerObject);

//Deal with checkoxes: -----------
function activateDeactivateMaterialCategories(eventObject) {
if (eventObject.target.selected==true) {
//HERE IS WHERE I NEED HELP:
//My dynamic text fields are named "shoes_label", "socks_label","gloves_label" and "hats_label"...so if the shoes_activated_checkbox gets turned on, I want the shoes_label's color to change.

}

Evaluating A String Variable
I am trying to loop through some text boxes I have named txtN0, txtN1, txtN2, etc. But I am at a loss of how to do so. I assigned cubeBox as a variable to hold a string named txtN0... but it doesnt seem to want to use it in _root.names_mc.cubeBox.htmlText. It ignores the line completely. Could someone give me some insight? Thanks!,
Mike


Code:
while (loopMe <= 40){ //Go through the text boxes and insert info
cubeBox = "txtCN" + loopMe; //Loop Cube Number textbox
nameBox = "txtN" + loopMe; //Loop Name textbox
//trace(cubeBox);
_root.names_mc.cubeBox.htmlText = info_array[loopMe];//Insert text
_root.names_mc.nameBox.htmlText = info_array[loopMe];//Insert text

_root.txtInt = 0;
loopMe++;
}

Evaluating Nothing In A Text Field
I have a textfield on stage that I have set focus on named noentry1

I want to write script that that will just go to frame #10 when the user presses the enter key.

I don't want the user to type anything in the textfield. if they do I want them to go to frame 20 where I can tell them they shouldn't have typed anything in the test field.

here's what I got so far.

Any help would be greatly appreciated.

code: on(keyPress "<Enter>"){
if(noentry1.text != " ");
gotoAndStop(10);
}

Thanks in advance

-Lemorris

[F8] Evaluating Layered Mcs As Text
I have a hierarchy of clips (a->b->c);
I want to access clip 'c' from 'a' directly.
I tried a["b.c"], but that doesn't work. I noticed a[b][c] works, but I can't use that as is because I need the "b.c" part to be in one string.

Generating And Evaluating A Function Name In AS2
I'm trying to figure out how to generate and then execute a function call within AS itself. Sort of AS writing its own code, only I'm having a hard time searching out a solution to my dilemma. (Apologies if this already exists elsewhere!)

Here's a simplified example:

Code:
//SETUP STUFF
var wrapperFunction = function(targetString:String)
{
//??? how to evaluate the building of the function name here
eval(this[targetString + "_doSomething();"]);
//???
}

var myString = "theTargetFunction"

var theTargetFunction_doSomething = function()
{
trace("successful execution");
}

/////////////////////////////////////
//EXECUTION STUFF

//so if I call:
wrapperFunction(myString);

//the result would be execution of the function
//theTargetFunction_doSomething
//tracing the output: "successful execution"
I'm really stuck on that line inside of wrapperFunction enclosed with ???. The current line doesn't work at all, and is just example to help explain what I'm trying to accomplish.

Ultimately, I want to have AS build the name of the function from pieces as a string, and then execute that franken-string.

Any ideas from the gallery?

~Brit

Evaluating A Boolean Expression
What I am trying to do is create a function that will test an array of boolean expressions. Here is the basic code that I will need to get working...

Is something like this possible? Coords[] is an array, of course, and Map is just a MC that moves around during the course of my program.


ActionScript Code:
function checkCoords(){
    coords[0] = "_root.map._x < 400";
    return eval(coords[0]);
}

I've also tried this:


ActionScript Code:
function checkCoords(){
    coords[0] = "_root.map._x < 400";
    if( eval(coords[0]) ){
        return true;
    }else{
        return false;
    }
}

Expression Not Evaluating Correctly
Hi,
I have three movie clips on my stage all are at y=388.9. In the actionscipt for the movie clips I have this statement...

if (this._y==388.9){
trace('something!');
}
else{
trace('nothing');
trace(this._y);
}
Output:
nothing
388.9

everytime this is run the expression results in false and 'nothing' and the y coordinate (388.9) print out.

Does anyone know why this expression evaluates to false even though this._y is 388.9?

I must be missing something. All the other movie clips at different y values evaluate correctly.

Thanks.

Question About Evaluating Expression
i'm trying to set up a loop that handles this:

for (X = 0; X<10;X++){
  _level0.buttonX.someValue = 10;
}

how can i execute that expression in the loop?


Evaluating An (external) Loaded Variable
I am trying to perform an "if" statement using a variable that is loaded from a .txt or XML file.
For example- if (color=="red"){gotoAndStop("somewhere");}
and the variable for color is pulled from a .txt file.

Thanks for the help!

Evaluating Radio Button Values
Greetings,

First of all, I would like to thank all the contributors of this board. I dont know where we would stand without your help.

Because I am a VB.net developer, I find the syntax of flash a bit confusing.

I have a series of radio buttoms, all part of the same group name.

I would like a button to act a certain way if a specific radio button is selected. This would involve an "if then" nesting in VB, but not sure how to put this in flash scripting.

For example:

radio buttom 1: (.)ON
radio buttom 2: ( )OFF

by pressing the a buttom next to it, "hello world" would be displayed on a txt box because the on radio button's state is checked.

Thank you for your help.

Getting Bytes Total By Evaluating An Expression
Hello,
I have an expression with a variable in it (StoLoadIn) that evaluates to 1 or 2. This variable exists on the _root and switches the focus of my getBytesTotal() from one movie clip to another (splash1_mc and splash2_mc)

I want to be able to ultimately call a getBytesTotal() like this hard coded example:

_root.splash2_mc.getBytesTotal()

If I put in the "StoLoadIn" variable, I need to write the call like:

"_root.element" + _root.EtoLoadIn + "_mc.getBytesTotal()"

If I trace this, it returns exactly what I have written above: _root.splash2_mc.getBytesTotal()

If I put an eval around this as in:

eval("_root.element" + _root.EtoLoadIn + "_mc.getBytesTotal()"),
it returns "undefined".

How can I write this so this expression returns the total bytes like the hard coded example I have written above does?

Thanks in advance,
Damien

Array Comparison Not Evaluating Correctly
I need a new pair of eyes on this...Can someone tell me why the if statement isn't evaluating correctly in the code below.

Copy and paste the code below into the first layer of a new document and then run it. The list[0] value is 4,5,6. So is the roll_value. However when I compare the two below, Flash doesn't go down the expected path...p.s. the expected outcome is Instant Winner.
-----------------------------
//roll ranking array
var pair = [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];
var r01 = [4,5,6];
var r02 = [6,6,6];
var r03 = [5,5,5];
var r04 = [4,4,4];
var r05 = [3,3,3];
var r06 = [2,2,2];
var r07 = [1,1,1];
var r08 = [6,pair];
var r09 = [5,pair];
var r10 = [4,pair];
var r11 = [3,pair];
var r12 = [2,pair];
var r13 = [1,pair];
var r14 = [1,2,3];
var list = [r01,r02,r03,r04,r05,r06,r08,r09,r10,r11,r12,r13,r1 4];

//dice setup
var d1 = [1,2,3,4,5,6]; //establish array for each die
var d2 = [1,2,3,4,5,6]; //establish array for each die
var d3 = [1,2,3,4,5,6]; //establish array for each die
var dice = [d1,d2,d3];//create a dice array holding 3 die

//roll the dice randomly
//roll_value_0 = dice[0][Math.floor(Math.random()*6)];
//roll_value_1 = dice[1][Math.floor(Math.random()*6)];
//roll_value_2 = dice[2][Math.floor(Math.random()*6)];

//hard-coded values
roll_value_0 = dice[0][3];
roll_value_1 = dice[1][4];
roll_value_2 = dice[2][5];

//display results
trace("You got "+roll_value_0+roll_value_1+roll_value_2);

//place the roll result into its own variable
var roll_value = [roll_value_0,roll_value_1,roll_value_2];

//Compare roll with list
if(roll_value==list[0]){
trace("Instant Winner!");
break;
}else {
trace("Keep rolling!");
trace("roll_value = "+roll_value);
trace("List Value = "+list[0]);
}

trace("------------");

Evaluating A String As Math (Flash 6/MX)?
Say that I have a variable (x) that is set to the string "7*6+4". Is there a way to evaluate that equation as math and hence do something like:

if (checkTheMath(x) == 46) {
doThing ();
}

Originally I thought that this was what eval() was for, but I've since come to understand that it's more of an array tool.

Any help would be appreciated.

Evaluating String As A Movie Clip's Name
Hi, need help:
On the stage i've a movieclip called, let's say "pippo", and I want to use it but i don't want to call it "pippo" but i want to read its name from xml and then i want flash to understand that the string "pippo" is a movieclip. does anyone out there know how to do it?

i already learned that i can not do something like "myxml.firstchild.firstchild.attributes.name._ x = 0;" where "name" is the name of the istance i want to move...

please, help

Evaluating A Variable - Convert To String?
Hopefully someone can help here, it should be pretty simple. I have several buttons, when pressed they create a variable eg

buttonPressed=2;

This value is passed to the function eg

runFunction (buttonPressed)

All this is working fine. I then want to set the x and y coordinates using the number stored in the buttonPressed variable eg.

X=[button+"buttonPressed"]._x;

this doesn't work but I want the above statement to evaluate to

X=button2._x

I have also tried X=["button"+String(buttonPressed)]._x; but this isn't working either

Any suggestions??

Evaluating Textfield.htmlText Content
Hi,

I have this script :

// TRYING TO CHECK TEXTFIELD'S HTML CONTENT VIA ITS INSTANCE (INSTEAD OF ITS VARIABLE)
//
// Terms :
// myTextField ........ instance name of a text field.

myWords = "<b>Hello there</b>";
myTextField.htmlText = myWords;
this.onEnterFrame = function() {
if (myTextField.htmlText == myWords) {
return true;
} else {
return false;
}
};

How to evaluate if the textfield's html content really match with the variable "myWords" ? It is not a problem if it goes this way :

myWords = "Hello there";
myTextField.text = myWords;
this.onEnterFrame = function() {
if (myTextField.text == myWords) {
return true;
} else {
return false;
}
};

Weird Results Evaluating Variable
I know my SWF file is recognizing variables from a remote file, but I can't get Action Script to do anything based on their values.

Here's what's happening: I have a questionnaire with several pages in HTML. Using PHP I can write variables to a text file. I've figured out how to get the variables into the SWF file and I've placed dynamic text boxes in the file so that I know the variables are being recognized. For example, when a user completes "Part A" of the questionnaire, a dynamic text box for Part A shows the value "a".

So you'd think if I just wrote a script saying if the variable equals "a" then a movie should have its alpha set to 100, or:
if(parta=="a"){
setProperty(this.partacheckbox, _alpha, 100);
}
But for the life of me I can't get it to work.

I've tried everything I can think of including initializing the variable with: var parta:String = "x"; but I can't seem to get anywhere.

I've done this sort of thing elsewhere in the file and I'm using exactly the same action script, but no success. I've tried changing variable names in cas that interferes, but still no success.

I've spend six hours trying to get this to work and would be glad to pay for a solution except the job I'm doing is voluntary.

Thanks for any help.

Help - Evaluating Variables Loaded From An External File
Aghh,

I'm sure this is something simple:

loadVariables ("navdata/mainNav.txt", 0);

text file contains: mainItem2=POP

if (this[mainItem2] == POP) {
gotcha = this[mainItem2];
trace ("gotcha="+gotcha);
}

The IF statement runs, so you would think that the variable 'gotcha' would
be set as equal to 'POP' - but it isn't...

How do I return the values of variables loaded from an external file?

(hair falling out in clumps)

[Edited by mrming on 02-11-2002 at 08:18 PM]

Evaluating Dynamic Text Loaded As Html
I am using Flash-MX to load text from a .txt file that has a list of different dates of events to a dynamic text box with text rendered as html. What I am wanting it to do is evaluate if the date of the event has passed or not. The past events I want to appear ghosted, the most current event that has not passed I want to be in red text and all the subsquent events that have yet to pass I want to appear in black text. Some of the events are also hypelinks to make it more complicated. I'm not sure if I have to load each event in a seperate variable, I'm guessing I will, but not sure how to make Flash read the string and interpret the date so it can evaluate it.

URGENT: Issue With If Statement Evaluating Unexpectingly
The following code is for a tab navigation. When you rollover the tab it slides out a little. When you rollout the tab slides back in. When you click on the tab it's suppose to stay slide out and then a logo fades in.

The following code is what I use. The problem is the if statements is returning true all the time for some reason. Even after clicking on the tab.


Code:
this.nav.contact_btn.onPress = function() {
nav.contact_btn.gotoAndPlay("_selectstate");
_global.curFrame = "contact";
_root.gotoAndStop(7);
}
if (curFrame != "contact") {
this.nav.contact_btn.onRollOver = function() { nav.contact_btn.gotoAndPlay("_overstate"); }
this.nav.contact_btn.onRollOut = function() { nav.contact_btn.gotoAndPlay("_outstate"); }
}
The onPress function simply makes the logo appear and then sets a global variable called curFrame and sets the value to "contact". The if statement then checks curFrame and if it's not equal to "contact" it will display the onRollOver and onRollOut animations. And if it returns false it should skip the onRollOver and onRollOut parts, but it doesn't.

Any help is appreciated.

NOTE: I also tried "curFrame <> "contact".. but didn't work.

Evaluating Math And Outputting Results To A Text Box
Howdy, im new to flash (although, i only have access to flash 5 ) and was wondering how I evaulate math in action script and have the result print on screen somewhere like a text box? I dont want results in the output box, i want it contained within the movie

Thanks!

Evaluating A Text Input Field On Button Click
can anyone tell me why the following code wouldn't be working? this is on a button, so that the input would be evaluated and a certain msg would appear when the button is clicked.


Code:
on (release) {
if ((inputName = "this") || (inputName = "that")) {
msg = "msg1";
} else {
msg = "msg2";
}
}
help?

Passing Session Variable To FLASH, Evaluating, Then Altering The Session
I started a thread in the sounds and audio section and got some good suggestions from hp3 (mod) there. He suggested I move my questions here...

the task: read 2 session variables into FLASH, evaluate them in an if loop of some kind, and be able to rewrite the session variable with an onClick even for a button.

I want to be able to control the "state" of a soundtrack in a site that uses FLASH just as the navigation. I have the sound track built and the on off controls work fine (loads and unloads the movie to layer 1). The problem is that when you move fron HTML page to HTML page, your choices don't persist.

Every page in the site is ASP/VBSCRIPT, so using a Session variable is not a problem. I just need to know HOW.

I was told I need to pass the varible in through the embed src tag:

<embed src="controlpanel.swf?VAR1=VAL1&VAR2=VAL2" loop="false" etc etc

actually...

<embed src="controlpanel.swf?STATE=<%=Session("STATE")%>& TRACK=<%=Session("TRACK")%>" loop="false" etc etc

sound right so far? OK..easy enough. Now how do I read that querystring value into a FLASH AND then how do I evaluate it?

Is it as simple as Request.Querystring("STATE")?

FlashVariable1 = Request.Querystring("STATE")

Is there some loadvarible method for doing this? In the end, I want the first frame of the movie to do this:

1. get the variables STATE & TRACK from the embem src tag
2. evaluate the variables and do accordingly:

if FlashVariable1 = "ON" then
if FlashVariable2 = 1 then
load track1.swf into layer 1
else if FlashVariable2 = 2 then
load track2.swf into layer 2
else don't play the music
end if

3. when the user clicks the off button or selects a different track, write that back to the server side session variable:

onclick
unloadmovie from level 1 (killing the audio)
set Session("VAR1") = "OFF"

or for track selection...

onclick
loadmovie trackX.swf into layer 1
set Session("VAR1") = "ON"
set Session("VAR2") = "TRACK2"

Then, when the user moves to the next HTML (actually ASP) page, the embed tag uses the new session variable values and passes them into FLASH so that they can be evaluate once more.

Sound right? now HOW? That's the question. Your help is SUPREMELY appreciated!!

Thanks all

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