Skip to main content
Inspiring
April 1, 2011
Answered

if else BUG!

  • April 1, 2011
  • 2 replies
  • 470 views

Hi all,

I'm working on a project but the 'if' statements aren't working.

Can anyone help please?

here is the thingI have a scroll bar (scroll_mc) and inside it I have a dragable circle (circle_mc) and I have a content that is called (content_mc)

var _limit = new Rectangle(0,0,470,0) // -y, -x, +y, +x
var _position
var _divide = 35.2 // 720 (stage) * 25 (screens) 470 (scroll size)

function enter_frame(e){
    _position = scroll_mc.circle_mc.x*_divide
    content_mc.x= 0 - _position
}

scroll_mc.circle_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag_down)

function drag_down (e){
    scroll_mc.circle_mc.startDrag(false,limite)
    stage.addEventListener(Event.ENTER_FRAME, enter_frame)
}

stage.addEventListener(MouseEvent.MOUSE_UP, drag_up)

function drag_up (e){
    if (content_mc.x > 0 && content_mc.x < 360){
        new Tween (content_mc, "x", Strong.easeInOut, content_mc.x, 0, 1 ,true);
    }
    if (content_mc.x > 360 && content_mc.x < 720){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }
    if (content_mc.x > 720 && content_mc.x < 1080){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }

    scroll_mc.circle_mc.stopDrag()
    stage.removeEventListener(Event.ENTER_FRAME, enter_frame)

}

the problem is when I stop drag between 0 and 360 or 360 and 720 or 720 and 1080 nothing is happening and I need my content (content_mc) to reposition with the new tween event any ideas why?

This topic has been closed for replies.
Correct answer kglad

use the trace() function to check content_mc's x property.

2 replies

Participant
April 1, 2011

I see the problem.  You are excluding 360 and 720

    if (content_mc.x > 0 && content_mc.x < 360){
        new Tween (content_mc, "x", Strong.easeInOut, content_mc.x, 0, 1 ,true);
    }
    if (content_mc.x > 360 && content_mc.x < 720){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }
    if (content_mc.x > 720 && content_mc.x < 1080){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }

should be

    if (content_mc.x > 0 && content_mc.x <= 360){
        new Tween (content_mc, "x", Strong.easeInOut, content_mc.x, 0, 1 ,true);
    }
    if (content_mc.x > 360 && content_mc.x <= 720){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }
    if (content_mc.x > 720 && content_mc.x < 1080){
        new Tween  (content_mc, "x", Strong.easeInOut, content_mc.x, 720, 1 ,true);
    }

note the <= in the first 2 ifs.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 1, 2011

use the trace() function to check content_mc's x property.

Inspiring
April 1, 2011

thanks.....saving my life again!!!!

lol

kglad
Community Expert
Community Expert
April 1, 2011

you're welcome.