all groups > flash actionscript > june 2004 >
You're in the

flash actionscript

group:

Marquees w/ AS 2.0


Marquees w/ AS 2.0 Ken Silanskas
6/30/2004 1:43:21 PM
flash actionscript:
Hi all,
It's been a while since I posted last. I was wondering if anyone could
tip their hat in the right direction for me on a piece of functionality I'd
like to add to an application of mine. In Windows, when you click on a blank
space and drag, you get that translucent marquee that selects things as you
go over them. Here's what I have in my app that I'd like to simulate that
behavior...

1. 100 Checkboxes in a grid (As an example)
2. Rather than have the user click each box individually to select them, I'd
like to try implementing a piece of code that will keep redrawing a square
as I drag the mouse. The same as you would see in Windows. As the square
covers the checkboxes, it should select them and deselect them as it comes
off of them.

Could someone point me in the right direction?

-Ken

Re: Marquees w/ AS 2.0 mrism
8/20/2004 9:44:37 AM
Hi Ken

Did you manage to get it work? I am trying something similar. Could share the trick?
Re: Marquees w/ AS 2.0 PBKing
8/20/2004 2:00:42 PM
Hm. Interesting problem. Neat idea.

working . . .

just worked out a proof of concept. Box only opens down and right, but you
get the idea and can clean it up . . .

Essentially, on mousDown, I'm attaching a box (to _root). This
box.onEnterFrame expands to the appropriate size.

onMouseUp removes the box.

The checkboxes have an onEnterFrame action on them that hitTest's a point on
it (right over the checkbox) to see if it intersects with the box that was
made. If true, it checks. If false it unchecks. Again, you'll have to clean
that up for real use.

You could clean that up a lot using classes and whatnot. Hope that helps.
That was an interesting problem to solve. See the attached files for my take
on the matter.





//root--------------------------------------------------------

var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
tempObj = new Object();
tempObj._x = _xmouse;
tempObj._y = _ymouse;
tempObj.xOrig = _xmouse;
tempObj.yOrig = _ymouse;
_root.attachMovie("expandableBox", "expandableBox",
this.getNextHighestLevel(), tempObj);
delete tempObj;
};

mouseListener.onMouseUp = function() {
_root.expandableBox.removeMovieClip();
};

Mouse.addListener(mouseListener);

//expandable box------------------------------------------
onEnterFrame = function(){
this._width = this._parent._xmouse - xOrig;
this._height = this._parent._ymouse - yOrig;
}



//checkBoxes------------------------------------------------
onClipEvent(enterFrame){
if(this._parent.expandableBox.hitTest(this._x+11, this._y+7)){
this.selected = true;
} else {
this.selected = false;
}
}
Re: Marquees w/ AS 2.0 mrism
8/20/2004 2:24:53 PM
AddThis Social Bookmark Button