You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by myflashlab team <my...@gmail.com> on 2023/05/12 13:52:09 UTC

Trouble with removeBead

I have recently started to dig into ApacheRoyale. It's amazing but
documents are all over the place and it's very hard to find your way
around :) I have been trying to find answers without bothering anyone
but it seems like I cannot fix this one...

I have a list in which its content gets updated and sometimes its
items are draggable and sometimes not. I am able to correctly add the
drag functionality but then removeBead does not seem to work at all.

Any ideas?
Thanks in advance

var beadDragSrc:IBead =
_flex.subItemsList.getBeadByTy
pe(SingleSelectionDragSourceBead);
var beadDragImg:IBead =
_flex.subItemsList.getBeadByType(SingleSelectionDragImageBead);

if(isSortable)
{
if(!beadDragSrc)
{
beadDragSrc = new SingleSelectionDragSourceBead();
beadDragSrc["dragType"] = "move";
_flex.subItemsList.addBead(beadDragSrc);
}

if(!beadDragImg)
{
beadDragImg = new SingleSelectionDragImageBead();
_flex.subItemsList.addBead(beadDragImg);
}
}
else
{
if(beadDragSrc) _flex.subItemsList.removeBead(beadDragSrc);
if(beadDragImg) _flex.subItemsList.removeBead(beadDragImg);
}

Re: Trouble with removeBead

Posted by Yishay Weiss <yi...@hotmail.com>.
Hi,

Generally removing beads does not remove its functionality. A lot of the functionality (e.g., event listeners being registered) is done upon addition. The IBead interface has 'function set strand' which is called on addition, but not 'function removeFromStrand' to be called on removal, which means in general beads are not aware of their removal. The logic in that is that if a bead was added then its code has already been loaded and there's no significant performance gained from their removal.

If you want functionality that can be injected and then removed, you can create a bead that can react to the strand's state and turn itself off/on accordingly (see DisableBead), or contain a method of its own to turn off/on (maybe by extending an existing bead). Sometimes it makes sense to simply replace a strand that has a bead, with a new strand that does not contain that bead. Whatever makes sense in your app.

Hope this helps,
Yishay
________________________________
From: myflashlab team <my...@gmail.com>
Sent: Friday, May 12, 2023 4:52 PM
To: dev@royale.apache.org <de...@royale.apache.org>
Subject: Trouble with removeBead

I have recently started to dig into ApacheRoyale. It's amazing but
documents are all over the place and it's very hard to find your way
around :) I have been trying to find answers without bothering anyone
but it seems like I cannot fix this one...

I have a list in which its content gets updated and sometimes its
items are draggable and sometimes not. I am able to correctly add the
drag functionality but then removeBead does not seem to work at all.

Any ideas?
Thanks in advance

var beadDragSrc:IBead =
_flex.subItemsList.getBeadByTy
pe(SingleSelectionDragSourceBead);
var beadDragImg:IBead =
_flex.subItemsList.getBeadByType(SingleSelectionDragImageBead);

if(isSortable)
{
if(!beadDragSrc)
{
beadDragSrc = new SingleSelectionDragSourceBead();
beadDragSrc["dragType"] = "move";
_flex.subItemsList.addBead(beadDragSrc);
}

if(!beadDragImg)
{
beadDragImg = new SingleSelectionDragImageBead();
_flex.subItemsList.addBead(beadDragImg);
}
}
else
{
if(beadDragSrc) _flex.subItemsList.removeBead(beadDragSrc);
if(beadDragImg) _flex.subItemsList.removeBead(beadDragImg);
}