Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Moving Items At The Same Time

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Moving Items At The Same Time

    Hi All,

    I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have
    Code:
     // Includes the tweening extensions.
    
    #include "mc_tween2.as"
    
    
    // Assigns each button its own functions.
    
    // Of course, these buttons were created at design time, on the Flash IDE itself.
    // Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
    // movieclip (or from some component).
    
    // This is an array, a list of the buttons used.
    var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];
    
    // Loops on all buttons from the first to the last one
    for (var i=0; i<myButtons.length; i++) {
    	// Sets its original X value. This will be used later for reference.
    	myButtons[i].originalX = myButtons[i]._x;
    	myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);
    
    	// When the mouse rolls over this menu option... go down just a bit.
    	// NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
    	// mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
    	myButtons[i].onRollOver = function() {
    				this.tween("_x", this.originalX + 5, 1);
    	};
    	// When the mouse exits the menu option.. go back up.
    	myButtons[i].onRollOut = function() {
    		this.tween("_x", this.originalX, 0.5);
    	};
    	// When the mouse clicks.. activate it!
    	myButtons[i].onRelease = function() {
    		this._parent.activateItem (this);
    		// *** Add some function here or somewhere else to handle real button actions!
    		trace ("Hey, button "+this+" was clicked.");
    	};
    }
    
    this.activateItem = function(item) {
    	// Function that activates a button.
    	
    	// Checks if there's an activated item already; if so, deactivates it.
    	if (this.currentItem != false) this.deActivateItem();
    	
    	// Activates it, finally
    	this.currentItem = item;
    	this.currentItem.alphaTo (100, 1); // makes it 'disabled'
    	this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
    };
    
    this.deActivateItem = function() {
    	// Deactivates the current activated menu item.
    	this.currentItem.enabled = true; // back to a normal button/movieclip
    	this.currentItem.alphaTo (100, 0.5); // back to its original opacity
    	this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
    	this.currentItem = undefined;
    };
    
    this.stop();

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You gave up on me already? Sheesh... LOL
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh no not at all! Please keep helping me! I just had a meltdown overnight and got desperate

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    ROTF. I know, I was just messing with you. I am still working on it. I thought I had it, but when I tested nothing worked, LOL

    Still thinking!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Someone somewhere posted this... It didn't really make sense to me but maybe it'll help?
    Add an onPress to myButtons[i] where you set a globalvariable to i , _root.currentButton = i;

    And before you set your onRollOut() you check if current i is equal to currentButton, if so, delete onRollOut, if less, make an onRollOut that goes to the left and if bigger make one that makes the buttons go to the right.

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well the first part means this:

    Code:
    myButtons[i].onRollOut = function() {
    		this.tween("_x", this.originalX, 0.5);
                    _root.currentButton = i;
    I understand what they mean by the second part, but not how to impliment it... hmmmmm
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    No, thats not right.. They want you to make a:

    Code:
    on(press){
        _root.currentButton = i;
    }
    Then they want you to set 3 onRollOut functions:

    Code:
    myButtons[i].onRollOut = function() {
    		this.tween("_x", this.originalX, 0.5);
    }
    then 2 more, one where the originalX is moved +1.5 and one where originalX is moved -.05

    Then on your buttons put something like:

    Code:
    on(release){
        if (i == 1){
            function1();
            else if (i >= 1){
                     function2();
                     else if (i <=1){
                              function3();
                      };
             };
    };
    Something like that.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD
    No, thats not right.. They want you to make a:

    Code:
    on(press){
        _root.currentButton = i;
    }
    Then they want you to set 3 onRollOut functions:

    Code:
    myButtons[i].onRollOut = function() {
    		this.tween("_x", this.originalX, 0.5);
    }
    then 2 more, one where the originalX is moved +1.5 and one where originalX is moved -.05

    Then on your buttons put something like:

    Code:
    on(release){
        if (i == 1){
            function1();
            else if (i >= 1){
                     function2();
                     else if (i <=1){
                              function3();
                      };
             };
    };
    Something like that.
    Hmmm I'm confused... Can you see that working?

  9. #9
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    About as much as you wanting to move all of them at the same time

    Seriously though, what I just wrote was a mere coded example of what the OP had stated in words. Will it work? In theory, yes, in practicality? I don't know.

    I still think you should do if/else statements for each button in that AS file.

    using button names. so something like:

    if _right1 is clicked, move _right1, _right2 to the right, etc....
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #10
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    But exactly HOW to do it will be the death of me!

Bookmarks

Posting Permissions

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