A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [F8] onClipEvent conversion!!!

  1. #1
    Senior Member
    Join Date
    May 2000
    Posts
    814

    [F8] onClipEvent conversion!!!

    I have this code that makes my MC shake! I want to be able to activate it on a button press, but i'm having no luck with the syntax. (i just seems to move once, and not continuiously)

    onClipEvent (load) {
    //setting initiaion position
    cx = this._x;
    cy = this._y;
    }
    onClipEvent (enterFrame) {
    //causes the object to be offset
    this._x = cx+(Math.random()*5);
    this._y = cy+(Math.random()*5);
    }

    cheers
    Rat

  2. #2
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    code:
    //
    function shake(myMc, cx, cy) {
    onEnterFrame = function () {
    myMc._x = cx+(Math.random()*5);
    myMc._y = cy+(Math.random()*5);
    };
    }
    mc.onPress = function() {
    shake(this, this._x, this._y);
    };


  3. #3
    Senior Member
    Join Date
    May 2000
    Posts
    814
    cheers

    i will give it a go

  4. #4
    Senior Member
    Join Date
    May 2000
    Posts
    814
    I have another problem with a simliar code, i want to add the following code to a MC that is dynamically attached using code:

    PHP Code:
    onClipEvent (load) {
        
    _x 0;
        
    _y 0;
        
    speed 5;


    }
    onClipEvent (enterFrame) {

        
    endX _root._xmouse;
        
    endY _root._ymouse;
        
    _x += (endX-_x)/speed;
        
    _y += (endY-_y)/speed*1.5;
    updateAfterEvent();


    I havn't got a clue how to do it!!!

    rat

    *edit: please use PHP tags for code samples
    gparis
    Last edited by gparis; 08-31-2007 at 12:44 PM.

  5. #5
    Senior Member
    Join Date
    May 2000
    Posts
    814
    still not solved this, my code is a mess!!!

    it will allow me to get my dynamic attached MC to follow my mouse?

    rat
    Last edited by ratboy; 09-03-2007 at 04:54 AM.

  6. #6
    Senior Member
    Join Date
    May 2000
    Posts
    814
    hey i think i fixed it

    function follow() {

    onEnterFrame = function () {
    endY = _ymouse;
    _y+= (endY)/3;
    updateAfterEvent();
    };
    }

    follow(textBlock);

  7. #7
    Senior Member
    Join Date
    May 2000
    Posts
    814
    Hey i think i havn't! the above code moved my whole main MC. Doh
    although i am close!!

    PHP Code:
    function follow(MC) {
    onEnterFrame = function () {
    endY =_root._ymouse
    MC._y= (endY-_y); 
    updateAfterEvent(); 
    };
    }

    follow(shadows); 
    this allows my shadows MC to follow the verticl mouse monement, but i have lost my deceleration effect.

    any ideas!

    rat
    Last edited by ratboy; 09-03-2007 at 06:11 AM.

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