Solved

startDrag operating strangely

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
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.

765 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