A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Initiate Actions Based on _x?

Threaded View

  1. #1

    Initiate Actions Based on _x?

    Ok...after several hours tinkering I've set up a movie to initiate a set of actions triggered by a movieclips _x position. Im using Math.round to keep my intergers whole and im using ease on my movieclip. If the movieclip starts on a whole interger and the buttons are hit 1,2,3,4 everything is fine, but hit the buttons out of order (2,4,1,3) or set the start point of the mc to anything but a whole interger and the movie becomes a mess.

    I don't understand what im doing wrong. I tried some simple loop commands and my comp just locked up repeatedly so I broke down and used frameloops, it's closer to complete but still so far.

    I've attached a my test document, and a break down of my code. Any help would be greatly appreciated.


    The _x position needs to be...
    30 to initiate the home actions.
    -620 to initiate the about actions.
    -1280 to initiate the portfolio actions.
    -1930 to initiate the contact actions.

    when the function scripts moves the section MC from right to left everything is fine but to go from left to right the x position is off by 4 pixels(if you use Math.floor it off by +2 or -2). The text field with the number is a trace for the x position. Check it out you'll see what I mean.

    Thanks for taking the time to look.

    Heres my mc code
    Code:
    onClipEvent (load) {
    	new_posi = _x;
    	ease = 5;
    }
    onClipEvent (enterFrame) {
    	_x += Math.floor((new_posi-_x)/ease);
    }
    my function
    Code:
    function sectionopen() {
    	if (_root.sectionName == "home") {
    		_root.section.new_posi = 30;
    	}
    	if (_root.sectionName == "about") {
    		_root.section.new_posi = -620;
    	}
    	if (_root.sectionName == "portfolio") {
    		_root.section.new_posi = -1280;
    	}
    	if (_root.sectionName == "contact") {
    		_root.section.new_posi = -1930;
    	}
    }
    example of the button scripts
    Code:
    on (press) {
    	_root.sectionName = "home";
    	_root.sectionopen();
    	_root.gotoAndPlay("home");
    }
    example of my timeline loop
    Code:
    new_posi = _root.section._x;
    this.xplacement.text = new_posi;
    trace(new_posi);
    if(_root.section._x <> 30){
    	_root.section.home._visible = false;
    	_root.gotoAndPlay(11);
    } else if(_root.section._x == 30){
    		_root.section.home._visible = true;
    			_root.gotoAndStop(10);
    }

    -John

    PS. im working with MX
    Attached Files Attached Files

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