Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

testing boolean value syntax

New Here ,
Feb 10, 2008 Feb 10, 2008
hello, could somebody please help me with how to find the value of 3 boolean objects in an if statement?
i have 4 movie clips which tral a character on contact, but i only want one to trail at a time. The objects trail when a hittest return a true value, so i've tried to put in a if statement where a hit test will only be tested on that object if the boolean value of the other 3 objects = false, but it isn't working and i have no idea where to go from there. I'm sure i had it working with 2 objects earlier, but i don't know where i've gone wrong. here's the code for one of the objects;-



TOPICS
ActionScript
466
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2008 Feb 10, 2008
use the double equal (==) to test for equality.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 10, 2008 Feb 10, 2008
hey flawed - (sorry couldn't resist lol) although I'm not certain how your 'trailing' code operates, I think I'd consider going about this a little differently. I'd place all object references within an array, and track one variable that is a reference to the current object trailing, then run the test and switch the current object when the hitTest returns true. Then I'd use the current object reference in the trailing code. so for the test below I'd do something like:

EDIT: sorry kglad - typing...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2008 Feb 10, 2008
sorry but i'm completly lost!! kglad helped me quite alot yesterday, i've only had a few days to work this out and am completly new to programming. The section of code underneath just passes a true boolean value to the trailing movie clip when hit (objectA, ObjectC etc), and then false when the trailing object comes into contact with another object (objectB). the boolean is passed to code on the main timeline which attaches the objects. I've tried push and pop, do while loops etc but i dont seem to be getting anywhere. I tried the above code but now nothing will trail, as opposed to everything

for(var i = 0; i < objectA.length;i++)
{
{
if(this.hitTest(this._parent.objectA ))
{
this._parent.objectA
.booleanVar1 = true; //if hero hits answer a, trail
}

if(this.hitTest(this._parent.objectB )) //if answer a hits answer box - drop it
{
this._parent.objectA
.booleanVar1 = false;
}
}
//-------------------------trailing object c


if(this.hitTest(this._parent.objectC ))
{
this._parent.objectC
.booleanVar2 = true; //if hero hits objectC, trail
}

if(this.hitTest(this._parent.objectB )) //if answer c hits answer box (objectB)- drop it
{
this._parent.objectC
.booleanVar2 = false;
}
}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 10, 2008 Feb 10, 2008
I'm sorry flawed, I know you're working hard on this system, I just feel that it could be achieved more simply. So I made a basic example for you, you can examine the code, and see how it works. I also understand that kglad was helping you sort this out, and if you want to continue with the methods you've been working out, I won't be offended :)

@kglad: also not trying to step on you're toes kg, just was thinking there might be a simpler system here :)

download the example FLA file HERE
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2008 Feb 10, 2008
thanks so much for doing that, im sure i can take what i need from it but i can't find the action code bits? i usually just left click on the movieclips or on the timeline. could you tell me where the code is?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 10, 2008 Feb 10, 2008
all the code is on frame 1, the top layer of the main timeline. there is no code attached to MC instances, thats all of it.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2008 Feb 10, 2008
yey, sorry, found it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 10, 2008 Feb 10, 2008
thanks so much for doing that for me, but the reason i did it this way is because the objects kind of floats behind the hero when collected. maybe im just being too ambitious, and staring at the computer screen for the last 10 hours probably isn't helping!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Feb 10, 2008 Feb 10, 2008
LATEST
that's no problem flawed, this is only a very basic example, of the problem in question here. there are many additions that could be made to the system as well, including 'how' the item trails this was a very simple example and I took no time to add anything like that although it can be done within the confines of the methods as shown. the point is that these things could be accomplished with a less diverse system of variables and check procedures.

and yes lol, take a break!!! 🙂 then come back to it with fresh eyes...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines