Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

startDrag operating strangely

Posted on 2009-07-05
2
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
ruijietan earned 1000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

721 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