dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: need help centering a movie clip...stupid syntax errors...can't shake em

  1. #1

    Smile

    alright i'm using this code to center a movieclip which has buttons inside of it based on which button they push...the button which is pushed should go to the center of the screen

    on (press) {
    xposition = _xmouse;
    yposition = _ymouse;
    newxposition=0-xposition;
    _root.entire_movie*movieclip._x=newxposition;
    newyposition=0-yposition;
    _root.entire_movie*movieclip._y=newyposition;
    }

    but i keep getting this syntax error

    Symbol=entire_movie*movieclip, Layer=actions, Frame=2: Line 5: Left side of assignment operator must be variable or property.
    _root.entire_movie*movieclip._x=newxposition;

    Symbol=entire_movie*movieclip, Layer=actions, Frame=2: Line 7: Left side of assignment operator must be variable or property.
    _root.entire_movie*movieclip._y=newyposition;

    what do i do?

    thanks,

    yim

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    266
    Hi,

    It's quite difficult to see what you are trying to do, but what is _root.entire_movie ???? A movie clip I presume?

    Your code is very wrong around this line.

    The * character is used for mathematical multiplication!!!!

    So flash is trying to read what you have typed on the left of the * as a variable, and multiply it by what you have typed on the right of the *.

    The line above is always going to return a negative value because you are deducting the x co-ord of the mouse from 0.

    I think you are trying to be too advanced.

    Go back to basics and get to this after the basics.

    Dan.


  3. #3
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    this code should do it (have not tested it)
    Code:
    on(press){
       //were mc is the mc that you wish to center
      _root.mc.onEnterFrame=function(){
         xDest=_root._width/2;
         yDest=_root._height/2;
         //fastest tween if speed=2
         speed=5;
            if (mc._x<xDest-1) {
    		xDist = xDest-mc._x;
    		mc._x = mc._x+xDist/speed;
    	}
    	if (mc._x>xDest+1) {
    		xDist = mc._x-xDest;
    		mc._x = mc._x-xDist/speed;
    	} 
    	if (mc._y<yDest-1) {
    		yDist = yDest-mc._y;
    		mc._y = mc._y+yDist/speed;
    	}
    	if (mc._y>yDest+1) {
    		yDist = mc._y-yDest;
    		mc._y = mc._y-yDist/speed;
    	}
        }
    }
    BTW make any mathematical operations on the left side of the =

    /good luck on the eternal journey through knowledge

  4. #4
    Danny Gomez Creations cosmiceye's Avatar
    Join Date
    Mar 2002
    Location
    under a palmtree in Jamaica waiting for psytopia 2005 to begin
    Posts
    982
    sorry, I meant "BTW NEVER make any mathema...blabla.."

  5. #5

    Smile thanks for the help but...

    thanks for the help you guys...but dan i think your mistaken...i know the the * sign is for multiplication but the name of my movie clip is actually called "entire_movie*movieclip" so that is why the * is in there...also...it won't always give a negative value because subtracting a negative will give you a positive (simple grade school math)...anyways i figured out what the problem is...in mx to change the x or y value using the _x or _y properties you need to have a += at the end of the statement...not just a =...thanks anyways guys...

    yims
    *btw...i'll think about what you said about going back to basics...i really don't know what i'm talking about with this stuff anyways...:-)

  6. #6
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    Just for the record, variable names/instance names/any other names you can think of cant have *'s in them.

    Infact you cant use any of these:

    = + - [ ] { } ; : ' " > < / \ ! @ # % ^ & * ` ~ | . , etc...

  7. #7
    chatbugs.com ***** flashTampaDotCom's Avatar
    Join Date
    Mar 2002
    Location
    Tampa, Florida
    Posts
    171
    Just a question:
    Why would you use an asterisk within the name of a Movie Instance in the first place? Holy Confusing Batman!

    Perhaps its a poster-child example for a Tylenol Commercial!.. Yeah! I can see the caption now...

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