Skip to main content
Inspiring
February 25, 2008
Question

if (condition) not working

  • February 25, 2008
  • 2 replies
  • 246 views
Goal: To change the cursor to a custom cursor (mc: drag_cursor), when the mouse is over the mc called "image_holder". However I only want the cursor to change when certain files are loaded into "image_holder".

Method:
onEnterFrame = function() {
if (menus.hitTest(_root._xmouse, _root._ymouse, true)) {
stopDrag;
drag_mouse._x = -100;
drag_mouse._y = -100;
}else{
if (content.image_holder.hitTest(_root._xmouse, _root._ymouse, true)) {
if (dragCursor = true) {
trace(dragCursor)
startDrag(drag_mouse);
drag_mouse._x = _root._xmouse;
drag_mouse._y = _root._ymouse;
}
}
}
}

Problem:
menus.hitTest - changes the cursor back when user mouses over the menu (works)
content.image_holder.hitTest - changes the cursor to the custom cursor when the user is mouse over "image_holder" (works)
if (dragCursor = true) { - condition that asks if the cursor should be change to "drag_cursor". dragCursor is set to true when the user clicks a certain button to load certain files into "image_holder". The problem is that the cursor changes before it is set to true even after I set it to false at the start of the movie.

Cheers
This topic has been closed for replies.

2 replies

February 25, 2008
try

if(dragCursor == true)

use double equal signs

hth

doug
Inspiring
February 25, 2008
expansion17,

In this line:

> if (dragCursor = true) {

you're not checking if dragCursor is true; you're actually *setting*
dragCursor to true. To check the condition, use the double equals sign (if
dragCursor == true).


David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."