1 person found this helpful
You probably do not want to keep e.target in there. e.target can point to something inside the object that you click, such as one of the face graphics. You should use e.currentTarget instead. currentTarget points to the object that has the event listener assigned.
As far as your comparisons go, if you are testing a string value, you only need to use the string values. Using the "two. " as you have doesn't do anything for you except probably generate an error.
if(e.currentTarget.currentLabel == "facesad" || e.currentTarget.currentLabel == "blue1")
You do not want to use "String" in your code like you did because that is a class name in AS3. If you want to do something like that then use "face"+string, where string is a variable that is assigned a String value.
The code in my project is working as I want it with the e.target, but I'll take your advice change it to avoid any future problems.
As far as the rest, I probably didn't explain myself clearly enough, but the code in your post doesn't really do what I was looking for. As I noted at the end of the post, the code I posted was streamlined for clarity. In the actual project
there are several numbered instances and there are about a dozen keyframes in those symbols. My goal is to get a specific button to react if specific instances match specific groups. To get the code to do what I want, it is important to make sure I define a specific instance and its specific state.
But I think you did point me on the right track in saying I need to assign a string value. What would that look?
Labels are strings, so they would look just like I showed "thisisastring" Based on your description of the intention of the code, I don't think you are going about it per what you say you want (or what I described in your other posting for this). If you want see if One and Two are displaying the same thing, then give them the same frame labels for the same things and compare the frame labels...
if(One.currentLabel == Two.currentLabel) winbutton.gotoAndStop(frame2);
Oh, okay You are taking into consideration some of my previous postings. What I'm trying to do now is similar, but
The code in your last post doesn't do quite what I need because it activates "winbutton" when the two symbols are on
matching labels (e.g. "blue1"). What I want is for the winbutton to be activated if they share labels from matching groups (e.g. "blue1,blue2,blue3", "facesad,facehappy,faceangry"). I would like to be able to exclude certain members of the group, too. For instance, if "One" is the target and its current label is "blue1", I would want "winbutton" to only be activated if its label is "blue2" or "blue3".
I hope this is a better explanation. Thanks in advance.
What you just attempted to explain doesn't agree with what your posting started with... " want to set it up so that "winbutton" will move to it's second frame if "One" or "Two" is pressed while it shares the same label as it's partner."
It sounds like you need to try to tackle this yourself and weather the storm to solve it, because I can't follow what you say you want now. You know what you want and just need to put the thought logic into code logic.
If what you are saying now is you want to match labels that share the "blue" or "face" text in them, then you can use the String.indexOf() method to see if they conatin a certain string value or not.
if( String(e.target.currentLabel),indexOf("face") > -1) // the labels contains "face" if this is true
Look it up in tthe help documents to get a thorough explanation of what it does.
Thanks, Ned. Sorry for the confusion. Sometimes while trying to explain a situation, I'm not quite sure what information to focus on. Several times I've phrased a question in a particular way that led to an answer that, while correct, I couldn't really use. I have been attempting to post the simplest example explanations and simplest example code to explain what I am trying to do , but I usually end up stumbling over my own feet. Here, I basically wanted to ask "What is the correct synstax for the string method in this situation?" but ended up asking an entirely different question! I guess I was hoping whoever answered the question would latch onto my use of the string method and I could take it from there.