Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : There's got to be an easy solution to this one


DieFrohKartoffel
6/23/2004 8:36:50 PM
Hey all -

My group and I are developing an app, and we've run into an error. Any help
would be greatly appreciated. Thanks in advance!

We have devices in a group. These devices are multiple instances of a movie
clip. These clips, based on a root array, are told whether they have an error
or not (1,0). If the device has an error, it sets it's parent's (group) error
to on (1), but only if the parent error is 0.

This all works fine and dandy until all the devices do not have an error, but
the parent group is already keyed for an error. Then we cannot turn that error
off. One stipulation, the devices have no idea about each other and the group
cannot count how many devices there are.


dmccoy
6/23/2004 9:08:29 PM
-E=
6/24/2004 12:10:44 AM
loop through all devices in a group, then turn the group-error off, if none
of the instances has error on.

-E=

[quoted text, click to view]

DieFrohKartoffel
6/24/2004 1:46:09 PM
We cannot loop through the devices and then check for the error as the code
won't access the devices in the group. The group only looks at it's own error
variable, whether it's 1 or 0. The devices (duplicate instances) check that
variable, and then assign it if necessary.


The problem we run into is this:
When the group error is 0, the devices set the group error to 1 - which is
perfect. However, once all the devices switch back to 0, the group error stays
at 1. There is no way to reset this value. I know that's what you're getting
at, but without being able to count the devices or have the devices talk to
each other, there seems to be no solution. The devices check for the group
error so that the group error variable isn't constantly switching between 1 &
0, making it impossible to display the error.



//device code

if (_parent.error==0){ // group OK
if(error==0){ //device OK
_parent.error=0;
}
else{ // device ERROR
_parent.error=1;
}
}
else{ // group ERROR
if(error==0){ //device OK
_parent.error=0;
}
else{ //device ERROR
_parent.error=1;
}


//group code

if(error==0){
//display GROUP OK
}
else{
//display GROUP ERROR
}
dmccoy
6/24/2004 2:15:05 PM
why don't you create a temporary error array? if the device has an error, push
the value to the array. then write a loop that checks for values in the array,
and sets the group value accordingly, then reset the array to null.
DieFrohKartoffel
6/24/2004 5:41:24 PM
An array is a good idea, however, to properly add to it and check it, the
check/reset function needs to know how many devices (slots in the array) there
are. This would cause a problem otherwise. Without knowing how many devices
there are, the devices will constantly be writing to an ever-growing array,
thus, there will always be an error reported in the device. Perhaps I should
let the array fill up to an X number of times, then reset it and until there
are no 0s found, keep the device error on. Hmmm.. Thanks, I'm going to try
an alternate array solution.

Thanks again for the input everyone....
AddThis Social Bookmark Button