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








Or Operator


how does the || function work the code is
if(this.hitTest(_root.line2) && (_root.lapnum == 1.5 || 2.5)){
}




FlashKit > Flash Help > Flash ActionScript
Posted on: 07-18-2007, 05:40 PM


View Complete Forum Thread with Replies

Sponsored Links:

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View Replies !    View Related
Operator - Not Greater Than
I have tried !> and >! but keep getting errors. How do I script "not greater than"?

Thanks

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

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

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

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

View Replies !    View Related
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">&nbsp;&nbsp;<b><u>What you do two</u></b></font><br><font color="#919191">&nbsp;&nbsp;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">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do four</u></b></font><br><font color="#919191">&nbsp;&nbsp;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">&nbsp;&nbsp;<b><u>What you do five</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;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">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do six</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;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">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do seven</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;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">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do eight</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;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">&nbsp;<b><u>What you do one</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;all about what you do......</font><br>;"
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;&nbsp;<b><u>What you do two</u></b></font><br><font color="#919191">&nbsp;&nbsp;all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do three</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;all about what you do......</font><br>"
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do four</u></b></font><br><font color="#919191">&nbsp;&nbsp;all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;&nbsp;<b><u>What you do five</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do six</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do seven</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;&nbsp;all about what you do......</font><br>
<br><font color="#797979">u00bb</font><font color="#4189B7">&nbsp;</font><font color="#4189B7">&nbsp;<b><u>What you do eight</u></b></font><br><font color="#919191">&nbsp;&nbsp;&nbsp;all about what you do......</font><br>
<br>";

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

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

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

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

View Replies !    View Related
Define Operator
Hi all!
Just a quick question (I hope hehe)... How do I define operators in actionscript? For instance, if I have my own data type and want to use for example + on it?

View Replies !    View Related
Operator Overloading
Has anyone thought about writing filters for actionscript? So that we can have features like this. I really just don't have the time but if someone wants to do it I'll offer what time I have to help them.

I imagine that it will not be difficult, we'd just have to do a little pre-compilation of the file before it's fed to the as3 compiler.

The syntax could be something similar to the component markup we saw in as2 and with the embed methods used in as3 today.

I imagine it'd be something like this, although this is a very over simplified example.

Vector + overloading

ActionScript Code:
... class definition

[Operator(symbol="+")]
public static function addition( vector1:Vector, vector2:Vector ):Vector
{
   // implementation
}

... more class definition

Then in our code using the Vector class we could simply say something like...

Before our compiler

ActionScript Code:
var v1:Vector = new Vector( 10, 20 );
var v2:Vector = new Vector( 1, 13 );

var v3:Vector = v1 + v2;

This will give us errors if we just use the flex compiler, but if we compile it before hand so that it would replace 'v1 + v2' with 'Vector.addition(v1,v2)'.

After our compiler, but before as3 compiler

ActionScript Code:
var v1:Vector = new Vector( 10, 20 );
var v2:Vector = new Vector( 1, 13 );

var v3:Vector = Vector.addition( v1, v2 );

Some people will say that this is overkill, if it's just a start to customizing the workflow, and it's something I would use just for the sake of cleanliness I don't see the problem.

As for efficiency there'd be no loss really other than the time it takes for pre-compilation. Because it's implemented the same in the end.

Anyway, it's just an idea, but if we do this we can modify the workflow of actionscript ourselves. There's still issues that would need to be talked about such as inheritance and overriding overridden operators.

This is something I will eventually take on, but I figured I'd throw it out there and see if anyone was willing to implement it.

Take care.
Michael

View Replies !    View Related
Problem With '+' Operator
I want to add 9 to myArray in place '0'.
exmple:
myArray[0] = 11;
Sum = myArray[0]+9;

I need to get 20 in 'Sum'.but I always get 119.
why?
plz help.

View Replies !    View Related
Ask About Operator Overloading
Anyone?

I have create my custom class it call Status,
well, i import the status in my document class and wanna to use it as a new datatype, let say it store a string of "available", "current", "answered".

probably... I would think of using an = operator overridden to assign a value to property to make simple, I cant find any related article for me to refer.

any Idea?

///////////////////////////////////////////
var stat1:Status = new Status();
stat1="available";
//////////////////////////////////////////
can it be realized?

View Replies !    View Related
A Quickie - The 'as' Operator
I'm optimising some old code and have a question about the use of the 'as' operator.

If I have a reference to an object and know its type, how should I cast it to avoid coercion errors?

In the past I used;


ActionScript Code:
SomeClass(my_object).someFunction();

but recently, I wonder if this is better;


ActionScript Code:
(my_object as SomeClass).someFunction();

Is there any performance advantage of using one versus the other, and if so, do you know why? I can't find this documented anywhere.

Thanks!

View Replies !    View Related
Class Operator
Hey! I have objects in an array of different class types. How can i compare two objects to see if they are of same class?

i tried both

if(instance is instance)

and if(typeof(instance) == typeof(instance)

none seem to work.

The later one almost worked, but it only returns object as class type. Does it have anything to do that they are stored in an array?

View Replies !    View Related
Math Operator
Hi,

Can anyone here help me out on how to make a multiple choice question asking about math operation.

Example: 2+3=5

User should click the right answer then the feedback will come out. User must click the right answer to proceed to the next question. Limitation of attempt to answer the question is unlimited.

Give me example of script, please...

Urgent! This is my courseware assignment.

View Replies !    View Related
Operator '=' Must Be Followed By An Operand
Hiya everyone,

I am having some problems with some syntax and its just baffling me now, so if anyone can help and advise me then i would be most gratefull. The code is below:

The movies are all in Actionscript 2

startx = getProperty(_root.bt01, _x);
startx2 = getProperty(_root.bt02, _x);
startx3 = getProperty(_root.bt03, _x);
startx4 = getProperty(_root.bt04, _x);
startx5 = getProperty(_root.bt05, _x);
startx6 = getProperty(_root.bt06, _x);
moved = /:targetx-startx;
moved2 = /:targetx2-startx2;
moved3 = /:targetx3-startx3;
moved4 = /:targetx4-startx4;
moved5 = /:targetx5-startx5;
moved6 = /:targetx6-startx6;
setProperty(_root.bt01, _x, startx+(moved/14));
setProperty(_root.bt02, _x, startx2+(moved2/14));
setProperty(_root.bt03, _x, startx3+(moved3/14));
setProperty(_root.bt04, _x, startx4+(moved4/14));
setProperty(_root.bt05, _x, startx5+(moved5/14));
setProperty(_root.bt06, _x, startx6+(moved6/14));

The error code i get is:

Operator '=' must be followed by an operand moved = /:targetx-startx;

Any ideas???

View Replies !    View Related
Collision 'OR' Operator
I've been trying out some collision detection and here's what I came up with. It's easy to understand:
ActionScript Code:
stop();// New Function:function myCollision() {// If 1st circle hits the second or third circle:    if (myCircleOne.hitTest(myCircleTwo or myCircleThree)) {// Increment our hit counter:        hits = hits + 1;    }}// Run this function forever:setInterval(myCollision, 0);
Why doesn't this work? I tried or, I've tried | and also ||. None of these operators work. I'm trying to make it check if the first circle hits the second or third. How can this be done? BTW, what's the difference between or, | and ||?

- Thanks, Sharif .

View Replies !    View Related
OR Operator, Using Correctly?
why doesn't this work?


Code:

if (_root.currentSection == "Comgroup" || "Clientrooms" || "Contact") {
_root.sectionsBG("out");
} else if (_root.currentSection == "Work" || "Us" || "News" || "Insights" || "Opportunities") {
trace ("Background is in place.");
}
basically in english, i'm trying to say that:

if color is equal to purple or orange or brown then do this, else if color is equal to red or pink or green, then do this.

the error the above code is having is that, no matter what _root.currentSection is, it always goes to the first if statment, so leads me to believe i'm using the || operator wrong.

thanks.

View Replies !    View Related
Scope Of 'this' Operator
hello i have a class which stores the mouse x and y positions. i m having problem in accessing the variables of the class from the events inside the class

// controller.as
class controller{
public var x:Number;
public var y:Number;
public var mouse_listener:Object=new Object();

public function controller(){ // constructor
mouse_listener.onMouseMove=function(){
this.x=_root._xmouse;
this.y=_root._ymouse;
}
Mouse.addListener(mouse_listener);
}
}

// code for controller.fla
var c:controller=new controller();

_root.onMouseDown=function(){
trace(c.x+""+c.y);
}

//outputs "undefined undefined" whenever the mouse is clicked on stage


my problem here is i am not able to access the variables x and y of the controller class. when i try to access them from the constructor the this.x and this.y seems to refer to the mouse_listener object. i am not able to update the values to the x,y variables of the class. how do i do this ?

help please !!

View Replies !    View Related
Bitwise NOT Operator
I was reading this: http://www.macromedia.com/devnet/fla...rators_03.html

and it says:

Quote:




With a bitwise NOT operator, I would get 6 back. This is because the bitwise NOT flips each bit in the binary representation of 9 separately, so 1001 (9 in binary) becomes 0110, which is 6 in decimal.




However:


ActionScript Code:
trace (~9);

traces: -10

Am I misunderstanding something here? How does this bitwise operator operate exactly??

View Replies !    View Related
Equality Operator
Hi folks,

How can i check if 3 variables hold the same value in an if statement

var stepval1 = 20;
var stepval2 = 20;
var stepval3 = 20;


if (stepval1 == stepval2 == stepval3){
trace("inside 1 = 2 = 3");
}

Thanks

View Replies !    View Related
What Is The | (the Bitwise OR Operator) Used For?
Greetings everyone!

Working my way through the book "Flash MX 2004 games most wanted" from Friend of Ed.
The book assumes a bit more AS knowledge than I have atm so I'm using a lot of time checking every bit of code - making sure I know what is going on on each line. In one of the program codes (one that makes a tile-based gameboard) I've come across the bitwise OR operator written in AS as |. What is the use of this operator? In the Flash 8 AS helpfile it says:

expression1 | expression2

Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.

They also give the following code example:

// 15 decimal = 1111 binary
var x:Number = 15;
// 9 decimal = 1001 binary
var y:Number = 9;
// 1111 | 1001 = 1111
trace(x | y); // returns 15 decimal (1111 binary)

Problem is I can't wrap my head around the logic of this operator - example: why does the code above output 15 and not something else? Basically my question is this: how does | work? And how is it usefull to me when writing code?

Any hints to this are more than welcome!

View Replies !    View Related
Custom [] Operator
Hi to all.. i'm quite a newbie in flash.. but i came from other languages and i'm looking around, to feel comfortable with this language. . :-)

There is one thing i didn't find by searching the docs, and i hope that is possible to implement..

I want do write my own collection.. let's say a LinkedList.. i wonder if it is possible to implement the direct access by key (or position ) , in order to do something like..

Code:
var list:LinkedList = new LinkedList();
...
trace ( list[1] );
and maybe if it is possible to have the foreach, just like the Array has it

Code:



for each(var i:item in list) {
...
}
thanks to everyone :-)

View Replies !    View Related
Operator In A Variable
is it possible to store an operator such as >= in a variable, for example:
ActionScript Code:
var myOperator;
if(randomNumber == 1){
myOperator = >=;
}else{
myOperator = <=;
}



I know this sounds strange.

View Replies !    View Related
Smooth Operator
I searched the forums for the answer but I can't seem to find my answer. With that said here is my question. I made a flash movie which I added a preloader, and streamed music on it. When playing it, it still has some spots where the movie slows down and the music stops because it is streamed. I have it set for 30 fps and have been playing around with that also but it does not seem to work. Is there anyone out there with a tutorial for a preloader which will compile the movie first to make it smoother or another method that may help me out? Thanks,
Roxy Gurl

View Replies !    View Related
[AS2] Plus/minus Operator
Is there any simple way to use a plus or minus operator in AS2? To give this context, lets say I want to randomize a speed, higher or lower, on event (passing a certain x or y value) (like a ball bouncing around in a bounding box, but create some random rebound angles).

I'm essentially asking if there's anoperator for the symbol '±' in AS2...

Thanks in advance!

View Replies !    View Related
Collision 'OR' Operator
I've been trying out some collision detection and here's what I came up with. It's easy to understand:
ActionScript Code:
stop();// New Function:function myCollision() {// If 1st circle hits the second or third circle:    if (myCircleOne.hitTest(myCircleTwo or myCircleThree)) {// Increment our hit counter:        hits = hits + 1;    }}// Run this function forever:setInterval(myCollision, 0);
Why doesn't this work? I tried or, I've tried | and also ||. None of these operators work. I'm trying to make it check if the first circle hits the second or third. How can this be done? BTW, what's the difference between or, | and ||?

- Thanks, Sharif .

View Replies !    View Related
OR Operator, Using Correctly?
why doesn't this work?


Code:

if (_root.currentSection == "Comgroup" || "Clientrooms" || "Contact") {
_root.sectionsBG("out");
} else if (_root.currentSection == "Work" || "Us" || "News" || "Insights" || "Opportunities") {
trace ("Background is in place.");
}
basically in english, i'm trying to say that:

if color is equal to purple or orange or brown then do this, else if color is equal to red or pink or green, then do this.

the error the above code is having is that, no matter what _root.currentSection is, it always goes to the first if statment, so leads me to believe i'm using the || operator wrong.

thanks.

View Replies !    View Related
[AS Help] OR Operator Explaination
I figure this is a basic question but I'm stumped.

This script is straight out of the Animating with AS pt.2 tutorial here on UltraShock. I'm just curious how this works. Left and Right are variables that calculate the boundaries of another movie clip. This script causes the ball to change direction or "xspeed" when it reaches thoes boundaries.

What I can't figure out is how this works with the || "or" operator. I've read the reference on it but to no avail. Can anyone help?

*_x refers directly to the MC thats moving.


ActionScript Code:
} else {
        _x+=Number(xspeed);
        if (_x<left || _x>right) {
            xspeed = -xspeed;
            }

View Replies !    View Related
Varibale After . Operator
Last edited by -=(D.p)=- : 2003-08-20 at 10:03.
























Hey Ppl

My question goes like this :
i writed a simple command to get an attribute from a XML file


ActionScript Code:
trace(CurrNode.attributes.att1);


and it all works fine!
but i had created a function that return the attribute and i need to put
a variable instead of att1 i tried to do some stuff but it seems to not work
so how can i put a varibale after a dot operator?

Plz Help

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