Re: [Flapjax: 750] Digest for flapjax@googlegroups.com - 2 Messages in 1 Topic

8 views
Skip to first unread message

Nikita Dudnik

unread,
Aug 1, 2012, 3:14:22 AM8/1/12
to fla...@googlegroups.com
Hello.

I was trying to code something similar when I was learning flapjax.
Here is the result:

By the way you are storing a state related value in the "started" variable. It breaks the idea of representation of internal states using behaviors and will give you a lot of bug fixing headache when your project grows. In my example I have encapsulated mouse down, mouse up inside mouseIsDownB.

-- 
Nikita Dudnik

On Wednesday, August 1, 2012 at 12:35 , fla...@googlegroups.com wrote:

Group: http://groups.google.com/group/flapjax/topics

    Bennit <ben....@gmail.com> Jul 31 06:36AM -0700  

    In the example below I draw a line on a canvas element, however, after the
    line is drawn, the event stream for mousemove still fires events. Is there
    a way to force event streams to stop receiving events?
     
    Kind regards
    Ben
    ----
    // mode -- Line
    function modeLine(startX,startY) {

    function drawLine(x1,y1,x2,y2) {
    context.beginPath();
    context.moveTo(x1,y1);
    context.lineTo(x2,y2);
    context.stroke();
    context.closePath();
    }

    var lineE = receiverE(); // once a line event will be fired
    var started = true; // the drawing of this line operation has
    started
    var pointA = new Point(startX,startY); // the starting point
    var pointB = pointA; // the current ending point

    jQCanvas.fj('extEvtE','mousemove').mapE(function(mm){
    if(started) {
    redraw();
    drawLine(startX,startY,mm.layerX,mm.layerY);
    }
    else { console.log('mouse move event after stop');}
    });

    jQCanvas.fj('extEvtE','mouseup').onceE().mapE(function(mu){
    started = false;
    lineE.sendEvent(new Line(mu.layerX,mu.layerY));
    });

    return lineE;
    }

     

    Jay Shepherd <zys...@gmail.com> Aug 01 10:08AM +1200  

    Hi Ben. Checkout filterE, ill give you a better example when im on a pc
    :-)

     

You received this message because you are subscribed to the Google Group flapjax.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.

--
Flapjax home page: www.flapjax-lang.org
Flapjax list: groups.google.com/group/flapjax
Post: fla...@googlegroups.com
Unsubscribe: flapjax-u...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages