Don't Escape
I'm a werewolf and it's a full moon. I have to find a way to prevent myself from escaping.
3.72 / 5.00 28,758 ViewsRagnarok Online Jigsaw
Did you play Ragnarok Online? Do you like that game?
3.52 / 5.00 12,651 ViewsIs there a way to check a variables name or if not the class's name.
For example:
Var targets:Array = []
Targets = zombies;
//targets array contains other objects apart from zombies
For(var I:int = 0; I < targets.length; I++)
{
If (targets [i] .kinGroup == zombies)//kinGroup is the name of the array it is part of.
{
//do stuff
}//doesnt work
At 3/14/13 05:01 PM, HuDsOn90Five wrote: Is there a way to check a variables name or if not the class's name.
For example:
cast to the desired type, if it turns out to be null, ignore it
I'm not sure what your trying to do, but it might help you to know that all objects have string name properties for instance:
myObj.x = 5;
is the same as:
myObj['x'] = 5;
and you can see if any object has a public variable of a certain name by saying
if("x" in myObj){trace(myObj[x]);} I think what you're looking for is the "is" keyword. You can check to see a class type like so:
if (targets[i] .kinGroup is Zombies){
}else if (targets[i].kinGroup is Elves){
}..etc At 3/14/13 08:08 PM, Mattster wrote: I think what you're looking for is the "is" keyword. You can check to see a class type like so:
if (targets[i] .kinGroup is Zombies){
}else if (targets[i].kinGroup is Elves){
}..etc
Thank you, this is what i was looking for
At 3/14/13 08:08 PM, Mattster wrote: I think what you're looking for is the "is" keyword. You can check to see a class type like so:
if (targets[i] .kinGroup is Zombies){
}else if (targets[i].kinGroup is Elves){
}..etc
Thank you, this is sort of what I am looking for, but rather than checking the class name is there a way to check the array name? Im not really sure how to explain it but targets is combined of:
zombie classes which kinGroup is the "zombies" array which contains all zombies on stage.
tank and bunker classes which both kinGroup is "towers" array which contain all the tanks and bunkers on stage but could contain different classes in the future.
So rather than doing :
if(targets[i] is zombie){}
else if(targets[i] is tank){}
else if(targets[i] is bunker){}
Could i do something like:
if(targets[i].kinGroup is zombies){}
else if(targets[i].kinGroup is towers){}
if you catch my drift?
At 3/15/13 07:33 AM, HuDsOn90Five wrote: if you catch my drift?
I haven't tried this before, but you could make your arrays vectors. So you could so something along the lines of
//example vector
var v:Vector.<Zombie> = new Vector.<Zombie>();
if(targets[i].kinGroup is Vector.<Zombie>){
}else if(targets[i].kinGroup is Vector.<Bunker>){
}...
Now, that's if you want that format. Another solution (which I suggest) would be to make "kinGroup" an Object. Then check:
var group:Object = targets[i].kinGroup;
if ("zombies" in group){
}else if ("bunker" in group){
}...
or you could loop through it
for (var s:String in group){
if (s == "zombies"){
trace("zombie",group[s]);
}
} At 3/15/13 07:33 AM, HuDsOn90Five wrote:
if(targets[i].kinGroup is zombies){}
else if(targets[i].kinGroup is towers){}
if you catch my drift?
assuming "zombies" is a variable and not a type then you would say
if(targets[i].kinGroup == zombies)
flash can tell if 2 objects are copies of the same thing, but they can't be 2 different objects with the same properties, let me explain:
var a:Array = [1,2,3];
var b:Array = a;
trace(b == a); // --- true
that works fine, in fact if you change b in any way, a will be changed too.
however this does not
var a:Array = [1,2,3];
var b:Array = [1,2,3];
trace(b == a); // --- false
}
that won't work because they are 2 different arrays that just so happen to have the same information. you can change b without changing a. This is why you'll notice that classes like Point have a clone() function