Click and Drag multi-selection rectangle with Javascript

This is a nice solution for a problem occured when making strategy games or wireframe applications. Or generally when we want to select multiple items and have them in a visible group.
It is a rather simple solution once the math make sense.

Here’s a nice example I made on codepen. Simply click and drag to form a rectangle around one or both of the objects.

See the Pen Multiselect drag by Michael Dobekidis (@netgfx) on CodePen.

Continue reading

Facebooktwittergoogle_pluspinterestlinkedin
linkedin

Prevent MouseWheel scroll on TextArea Flex(3.4)

I’ve had a really hard time figuring this out, plus I couldn’t find a viable solution through web-search. So I’m posting my solution with full code.
This example also shows how to set focus on a textArea simply by mouseOver it.

<mx:Script&gt
<![CDATA[
public function setScroll(event:Event):void{

try
{
event.target.mx_internal::getTextField().mouseWheelEnabled=false;
}
catch (err:Error)
{

trace(err.message);
}
finally
{
// event.verticalScrollPosition=0;
}
}

private function setFocusOnStart(event:Event):void
{
stage.focus=InteractiveObject(event.currentTarget);
}
]]&gt
</mx:Script&gt

<mx:TextArea id=”gta1″ width=”540″ height=”92.5″ editable=”false” mouseOver=”setFocusOnStart(event)” wordWrap=”true” borderStyle=”none” fontSize=”13″ verticalScrollPolicy=”off” leading=”4″ kerning=”true” letterSpacing=”0″ maxChars=”400″ selectable=”false” backgroundAlpha=”1.0″ paddingBottom=”0″ liveScrolling=”false” creationComplete=”setScroll(event);”&gt

enjoy!

Facebooktwittergoogle_pluspinterestlinkedin
linkedin