Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : cellrenderer and dragging



ctvrtlik
4/23/2004 10:07:27 PM
any reasons why the following snippet doesn't work in a cellrenderer?

function onPress() {
trace("pressed");


var newclip = this.duplicateMovieClip("newClip", DepthManager.kTopmost);

newclip.onPress = function() {
trace("xxx " + this);
this._alpha = 50;
this.startDrag();
}

newclip.onRelease = function() {
trace("released");
this.stopDrag();
}
}
kglad
4/24/2004 4:14:00 PM
onPress() is a poor choice for an author defined function. you should change
that. and your use of "this" in your duplicateMovieClip statement is going to
refer to the timeline that contains that code. i'm not sure that's what you
want.
ctvrtlik
4/24/2004 5:43:56 PM
ultimately what i am trying to do, is to be able to drag a copy of a cell in a
datagrid. so "onPress" of a cell, i want to dupe the cell and then make that
dupe draggable. you are correct in that i don't want to attach to the "this"
timeline, but i was just doing it for testing purposes.

also, why is the onPress a poor choice? if my cellrenderer extends
UIComponent, i'm free to implement that callback function as i want.
kglad
4/24/2004 8:15:33 PM
onPress() is used by flash as an event handler so, in general, it's a bad idea
to reuse a flash object or method or function name.

if you're trying to attach an onPress() event to a data cell why don't you use
cellPress()?
AddThis Social Bookmark Button