Solved

startDrag operating strangely

Posted on 2009-07-05
2
243 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 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

737 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