A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: The Hell's wrong with this?!

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    The Hell's wrong with this?!

    Hi guys
    Not sounding like it but I am seriously getting annoied by this thing, I managed to extract most AS faults but this one's getting on my nerves:

    code:

    onClipEvent (enterFrame) {
    for (i=3; i<40; i+1) {
    placeX = random(600)
    placeY = random(150)
    X duplicateMovieClip("shard","sard" add i, i)
    X setProperty("/sard" add i, _x,placeX)
    X setProperty("/sard" add i, _y,placeY)
    setProperty("/sard" add i,_rotation,random(1000))
    setProperty("/sard" add i,_xscale,random(50))
    setProperty("/sard" add i,_yscale,random(30))
    }
    }



    Now I marked X at the place that is wrong: they all say ')' or ',' expected.

    What in the bloody hell is wrong?!

    Thanks
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    119
    first of, this looks to be old script. its in slash syntax. From what I know, newer versions of flash are still backward compatible , but just to be on the safe side, you should get rid of the slashes

    setProperty("/sard" add i, _x,placeX)
    should be
    setProperty("sard" add i, _x,placeX)

    and change the "add" to +

    setProperty("sard" add i, _x,placeX)
    should be
    setProperty("sard" + i, _x,placeX)

    and to be on the even safer side, put a ";" at the end of each line

    setProperty("sard" + i, _x,placeX)
    should be
    setProperty("sard" + i, _x,placeX);

    thats the best I can give ya.
    and like I tell the others, Im still new to this, but Im trying to help where I can. So if im wrong, sorry.

    Cheers

    Mark

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Thanks but -
    I know but the new scripts don't even work for any of these.

    this is one of the example for the new scripts i originally wrote:

    _root.[sard+i]._x = random(somenumber)+somenumber

    But then they never work.
    Any other ideas?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    _root["sard"+i]._x = random(somenumber)+somenumber


    you dont put the "." in
    New sig soon

  5. #5
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    ?? come again?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  6. #6
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    dudeqwerty means refer to root as if its an array.

    Normal array refereces look like myArray[0]

    So if you think of all the instances in _root as array elements, you can refer to them as such:
    _root[myClip]._x

    And in this case you are evaluating the name of the clip instead of calling it out explicitly, so:

    _root["sard"+i]._x = ... //there is no dot between _root and [
    if i was equal to 1 for example, this would evaluate to
    _root.sard1._x =

  7. #7
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Sounds like I tried that before... I'll try it again
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  8. #8
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    well no, because if you did, it would have worked
    New sig soon

  9. #9
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    I don't really know I got really bad mem

    Thanks!
    Yep sorta works, new script with new problems:
    [AS]onClipEvent (enterFrame) {
    2 for (i=3; i<40; i+1) {
    3 placeX = random(600)
    4 placeY = random(150)
    5 rotationRad = random(1000)
    6 myscaleX = random(40)+13
    7 myscaleY = random(30)+5
    8 FaultX duplicateMovieClip("shard","sard" add i, i)
    9 _root["sard"+i]._x = placeX
    10 _root["sard"+i]._y = placeY
    11 _root["sard"+i]._rotation = rotationRad
    12 _root["sard"+i]._xscale = myscaleX
    13 _root["sard"+i]._yscale = myscaleY
    14 }
    } line 15 fault:Unexpected '}' encountered [AS]

    FaultX -> ')' or ',' expected.

    So these 2 faults still remain... any other solutions?
    thx
    Last edited by tongxn; 06-02-2006 at 04:41 PM.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  10. #10
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    shard.onEnterFrame = function() {
    for (i=3; i<40; i++) {
    placeX = random(600)
    placeY = random(150)
    rotationRad = random(1000)
    myscaleX = random(40)+13
    myscaleY = random(30)+5
    duplicateMovieClip("shard","sard" +i, i)
    _root["sard"+i]._x = placeX
    _root["sard"+i]._y = placeY
    _root["sard"+i]._rotation = rotationRad
    _root["sard"+i]._xscale = myscaleX
    _root["sard"+i]._yscale = myscaleY
    }
    }

  11. #11
    Senior Member
    Join Date
    May 2006
    Posts
    119
    back tracking a little bit.
    As per your origional post, this works
    --------------------------------------
    onClipEvent (enterFrame) {
    for (i=3; i<40; i+1) {
    placeX = random(600);
    placeY = random(150);
    duplicateMovieClip("shard","sard" + i, i);
    setProperty("sard" + i, _x,placeX);
    setProperty("sard" + i, _y,placeY);
    setProperty("sard" + i,_rotation,random(1000));
    setProperty("sard" + i,_xscale,random(50));
    setProperty("sard" + i,_yscale,random(30));
    }
    }

    as long as you are using the onClipEvent (enterFrame) in the right place ie: on a movie clip.

    if not, you will get this error

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Clip events are permitted only for movie clip instances
    onClipEvent (enterFrame) {

    Total ActionScript Errors: 1 Reported Errors: 1.

    Now I think what you need is some DE-BuGGING error lessons.
    --------------------------------------------------------------
    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1:
    // this tells you where the error is.

    when it says thing like
    "permitted only for movie clip instances"
    it means that there are different event handlers that can be used for mouse events, frame events, Movie clip events, and button event. this is telling you which is the case

    and when it say things like
    "unexpected "."
    that means there is a (what ever is in between the quotes) where it should not be, on the line stated
    OR
    "expected a "{"
    means there is NOT a (what ever is in between the quotes) when one is needed on the stated line.

  12. #12
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    i dont know if this will affect anything, but you should really end your lines with a semi-colon. i don tknow if that will throw up an error anywhere, but you shoudl just always use them

  13. #13
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Sorry I think my above script [//AS] lost you guys a bit.
    THIS IS ALL SET ON THE MOVIECLIP *shard
    code:
    onClipEvent (enterFrame) {
    for (i=3; i<40; i+1) {
    placeX = random(600)
    placeY = random(150)
    rotationRad = random(1000)
    myscaleX = random(40)+13
    myscaleY = random(30)+5
    duplicateMovieClip("shard","sard" add i, i)
    _root["sard"+i]._x = placeX
    _root["sard"+i]._y = placeY
    _root["sard"+i]._rotation = rotationRad
    _root["sard"+i]._xscale = myscaleX
    _root["sard"+i]._yscale = myscaleY
    }
    }


    on the last line, flash tells me:
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 15: Unexpected '}' encountered
    }
    and this:
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 8: ')' or ',' expected
    duplicateMovieClip("shard","sard" add i, i)
    So can anyone give me the solution to these problems?

    Thanks
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  14. #14
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    THIS IS ALL SET ON THE MOVIECLIP *shard

    this works for MX6 if the duplicateMovie code is on the movieclip, so try -
    Code:
    onClipEvent (enterFrame) {
    
    	for (var i=3; i<40; i++) { // note - i++ to increment variable i
    
    		placeX = random(600);
    
    		placeY = random(150);
    
    		rotationRad = random(1000);
    
    		myscaleX = random(40)+13;
    
    		myscaleY = random(30)+5;
    
    		cRef = this.duplicateMovieClip("sard" + i, i);
             // make a reference to the duplicated clip - cRef
    
    		cRef._x = placeX;
    
    		cRef._y = placeY;
    
    		cRef._rotation = rotationRad;
    
    		cRef._xscale = myscaleX;
    
    		cRef._yscale = myscaleY;
    
    	}
    
    }

  15. #15
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    its the "add" you should use standard operators,
    just change the "add" to a "+" :
    also the increment in your for loop is wrong:
    Code:
    onClipEvent (enterFrame) {
    	for (i=3; i<40; i++) {
    		placeX = random(600);
    		placeY = random(150);
    		rotationRad = random(1000);
    		myscaleX = random(40)+13;
    		myscaleY = random(30)+5;
    		duplicateMovieClip("shard", "sard"+i, i);
    		_root["sard"+i]._x = placeX;
    		_root["sard"+i]._y = placeY;
    		_root["sard"+i]._rotation = rotationRad;
    		_root["sard"+i]._xscale = myscaleX;
    		_root["sard"+i]._yscale = myscaleY;
    	}
    }
    @MyFriendIsATaco, its is proper to use semicolons, but it will no throw any errors if you dont use them in AS, but in other languages it will,
    also semicolons are useful because they let you put many statments on one line,

    HTH,

    zlatan
    New sig soon

  16. #16
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    beat me to it
    New sig soon

  17. #17
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Thanks! I'll try.
    But I don't think that will fix the last "}" on the last line.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  18. #18
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    OH Great it worked! Thanks a modified dog!
    Last edited by tongxn; 06-03-2006 at 09:06 AM.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

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