A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Mouse angle relative to MC with fscommand

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    7

    Mouse angle relative to MC with fscommand

    Hi

    I am relatively knew to flash, so forgive me any misspelling.

    I have a MC in the library which is put in the scene by a function containting attachMovie, giving each new MC instance in the scene an individual movie clip name.

    Now with the action script below, which is nested in the MC instance in the library, I am able to access the name of each newly created MC in the scene.

    Now if possible, I would like to do the following:

    When I press on the MC and then again press somewhere in the scene it gives me the angle from the MC relative to the point I clicked in the scene. And if I click again on the movie clip it stops updating the angle.

    After all of this I would like to send the angle received from this procedure with an argument by fscommand. Now I don't know if I need to make any knew frames for this in the timeline and what to write there or if this is even possible with nested scripts like this. But yeah, any help is apreciated and I hope somebody can even understand what I wrote.

    onPress = function()
    {
    var args = this._name;

    fscommand("Symbols", args);

    /*var xDiff = Root_Radar.MiniMap._xmouse - this.lastX;
    var yDiff = Root_Radar.MiniMap._ymouse - this.lastY;*/

    }

  2. #2
    Junior Member
    Join Date
    Jul 2014
    Posts
    7
    Leaving the relative angle on the side at the moment, I am trying to trace just the x distance after clicking the symbol

    Currently I have in the first frame code:

    onPress = function ()
    {


    nextFrame();


    }

    And in the second frame this one here:

    var mouseListener:Object = new Object

    mouseListener.onMouseDown = function() {

    xdist = Math.round(this._xmouse - _parent._x);
    ydist = Math.round(this._ymouse - _parent._y);
    distancefromthis = Math.round(Math.sqrt((xdist*xdist) + (ydist*ydist)));

    trace(xdist);

    };

    Mouse.addListener(_parent.mouseListener);

    But its not working yet. I don't know if its possible to attach a mouselistener to a symbol which is created from an instance from the library...

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    7
    Ok, i think I have a setup which seam to be kinda working. But I can not make the mouse listener stop listening after I click the movie clip the second time:

    2nd frame:

    stop();

    var mouseListener:Object = new Object

    mouseListener.onMouseDown = function() {

    xdist = Math.round(_xmouse - _parent._x);
    /*ydist = Math.round(this._ymouse - _parent._y);*/
    distancefromthis = Math.round(Math.sqrt((xdist*xdist) + (ydist*ydist)));

    trace(xdist);

    };

    Mouse.addListener(mouseListener);



    3rd frame

    onPress = function ()
    {

    Mouse.removeListener(mouseListener);

    stop();


    }

    Does the 3rd frame even recognize the listener from the 2nd frame? The thing I'd like to do is that it stops updating the x position after I click the move licp the second time. Then make the whole process start from beginning (if click update, if clicked again dont update).
    Last edited by spaceharry; 07-13-2014 at 02:41 PM.

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    7
    I put the code from the 3rd frame in the 2nd and go back to the first fram with gotoAndStop, which seams to work. Guess that kinda solves my problem.

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