A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] [CS3] just missing something easy [AS3]

  1. #1
    Member
    Join Date
    Dec 2007
    Location
    Kirkland WA.
    Posts
    62

    resolved [RESOLVED] [CS3] just missing something easy [AS3]

    Trying to create a rotating knob i found this script and modified it for AS3 but I'm missing something easy.

    Code:
    onClipEvent (onEnterFrame){
    if (this.ok) {
    var xVar = _root._xmouse-this._x;
    var yVar = _root._ymouse-this._y;
    this._r = 180-(Math.atan2((xVar), (yVar))*(180/Math.PI));
    this._rotation = this._r;
    trace(this._r);
    }
    updateAfterEvent();
    }
    
    onClipEvent (onMouseDown){
    if (this.hitTest(_root._xmouse, _root._ymouse, 1))
    this.ok = true;
    }
    onClipEvent (onMouseUp){
    this.ok = false;
    }
    i recive this error
    Code:
    1087: Syntax error: extra characters found after end of program.
    any ideas?
    thank you in advance for your help

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    you modified that code for as3?!? There are sooo many reasons that it is NOT as3.
    • onClipEvent does not exist
    • _rotation property does not exist anymore
    • _root does not exist
    • _xmouse/_ymouse does not exist
    • updateAfterEvent() does not exist
    • etc, etc, etc...

    This code is nowhere near AS3. Work on just publishing it for AS2.

  3. #3
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    ^ True, that's everything but not AS 3.0
    It's AS 2.0 all the way...



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  4. #4
    Member
    Join Date
    Dec 2007
    Location
    Kirkland WA.
    Posts
    62
    Thank you guys for the heads up. I’m new, reading a lot and trying to learn. I guess I should have stayed in the newbie section. The rest of my project is in AS3 so I will try to update it for that. I have been getting a little confused some tutorials are in AS3 some in 2 same with the books I’m reading. And the next available Flash class I can take locally is not till the end of January. I will try to update my code and hopefully it will work

    Thank you again for your time

  5. #5
    Member
    Join Date
    Dec 2007
    Location
    Kirkland WA.
    Posts
    62
    I think i'm just making a mess with this conversion fron AS2 to AS3

    Code:
    this.knob.addEventListener(onEnterFrame);
    
    function rotate(evt:Event):void {
    if (this.ok) {
    var xVar = this.mouseX-this.x;
    var yVar = this.mouseY-this.y;
    this._r = 180-(Math.atan2((xVar), (yVar))*(180/Math.PI));
    this.rotation = this._r;
    trace(this._r);
    }
    updateAfterEvent():void
    }
    
    this.knob.addEventListener (onMouseDown){
    if (this.hitTest(this.mouseX, this.mouseY, 1))
    this.ok = true;
    }
    this.knob.addEventListener (onMouseUp){
    this.ok = false;
    }
    any help? please

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    yes, yes you are. you are using the event listeners completely wrong.

    Here is the proper syntax:
    Code:
    this.knob.addEventListener(Event.ENTER_FRAME, onEnterFrame);
    this.knob.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
    this.knob.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
    
    function onEnterFrame($e:Event):void
    {
         //whatever you want to do on enter frame
    }
    function onMouseDown($e:MouseEvent):void
    {
        //on mouse down
    }
    function onMouseUp($e:MouseEvent):void
    {
        //on mouse up
    }
    and for your reference, updateAfterEvent() has been changed to a method of the event object, so it'd be something like: $e.updateAfterEvent();

    You just in general have MANY MANY things wrong with this. It's not going to be an easy task, and more than likely, someone isn't just going to do it for you.

  7. #7
    Member
    Join Date
    Dec 2007
    Location
    Kirkland WA.
    Posts
    62
    Taco's friend (Nice), thanks for the help. I'm learning by doing and making mistakes (unfortunately the mistakes part is the part I'm best at) someday I hope to be able to help answer questions on this board, only on the newbie section I'm sure, but oh well. And I agree nobody should do my work for me. Your help has been greatly appreciated; I will see what I can come up with from here and not bug you again. Have a good holiday season.

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