Help Trouble With OR Operator In If Statement
I'm trying to check to see if all the other movieclips on the stage are on frame 1. If they are, then on release of this button go to and stop on frame 2 of a specified movieclip. If any of the conditions in the if statement are false (any of the movieclips are not on frame 1) then I want to send all of the movieclips on the stage to frame 1 and then send the specified movieclip to frame 2. The code that I am using is below. I have placed this code on the instance of the button and all the movieclips and button are on the main stage. Please tell me why it's not working!!! Code: on (release) { if (polPlan_mc._currentframe == 1 || baseDB_mc._currentframe == 1 || polNum_mc._currentframe == 1 || paidTo_mc._currentframe == 1) { insured_mc.gotoAndStop(2); } else { polPlan_mc.gotoAndStop(1); polNum_mc.gotoAndStop(1); baseDB_mc.gotoAndStop(1); paidTo_mc.gotoAndStop(1); insured_mc.gotoAndStop(2); }}
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 05-18-2005, 04:15 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help Trouble With OR Operator In If Statement
I'm trying to check to see if all the other movieclips on the stage are on frame 1. If they are, then on release of this button go to and stop on frame 2 of a specified movieclip. If any of the conditions in the if statement are false (any of the movieclips are not on frame 1) then I want to send all of the movieclips on the stage to frame 1 and then send the specified movieclip to frame 2. The code that I am using is below. I have placed this code on the instance of the button and all the movieclips and button are on the main stage.
Please tell me why it's not working!!!
Code:
on (release) {
if (polPlan_mc._currentframe == 1 || baseDB_mc._currentframe == 1 || polNum_mc._currentframe == 1 || paidTo_mc._currentframe == 1) {
insured_mc.gotoAndStop(2);
} else {
polPlan_mc.gotoAndStop(1);
polNum_mc.gotoAndStop(1);
baseDB_mc.gotoAndStop(1);
paidTo_mc.gotoAndStop(1);
insured_mc.gotoAndStop(2);
}
}
Trouble With Xml And If Statement
I'm having a slight problem with flash and xml.
I got a movieclip which is attached to the stage with a "for" loop, depending on the number of nodes in the xml file.
Then I have a nodeValue variable, which takes the values of all nodes in the xml.
ActionScript Code:
for (i=0; i<this.firstChild.childNodes.length; i++) {
btn_mc = container_mc.attachMovie("btn", "btn"+i, i);
btn_mc.bg.loadMovie("graphics/bg_thumbnail.png");
btn_mc._x = 30+Math.floor(i/rows)*110;
btn_mc._y = 80+i%rows*120;
details = this.firstChild.childNodes[i].childNodes.length;
for (j=0; j<details; j++) {
this.nodeValue = obj.products[i].childNodes[j].firstChild.nodeValue;
info = obj.products[i].childNodes[j].nodeName;
if (info == "typ") {
btn_mc.desc.text = this.nodeValue;
}
}
}
And then the problem occurs:
I have an if statement -directly below the above code -, where I'm trying to say that if none of the nodes a value of X (lets say poster) has, then decrease the alpha of a button in the navigation to 40. But even if one of them has this value, then don't do anything.
ActionScript Code:
if (this.nodeValue !="poster") {
mc._alpha = 40;
}
Any clues?
// next time xml with as3!
Trouble With If/else Statement
I'm trying to right some script that says when a user rolls over this button it should go to the 2nd frame (visible, 1st frame is empty) of a particular movieclip. But I want to be sure that none of the other movieclips on the stage are showing, so I wrote this if/else statement to say that if the currentframe of the other movieclip is 1 (not showing) then go stop on the 2nd frame of this movieclip. If not, go stop on frame 1 of the other movieclip and then go stop on frame 2 of this movie clip. Here is the code below. Someone please tell me why it's not working. I have the code on the instance of the button. The button and both movie clips are on the main stage.
on (rollOver) {
if (_root.insured_mc._currentframe=1) {
polNum_mc.gotoAndStop(2);
} else {
_root.insured_mc.gotoAndStop(1);
polNum_mc.gotoAndStop(2);
}
}
When I publish the SWF, i make sure that insured_mc is on frame 2, to test the code, then I rollover the button in question and polNum_mc goes to the 2nd frame too, but insured_mc doesn't turn off (go to frame 1).
Trouble Using _x In A If Statement
what i want to do is have a movie play i.e a rectangle move to point x from y at the click of a button, and at the click of another button, the rectangle should move from point x to point y; when the movie returns to point y, another frame should be loaded.
for example, check the following codes:
on frame 1:
stop;
butt.onRelease = function () {
gotoAndStop (2)
}
//butt is a instance name for a button//
on frame 2:
stop;
EndX = 200;
FinalX = 10;
mc.onEnterFrame = function () {
mc._x += (EndX - mc._x)/10;
}
butt.onRelease = function () {
mc._x += (FinalX - mc._x)/10;
if (mc._x == FinalX) {
gotoAndStop (3)
}
}
// mc is an instance name for a movieclip //
the movie will play forth and back but frame 3 will never come up; PLEASE IF YOU CAN HELP ME FIX THIS CODE I BEG YOU.
If Statement Trouble
Hi folks!
I thought this was going to be straight forward....
I have 25 buttons in a grid on the stage named a0 - a24. When you click on a button in a particular row, I want to throw a number/letter combination into an array. I'm just starting out trying to get the code to determine which button was pressed and do a trace action. All it ever traces is the first trace "this button is an f". What am I doing wrong??? my or's are right aren't they? ||
Code:
for(l=0;l<25;l++){
_root["a"+l].onRelease = function(){
if(this._name=="a0"||"a5"||"a10"||"a15"||"a20"){
trace("this is an f button")
}else if(this._name=="a1"||"a6"||"a11"||"a16"||"a21"){
trace("this is an r button")
}else if(this._name=="a2"||"a7"||"a12"||"a17"||"a22"){
trace("this is an a button")
}else if(this._name=="a3"||"a8"||"a13"||"a17"||"a23"){
trace("this is a u button")
}else if(this._name=="a4"||"a9"||"a14"||"a18"||"a24"){
trace("this is a d button")
}
}
}
Thanks for looking!
Trouble With If/else Statement
I'm trying to right some script that says when a user rolls over this button it should go to the 2nd frame (visible, 1st frame is empty) of a particular movieclip. But I want to be sure that none of the other movieclips on the stage are showing, so I wrote this if/else statement to say that if the currentframe of the other movieclip is 1 (not showing) then go stop on the 2nd frame of this movieclip. If not, go stop on frame 1 of the other movieclip and then go stop on frame 2 of this movie clip. Here is the code below. Someone please tell me why it's not working. I have the code on the instance of the button. The button and both movie clips are on the main stage.
on (rollOver) {
if (_root.insured_mc._currentframe=1) {
polNum_mc.gotoAndStop(2);
} else {
_root.insured_mc.gotoAndStop(1);
polNum_mc.gotoAndStop(2);
}
}
When I publish the SWF, i make sure that insured_mc is on frame 2, to test the code, then I rollover the button in question and polNum_mc goes to the 2nd frame too, but insured_mc doesn't turn off (go to frame 1).
Trouble With The If Statement
I would like to know how to use the if statement in Flash.
I am trying to make it so that when you click a button it checks to see if an input text area with the variable "Awnser" has the number 900 in it. I have tryed top use the code from the help file, but to no avail.
Trouble With Logic Statement
I'm having trouble with a logic statement that counts the click of a user. I need it to control a set movie clips. Every movie clip has two positions but they move in relation to one-another. It works in one direction correctly but needs to be double clicked from the other direction. Here is the code from the first and last button contained in the movie clip.
Just to explain it a little better there are 7 movie clips mainA through mainG (only 6 move)
mainB
on (release) {
if (clickOn || subZoom) {
/:btargetx = 20.5;
clickOn = 0;
subZoom = 0;
} else {
clickOn = 1;
/:gtargetx = 720.5;
/:ftargetx = 700;
/:etargetx = 679.5;
/:dtargetx = 659;
/:ctargetx = 638.5;
/:btargetx = 618;
_root.maing.subzoom = 1;
_root.mainf.subzoom = 1;
_root.maine.subzoom = 1;
_root.maind.subzoom = 1;
_root.mainc.subzoom = 1;
_root.mainb.subzoom = 1;
}
}
mainG
on (release) {
if (clickOn || subZoom) {
/:gtargetx = 123;
/:ftargetx = 102.5;
/:etargetx = 82;
/:dtargetx = 61.5;
/:ctargetx = 41;
/:btargetx = 20.5;
_root.mainf.subzoom = 0;
_root.maine.subzoom = 0;
_root.maind.subzoom = 0;
_root.mainc.subzoom = 0;
_root.mainb.subzoom = 0;
clickOn = 0;
subZoom = 0;
} else {
clickOn = 1;
/:gtargetx = 720.5;
_root.maing.subzoom = 1;
}
}
Having Trouble With Conditonal Statement
Okay so I have a piece of code inside a button that is giving me problems.
Let me start by saying I can make this code work if it is attached to a button on the main timeline and here is an example:
in the main timeline I have an piece of AS that says this:
if (section == "1") {
loadMovie("1.swf", "_root.myclip");
}
I have a button that says this:
on (release) {
section = "1";
}
So if the button is clicked, the movieclip 1.swf loads into _root.myclip and it displays up fine - just like I want it to.
My problem now is if I have a button that is burried into a move clip like lets say it is inside a movie clip called menu.btn then how to I send the section = "1"; to the root? I tried passing it by trying this:
on (release) {
with (_root) {
section = "1";
}
}
but that just does not work. How can I pass that with this method?
If Statement Giving Me Trouble
I'm probably missing something simple, but I can't get my code to get inside my if statement. I've got a loop with setInterval that keeps doing this till my if statement becomes true, but it never gets there. It always does the else statement instead. I'm only having the problem with the if statement, but this is the just of my code...
ActionScript Code:
//my loop starts here
trace("x=" + _root.myMovieClip._x);
trace("y=" + _root.myMovieClip._y);
if( 50 < _root.myMovieClip._x > 54 and 100 < _root.myMovieClip._y > 104) {
trace("it made it here");
//clear my interval
}else{
_root.myMovieClip._x += (endX-_root.myMovieClip._x)/div;
_root.myMovieClip._y += (endY-_root.myMovieClip._y)/div;
}
My 2 traces at the start of my loop show like x=51.8 and y=102, but it never makes it inside the if, only the else. Any help?
Trouble With A Loop Statement
The code below stops when I get to the if statement. I can see the data all come in fine when I trace it, but there is something wrong with my if statement because it never resolves and should. Any observations would be appreciated - I have been looking at it too long and can't get to work.
Attach Code
showcase = new Array("Showcase1","Showcase2","Showcase3","Showcase4","Showcase5",
"Showcase6","Showcase7","Showcase8","Showcase9","Showcase10");
exData.onData = function (ourstring) {
//-- create booth array, split string --//
var temp = ourstring.split("|");
var pair = new Array(2);
booth = new Array();
//-- create multidimensional array --//
for(i = 0; i < temp.length; i++){
pair = temp[i].split("=");
booth[pair[1]] = pair[0];
for (j = 0; j < showcase.length; j++) {
scCont = "sc" + (j + 1);
if (booth[pair[1]] == showcase[j]) {
scCont.company = booth[pair[0]];
trace("Success - entered if statement");
break;
}
}
}
exData.load("flashVars.php");
Having Trouble With Conditonal Statement HELP
Okay so I have a piece of code inside a button that is giving me problems.
Let me start by saying I can make this code work if it is attached to a button on the main timeline and here is an example:
in the main timeline I have an piece of AS that says this:
if (section == "1") {
loadMovie("1.swf", "_root.myclip");
}
I have a button that says this:
on (release) {
section = "1";
}
So if the button is clicked, the movieclip 1.swf loads into _root.myclip and it displays up fine - just like I want it to.
My problem now is if I have a button that is burried into a move clip like lets say it is inside a movie clip called menu.btn then how to I send the section = "1"; to the root? I tried passing it by trying this:
on (release) {
with (_root) {
section = "1";
}
}
but that just does not work. How can I pass that with this method?
Trouble Loading External SWF Using An IF Statement
To someone who might be able to help me...
I have made a VERY simple movie.
- One Button inside a movieclip on the root level
and
- One movieclip("holder") inside of another movie clip ("mainmovieclip"). also on the root level.
The button is told to produce a global variable("myvar") which contains the data "apple".
Inside the mainmovieclip, on the first frame is an action that asks if the "myvar" variable contains the data "apple". If it does, then load an external SWF into the movieclip "holder".
--
So here's the problem. The FLA runs fine when previewed, but it totally ignores the variable and the if statement, and just loads the external SWF file.
Any ideas on what's going on? Any help would be greatly appreciated!
You can download the source files here:
http://www.mediathread.net/flash.zip
Trouble With Html Tags In HtmlText = Statement
Guys, I've got a puzzler. A friend is building a blog, with entries placed in a database, pulled out with php, and then passed to flash. It all goes well except for one thing...problems with html. She's using a tutorial from webmonkey and here's all the actionscript, as it originally was created:
ActionScript Code:
//function to load external data using the loadVars() object//l=name of loadVars object//n=name of text field //t=trigger to decide whether to show all entries or just one.//e= entry number to display (number)//f=file to load from (string)function lv(l, n, t, e, f) { sb.setSize(null, 200); sb2.setSize(null, 50); //create a new loadVars object if one doesn't already exist //if it does, use it if (l == undefined) { l = new LoadVars(); l.onLoad = function() { var i; //clear out any text that might already be there n.htmlText = ""; //to show a single entry at a time we use the //following code if (t == undefined) { n.htmlText += "<b>"+this["title"+e]+" - "+this["date"+e]+"</b><br><br>"; n.htmlText += this["entry"+e]; } else { //cycle through and show all entries for (i=0; i<this.n; i++) { n.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["title"+i]+" - "+this["date"+i]+"</a></u><br>"; } } sb.update(); sb2.update(); }; } l.load(f);}function loadArc(passed) { arcNum = passed-1; lv(blog_lv, entries_txt, undefined, arcNum, "blog.php");}//for the large entry textfield lv(blog_lv, entries_txt, undefined, 0, "blog.php"); //for the archives text field lv(archive_lv, archive_txt, "cycle", null, "blog.php");
the result: everything loaded in the .swf except the title of her entry over the entry itself. There is a bold html tag around that part, she removed it and voila! The title appeared. But now there's another html tag that starts off a line of code, and it's failing. Click on the entries, and nothing loads except the - between the date and title. Here is that section of code:
ActionScript Code:
for (i=0; i<this.n; i++) { n.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["title"+i]+" - "+this["date"+i]+"</a></u><br>"; }
She found that by hardcoding a variable defined by the loadArc function, which is pulled in as arcNum, the whole thing works...but of course, can only pull in one entry with the one id number she coded. She also has removed the <u> tags, but the <a href must obviously remain to make her entries clickable.
Any clues why having html at the front of this statement in the for loop is causing the entire line to fail, and no variable to pass? It's an interesting stumper. To see this in action, here is the page: http://www.lunesse.com/journal/journal.swf. In that directory you can also find the .fla file and the php results from the database. Tester.html is her second flash movie, also in that directory and completely barebones, and she received the exact same results.
Any pointers I could relay to her would be great. Thanks for your time.
Trouble With Html Tags In HtmlText = Statement
Guys, I've got a puzzler. A friend is building a blog, with entries placed in a database, pulled out with php, and then passed to flash. It all goes well except for one thing...problems with html. She's using a tutorial from webmonkey and here's all the actionscript, as it originally was created:
ActionScript Code:
//function to load external data using the loadVars() object//l=name of loadVars object//n=name of text field //t=trigger to decide whether to show all entries or just one.//e= entry number to display (number)//f=file to load from (string)function lv(l, n, t, e, f) { sb.setSize(null, 200); sb2.setSize(null, 50); //create a new loadVars object if one doesn't already exist //if it does, use it if (l == undefined) { l = new LoadVars(); l.onLoad = function() { var i; //clear out any text that might already be there n.htmlText = ""; //to show a single entry at a time we use the //following code if (t == undefined) { n.htmlText += "<b>"+this["title"+e]+" - "+this["date"+e]+"</b><br><br>"; n.htmlText += this["entry"+e]; } else { //cycle through and show all entries for (i=0; i<this.n; i++) { n.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["title"+i]+" - "+this["date"+i]+"</a></u><br>"; } } sb.update(); sb2.update(); }; } l.load(f);}function loadArc(passed) { arcNum = passed-1; lv(blog_lv, entries_txt, undefined, arcNum, "blog.php");}//for the large entry textfield lv(blog_lv, entries_txt, undefined, 0, "blog.php"); //for the archives text field lv(archive_lv, archive_txt, "cycle", null, "blog.php");
the result: everything loaded in the .swf except the title of her entry over the entry itself. There is a bold html tag around that part, she removed it and voila! The title appeared. But now there's another html tag that starts off a line of code, and it's failing. Click on the entries, and nothing loads except the - between the date and title. Here is that section of code:
ActionScript Code:
for (i=0; i<this.n; i++) { n.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["title"+i]+" - "+this["date"+i]+"</a></u><br>"; }
She found that by hardcoding a variable defined by the loadArc function, which is pulled in as arcNum, the whole thing works...but of course, can only pull in one entry with the one id number she coded. She also has removed the <u> tags, but the <a href must obviously remain to make her entries clickable.
Any clues why having html at the front of this statement in the for loop is causing the entire line to fail, and no variable to pass? It's an interesting stumper. To see this in action, here is the page: http://www.lunesse.com/journal/journal.swf. In that directory you can also find the .fla file and the php results from the database. Tester.html is her second flash movie, also in that directory and completely barebones, and she received the exact same results.
Any pointers I could relay to her would be great. Thanks for your time.
Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails.
[Flash CS3 (Flash 8 available as well)]
[Actionscript V2 (AS3 Not available for this project. End result must be in AS2. Plus I haven't learned AS3 yet)]
Hi
Sorry about running two posts so close together, but I couldn't change the other one to reflect the changes I've made in my problem.
The 1st post dealt with my theory that my IF statement wasn't written correctly, and so failed. But I've since disproved that.
Okay here is the situation.
I isolated elements from a larger app that I'm putting together and the problem still followed.
The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.
The purpose of the application is to load an XML file(works)
Populate 2 text fields with information from the XML file(works)
Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);
Heres the code:
Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
if (success) {
//point to the first node with information
var track_xml = data_xml.firstChild;
//loop through each node
while (track_xml != null) {
//print out each node
test1 = track_xml.toString();
//point to the next node
track_xml = track_xml.nextSibling;
//Runs my code
//Define the contents of two text fields located in the movie
textOne = data_xml.firstChild.childNodes[3].firstChild;
textTwo = data_xml.firstChild.childNodes[5].firstChild;
trace("data_xml.firstChild.childNodes[3].firstChild = " + data_xml.firstChild.childNodes[3].firstChild);
trace("data_xml.firstChild.childNodes[5].firstChild = " + data_xml.firstChild.childNodes[5].firstChild);
/*dummyYes = data_xml.firstChild.childNodes[5].firstChild;
dummyNo = data_xml.firstChild.childNodes[6].firstChild;
dummyMaybeEmail = data_xml.firstChild.childNodes[3].firstChild;
dummyMaybeFax = data_xml.firstChild.childNodes[4].firstChild;*/
//Checks between the two text fields for a match
if (textOne == textTwo) {
trace("It is selected!" + textOne + " " + textTwo);
check_fax.selected = true;
} else {
trace("Ir is NOT selected!" + textOne + " " + textTwo);
check_fax.selected = false;
};
}
} else {
trace("error reading file");
}
delete data_xml;
};
data_xml.load("XML/dummy2 - email.xml");
};
After you read the code, you'll have noticed the trace commands I stuck in there.
They send this to the output panel:
Code:
data_xml.firstChild.childNodes[3].firstChild = 1
data_xml.firstChild.childNodes[5].firstChild = 1
Ir is NOT selected!1 1
So as far as I can see, it reads the XML file with no problems, it loads the text fields with no problem. But for some reason the IF statement refuses to recognize that both the XML nodes contain the same information.
If I alter the code like so:
Code:
textOne = 1;
textTwo = 1;
Then the IF statement works. It sees that the two text fields are identical in content, and the checkbox is selected.
So whats wrong with the Data from the XML file?
I haven't a clue.
I tried converting from a string to a Numeral using:
Code:
newText = Number(textOne);
But that didn't work, it just produced "NaN" when traced.
I tried populating the XML file with text versus numbers, still no luck.
What came from the trace:
Code:
data_xml.firstChild.childNodes[3].firstChild = hi
data_xml.firstChild.childNodes[5].firstChild = hi
Ir is NOT selected!hi hi
The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.
CheckBoxes are mandatory.
But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.
I'd really appreciate some help and suggestions with this, I think I'm out of ideas.
Thanks
-Lem
Problem With Continue Statement And Label Statement
What am I doing wrong?
ActionScript Code:
var a = {
a:[1,2,3,4,5,6,7,8,9,0],
b:[1,2,3,4,5,6,7,8,9,0],
c:[1,2,3,4,5,6,7,8,9,0],
d:[1,2,3,4,5,6,7,8,9,0],
e:[1,2,3,4,5,6,7,8,9,0],
f:[1,2,3,4,5,6,7,8,9,0],
g:[1,2,3,4,5,6,7,8,9,0]
}
outerLoop: for(var i in a){
trace(i);
for(var j in a[i]){
trace(' '+j);
continue outerLoop;
}
}
Quote:
1039: Target of continue statement was not found.
Converting 'If Else' Statement To A 'switch' Statement
I am attempting to convert the following If statement to a Switch statement and I'm unclear as to the details of the execution of it. If someone could help me with this I would be very grateful. Here is the If statement followed by the shell of my attempted switch statement. TIA.
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
f (spotOne) {
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
} else if (spotTwo) {
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
} else if (spotThree) {
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
} else {
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
}
};
---------------------------------
(attempt at conversion to switch)
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
var location:Number = ?
switch(location) {
case spotOne:
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
break;
case spotTwo:
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
break;
case spotThree:
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
break;
case spotFour:
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
break;
}
Operator Help
I have 2 text fields, and I want both input variables to be correct in order for the user to go to the congratulations you got it right screen.
What's happening is only one of the inputs is getting evaluated, and the user is sent on from there.
Here is the action on the button:
on (keyPress "<Tab>") {
if ((cd=="t")||(cd=="T")||(cd=="today")||(cd=="TODAY" )||(cd=="Today")&&(ct=="1300")) {
gotoAndStop ("correct");
with (bclip) {
gotoAndStop ("right");
}
} else {
with (bclip) {
gotoAndStop ("wrong");
}
}
}
The first field has a few right answers, but the second has only 1 right answer, but I want both to be correct before showing the user the happy message.
I'm kinda new at this so be gentle. If there's an easier way help me out.
A Between Operator
I can't seem to find a between operator. I see one for just about everything else but I can't find an operator for something like . . .
if (x is between -50 and 47) {
Have I missed it?
Can I trick it somehow?
Thanks.
'between' Operator
simple question, but I cant seem to find the answer by looking through previous posts.
The mc is set to 46.8 on the screen and then again on the frame script. however, when I comes to setting an if statement:
if (getProperty(_root.mymc, _x) ==46.8) {
...it is always returned as false, even though I know it is true.
So for testing purposes I went about using '>' until I found the value of the movieclip. Odd thing is I got the number to between 46.7 and 46.9 i.e. 46.8! Perhaps it is looking at 2d.p.?
I could get round this by using > && < (inbetween operator), but I'm not sure how to do it.
I want to say if the _x position of my movieclip is greater that 46 but less than 47 etc
The closest I have got is:
setProperty(_root.mymc, _x, >46 && <47);
If anyone could help me out on this it would be much appreciated.
Or Operator
Why does this not work??
Flash always seem to do the "else" command, unless i delete the | 3 | 5, but I also need i to check if _root.playto == 3 or 5, it's allways only one or none of them.
Is there another way of saying if _root.playto is equal to 1 or 3 or 5.....?
if (_root.playto == (1 | 3 | 5)) {
_root.animation.gotoAndPlay("3-1");
} else {
_root.animation.play();
}
[help] AND/OR Operator
I searched all threw the help files on flash mx 2004 pro but i cant find what the AND/OR operator is...
Dose it exsist and what is it?
Thanks people
Contains Operator
Is there any sort of "contains" operator to use in an if statement with flash?
I want to test a string to see if it contains a particular word. How can I do that with flash?
Thanks
[F8][AS2] I Need A Var For A Operator
Code:
function getItems(Item:String) {
var pc:PendingCall = service.Item;
pc.responder = new RelayResponder(this, 'handleDoRead', null);
}
As you can see this wont use the var Item in place of the operator. But thats what I'm after. This is a remoting class I'm making thats get it's method from a var.
Or Operator
how does the || function work the code is
if(this.hitTest(_root.line2) && (_root.lapnum == 1.5 || 2.5)){
}
[F8]Operator For ² , ³ , ...?
Hi,
english is not really my native language so I'm not even sure what this is called.
But is there actually a math operator for ², ³, ..?
Thanks
&& Operator
Is it possible to have a 3 expressions be true before something happens, or can it only be 2 expressions?
for example..
if (_global.My1 == 1 && _global.My2 == 2 && _global.My3 == 3) {
//do something.
I tried it, but it didn't work, but it didn't give me an error either, so not sure if I'm typing it right.
Thanks!
D
Edited: 05/07/2007 at 01:08:21 PM by cre8ive1974
New Operator
Hi,
Could anyone tell me please, what happens wrong if I add the new operator to the URLLoader(e.target) to the code bellow, coz i would get the 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.net:URLRequest. Does it work something like a type casting if i use the class name without the new operator?
thanks.
Attach Code
private function completeHandler(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
}
&= Operator
See this example:
Code:
Var_1 = True;
Var_2 = False;
Var_1 &= Var_2;
That last rule is the same as:
Code:
Var_1 = (Var_1 & Var_2);
This gives Var_1 the value True, and that's what I don't get.
I reason like this:
To make Var_1 True, both Var_1 and Var_2 need to be True.
Because:
HTML Code:
Condition 1Condition 2 End Value
1 0 0
0 1 0
1 1 1
0 0 0
And the first case of my little overview is what the last rule said, no?
The % Operator
Hi guys.
Would one of you kind peeps please explain what the % symbol does when used like this...
ActionScript Code:
var beans:Number = Math.floor(200)%;
...I think that's right anyway. I've seen in floating around in a couple of scripts and just wondered what it did.
Cheers.
Si ++
How To Use The OR Operator
Hi, I would like to check if a variable is equal to either one of two other variables.
If I use this code, the check returns "true"
ActionScript Code:
if (itemPageId == ParentPageId) {
}
But when I´m trying to check with two variables it doesn't work the way I want.
This returns "false" though "ParentPageId" is true
ActionScript Code:
if (itemPageId == CurrentPageId or ParentPageId) {
}
This on the other hand returns "true"
ActionScript Code:
if (itemPageId == ParentPageId or CurrentPageId) {
}
What am I doing wrong??
Operator Comparision
I am trying to use the operator && to see if both MC's visibility are equal to false. Here is the code I am trying to use but it just doesnt work. It gives me this error:Left side of assignment operator must be variable or property. Any idea's?
[code]
if (x._visible =false && y._visible = false) {
}
[ ] Operator Revisited
Hi, it me again even more confused than before. I posted the other day about a particular use of the [] operator to set a dynamic variable. Thats fine now, cheers...but what about this?
PHP Code:
variable = [_level1.objectSelected]title;
'_level1.objectSelected' would be something like '_level2.object2'
so in this case Im trying to get the value of:
'_level2.object2.title'.
The rules to the [] operator bewilder me, are there any good tuts out there?
Thanks again
KUSH
Dont Get It && Operator
on (rollOver) {
square2 = _root.product_line.squares.square_2;
square3 = _root.product_line.squares.square_3;
whitecolor = square2 && square3;
whitecolor.setRGB(0xFFFFFF);
whitecolor._alpha = 20;
}
When I rollover square one only square 3 follows the actionscript ... any reason???
Thanks
Big Operator Problem
big i don't know but i'll get crazy soon:
i got 2 variables:
nb_con1 and nb_con2
i make a typeof on both and both are numeric values
with a trace, they both have the same values.
if i make
if (nb_conx==nb_con2) {
writer.start();
}
the action doesn't play
if i make
if (nb_conx!=nb_con2) {
writer.start();
}
the action plays.but it shoulb the contrary or i'm stupid..?
thx
Operator Overloading
is it possible to do operator overloading?
beacuse the AS already works with ++ and -- and so on
so is it possible to overload operator like in the c++ language?
thanks in advance
peleg
|| Operator Problem
....I have this code which works fine:
if (eval(thelevel)[x][y] === 0 && eval(previouslevel)[x][y]!== 0)return true;
else return false;
...but when I add an OR operator to test the inequality of 0 or 1 it doesn't work. Like this:
if (eval(thelevel)[x][y] === 0 && eval(previouslevel)[x][y]!== 0 || 1)return true;
else return false;
Can someone tell me what I am doing wrong here?
Cheers!
Operator Confusion
Guys,can u explain what are the differences in the following:
++a and a++
sry,i'm a newbie,giving these lame questions.Thxs
HitTest With Or Operator ( || )
I've built a presentation in Flash 5 which generates a series of bar graphs showing a demand curve over a 12 hour time span. It works, but I'm trying to optimize the code to reduce file size and make it more efficient. I made it work by hard coding every single instance; this involves 24 irrigation timers, any one of which can start up to three run cycles during the 12 hour period. I figured that consolidating each instance of a controller into a single hitTest could reduce the total lines of the AS by 2/3.
However, using hitTest with the ( || ) or operator doesnt' work. The script is:
//"this" is a MC representing a 15 min time period.
//"timer1a", "timer1b" and "timer1c" represent different start times for the same controller. Each is a seperate and properly labeled instance of a MC.
if (this, hitTest(_root.timer1a || _root.timer1b || _root.timer1c)) {
_root.controlR1[i] = 1;
} else {
_root.controlR1[i] = 0;
}
When I run a trace, hitTest picks up the "a" instance, but not the "b" or "c" instance. I suppose I could live with the original, but I'd like to know what I'm doing wrong. Any suggestions?
Help Operator Precedence
Hi,
I am optimizing some code but am unsure of where to go from here.
And thats after reading the actionscript dictionary on associativity and operator precedence.
here is the code ... the zero's must go.
Code:
this.x = x * c + 0 - z * s;
this.y = y * c + 0 + w * s;
this.z = x * s - 0 + z * c;
this.w = -y * s - 0 + w * c;
Thanks in advance
Shipstern
Add Operator Flash 8?
I am not able to use the add operator in flash8. I tried a search but the string "add" produces many results.
Can anyone help me out real quick on this one. Not sure what changed with flash mx and flash8.
example:
Kbps = Math.round(bits*10)/10 add "KB/S";
error:
**Error** Scene=Scene 1, layer=Loader, frame=1:Line 23: Syntax error.
Kbps = Math.round(bits*10)/10 add "KB/S";
Operator '>' Must Be Followed By An Operand - Help
I am using a scroll bar and text but I keep getting an error when I go to preview. I have fix some but driving me crazy for the rest and not sure how to fix this. Please help. I have listed the error report that comes up and below it the code. Thanks much
Errors:
ymbol=Symbol 472, Layer=ActionScript, Frame=1: Line 3: Operator '>' must be followed by an operand
<br><font color="#797979">u00bb</font><font color="#4189B7"> <b><u>What you do two</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 5: Operator '>' must be followed by an operand
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do four</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 6: String literal was not properly terminated
<br><font color="#797979">u00bb</font><font color="#4189B7"> <b><u>What you do five</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 7: String literal was not properly terminated
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do six</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 8: String literal was not properly terminated
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do seven</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 9: String literal was not properly terminated
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do eight</u></b></font><br><font color="#919191"> all about what you do......</font><br>
Symbol=Symbol 472, Layer=ActionScript, Frame=1: Line 10: String literal was not properly terminated
<br>";
Here is the code:
txt = "<font color="#797979">u00bb</font><font color="#4189B7"> <b><u>What you do one</u></b></font><br><font color="#919191"> all about what you do......</font><br>;"
<br><font color="#797979">u00bb</font><font color="#4189B7"> <b><u>What you do two</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do three</u></b></font><br><font color="#919191"> all about what you do......</font><br>"
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do four</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7"> <b><u>What you do five</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do six</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do seven</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7"> </font><font color="#4189B7"> <b><u>What you do eight</u></b></font><br><font color="#919191"> all about what you do......</font><br>
<br>";
Typeof Operator
Hi,
Code:
trace(typeof(bcUI._parent.getInstanceAtDepth(bcUI._parent.DISABLER_DEPTH)))
...gives 'movieclip'.
Code:
trace("Clip: " + typeof(bcUI._parent.getInstanceAtDepth(bcUI._parent.DISABLER_DEPTH)) == "movieclip");
..gives false.
Can anyone save me a few hours in trying to convince ropey Flash that "movieclip" == "movieclip" is true?
Cheers, CN.
Ternary Operator
can someone convert this ternary operator to if statements?
ActionScript Code:
this.load_bar._x>190 ? (this.load_bar._x<192 ? i=0 : null) : null;
Many thanks.
Assignment Operator
Hi...
I have the following problem.
I have an array that has a name for a square.
In my i want to edit the _width value of each square by using a loop.
The first part with the for loop works and shows 4 squares.
The second loop must change the _width for each square but this doesn't work.
grafieken[g].onEnterFrame = function() { were grafieken[g] is the array does not work. However, if i change this too grafiek1.onEnterFrame = function() { this will work for only the first square.
How do make sure all the squares will change
Code:
grafieken = new Array("klant1", "klant2", "klant3", "klant4");
count = 0;
//first part
for (g=0; g<grafieken.length; g++) {
_root.grafiek1.duplicateMovieClip("grafiek"+grafieken[g], count);
trace(grafieken[g])
oCount = eval("grafiek"+grafieken[g]);
with (oCount) {
_width=10;
_height=10;
_x = (count % 16)*_width;
_y = (count % 16)*_height;
count++;
}
}
//second part
for (g=0; g<grafieken.length; g++) {
//trace(grafieken[g])
grafieken[g].onEnterFrame = function() {
if (this._width <= 99) {
this._width += ratio;
if (this._width == 100) {
grafieken[g]_uitslag = this._width;
trace("Maximum is bereikt");
}
}
}
}
thanks
If And Else Operator Query
hello im well new to flash and am trying to make flash decide between to things. i am passing play label data in flash which will make it jump to a label from the url. but i want it to play frame 27 if there was no data passed in.
so my code would give me a function like this
if _global.jumpTO exists
gotoAndPlay(_global.jumpTO);
else
gotoAndPlay(27);
how would i code this properly i dont know what operator to use to do this.
thank you
|