Solved

startDrag operating strangely

Posted on 2009-07-05
2
235 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now