dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: If/Then statement needed for movieclip postion

  1. #1
    Nose Picker
    Join Date
    May 2002
    Posts
    66

    If/Then statement needed for movieclip postion

    I'm moving a movie clip around with buttons using this script:

    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    function nextMC() {
    	var forward:Object = new Tween(posters_mc, "_x", Back.easeOut, posters_mc._x, posters_mc._x - 906, 5, false);
    
    };
    
    function prevMC() {
    	var forward:Object = new Tween(posters_mc, "_x", Back.easeOut, posters_mc._x, posters_mc._x + 906, 5, false);
    
    };
    
    
    nextBT.onRelease = nextMC;
    prevBT.onRelease = prevMC;
    Ex: http://mark2000.com/menutest.swf

    I want the clip to loop. Is there an if/then statement i can add so that if x coordinate is finally reached by the clip then the clip will automatically goto y coordinate on the next frame? Thanks!

  2. #2
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    are you trying to use yoyo function? If so, this is it
    PHP Code:
    function nextMC() {
    var 
    forward:Tween= new Tween(posters_mc"_x"Back.easeOutposters_mc._xposters_mc._x 9065false);
    forward.onMotionFinished=function(){
    this.yoyo();
    }
    };
    function 
    prevMC() {
    var 
    forward:Tween= new Tween(posters_mc"_x"Back.easeOutposters_mc._xposters_mc._x 9065false);
    forward.onMotionFinished=function(){
    this.yoyo();
    }
    }; 
    or may be i guess you want it to perform gotoNextFrame, then just replace this.yoyo by gotoAndStop(yourFrameNumber)
    Last edited by deepakflash; 01-14-2008 at 06:40 AM.

  3. #3
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    That didn't work out. See, i dont want to yoyo directly back when the button is pushed. I want the menu as a whole to loop. So when I get to the last panel, say at x coordinate 9500, the movie clip will suddenly go to x coordinate 50 on the very next frame - no tweening involved.

  4. #4
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    I just tried the following code for my forward button but that too didn't work, although I don't see why not. Could someone look it over as see whats missing?

    Code:
    function nextMC() {
    	if (posters_mc._x == -3862.3) {
       var forward:Object = new Tween(posters_mc, "_x", Regular.easeOut, 6957.3, 7104.3, 3, false);
    } else {
    	var forward:Object = new Tween(posters_mc, "_x", Back.easeOut, posters_mc._x, posters_mc._x - 906, 5, false);
    }
    };

  5. #5
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    what is it thats not working? try placing trace action inbetween lines so that you can easily spot the bug. thats one way to go about it. if you dont have your trace occuring then it means the basics of the code is wrong, and btw, it has to be var forward:Tween= new Tween(........... why do you have it as an Object ?

  6. #6
    Nose Picker
    Join Date
    May 2002
    Posts
    66
    I have object because the script i copied had object in it. I replaced it with tween and it works equally well. What seems to be the problem is that the if/then statement doesn't work, but the else statement does. For some reason even though the clip is at the coordinates I specify it still doesn't return to the start. Can you see any reason why it wouldn't? If I posted my source flash would it help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center