Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 4 of 4
  1. #1

    Default need help with mouse over movement

    hi there,

    i am in need of help with some code - i copied and pasted some old code into my file to make it move back and forth horizontally, and naturally it doesn't work. i originally got the code from a demonstration movie and i'm totally frustrated - what am i doing wrong?

    i'm kind of a novice at this, if my post hasn't made this obvious...

    the file is located at: http://www.littleigloo.com/hca_profiles05.fla

    this was the original code; i can't get it to work:

    onClipEvent (enterFrame) {
    if (_root.navOpen = 0) {
    direction = ((300-_root._xmouse)/20);
    if (((this._x>=400) && (direction>0)) || ((this._x<=200) && (direction<0))) {
    direction = 0;
    }
    this._x = this._x+direction;
    }
    }

    the code i have in there now moves it back and forth, but goes off the screen. when i add more of the old code back in, it doesn't work any more. sigh...

    it's late i know, i'm desperate. some help of what i can do to fix this is appreciated. thanks!! domenique.

  2. # ADS
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    I only have FlashMX so I can't view the demo file. The one thing I do notice in your code is an incorrect use of the equality operator.......

    if (_root.navOpen = 0)

    A single "=" sign assigns a value

    A double "==" sign compares a value

    So, the corrected code(without really understanding what your trying to do)....... would look like.......
    Code:
    onClipEvent &#40;enterFrame&#41; &#123; 
    if &#40;_root.navOpen == 0&#41; &#123; 
    direction = &#40;&#40;300-_root._xmouse&#41;/20&#41;; 
    if &#40;&#40;&#40;this._x>=400&#41; && &#40;direction>0&#41;&#41; || &#40;&#40;this._x<=200&#41; && &#40;direction<0&#41;&#41;&#41; &#123; 
    direction = 0; 
    &#125; 
    this._x = this._x+direction; 
    &#125; 
    &#125;
    Hope it helps
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  4. #3

    Default thanks for looking at the file

    it was a flash mx professional file, maybe it needs to be resaved. i tried the code and it didn't work for what i need - i need the movie clip in the 1st frame to move horizontally in both directions. thanks for looking at it tho : ) dom.

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    FlashMX and FlashMX2004 are different versions. Flash is backward compatable meaning FlashMX2004 can view FlashMX files but not vice versa. If your referring to a mouse based position scroller, maybe something like this.....

    Code:
    function accelScroller&#40;myTarget&#41; &#123;
    	myMiddle = Stage.width/2;
    	this.onEnterFrame = function&#40;&#41; &#123;
    		moveDist = myMiddle-_root._xmouse;
    		trace&#40;moveDist&#41;;
    		myTarget._x += moveDist/10;
    		if &#40;myTarget._x>Stage.width&#41; &#123;
    			myTarget._x = 0;
    		&#125; else if &#40;myTarget._x<0&#41; &#123;
    			myTarget._x = Stage.width;
    		&#125;
    	&#125;
    &#125;
    //Usage
    accelScroller&#40;_root.mcInstanceName&#41;;
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. pong collisions and movement
    By weefolk in forum Flash Scripting
    Replies: 1
    Last Post: 05-19-2006, 04:06 PM
  2. Need help with Character movement
    By lewmiszkin in forum Games
    Replies: 0
    Last Post: 12-14-2005, 05:37 AM
  3. Off screen movement
    By Um in forum Flash Scripting
    Replies: 11
    Last Post: 11-22-2005, 12:55 PM
  4. Replies: 9
    Last Post: 06-10-2005, 10:01 PM
  5. Hiding a mouse creating a new mouse and make that reveal?
    By orkdaorc in forum Flash Scripting
    Replies: 13
    Last Post: 10-17-2004, 08:25 AM

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
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial