Solved

startDrag operating strangely

Posted on 2009-07-05
2
238 Views
Last Modified: 2013-11-11
When I place a startDrag statement in an if statement, it gets called whatever the clause is.

It's very strange - in the code example drag_time is "false" before the if statement, but it gets set to whatever the if statement's clause is (in this case "testingtesting"!) and so whatever is inside the if gets called.

the first trace is "false" the second is "testingtesting". Even if I change the clause to equal "butterfly", say, then it gets set to that!

Where am I going wrong?
paintings_loader_mc.onPress = function() {
	trace(_root.chooser_mc.drag_time)
	if (_root.chooser_mc.drag_time = "testingtesting") {
		trace(_root.chooser_mc.drag_time)
		_root.paintings_loader_mc.startDrag();
	}
}

Open in new window

0
Comment
Question by:corin_pearce
2 Comments
 
LVL 3

Accepted Solution

by:
ruijietan earned 250 total points
ID: 24782075
For comparing strings you use the == (equality comparison) operator , not the = (assignment) operator.

What your code currently does is that it sets drag_time to "testingtesting" instead of comparing it.

Switch = to == and it should work. :D
paintings_loader_mc.onPress = function() {
        trace(_root.chooser_mc.drag_time)
        if (_root.chooser_mc.drag_time == "testingtesting") { // drag_time == "testingtesting"
                trace(_root.chooser_mc.drag_time)
                _root.paintings_loader_mc.startDrag();
        }
}

Open in new window

0
 

Author Closing Comment

by:corin_pearce
ID: 31599914
wow that was simple, how silly of me - thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question