|
Now this I understand. And should work. Assuming of
course that we add a perentDoc member to the DynLayer.
wht I don't understand, is that with htis method,
why would you want to pass the doc argument?
Here's
the method that I have for adding Drag events to a layer:
DynEvent.Drag.enable=function(dlyr,doc) {
if (!dlyr.isLayer) return;
dlyr.addEventListener(DynEvent.Drag.lyrListener);
var
dyndoc=dlyr.frame.lyrobj||doc||AfroAPI.document;
if (dyndoc.dragCount==0) {
dyndoc.addEventListener(DynEvent.Drag.docListener);
dyndoc.dragEnabled=true; };
dyndoc.dragCount++; };
You will notice that each layer already contains a frame value that points
to the frame that it is contained in. This is automatically assigned
when a layer is added to a parent.
Using this method, I am also able to track the number of layers per
document that are "Drag Enabled". This makes it possible to
autometically remove the Listener when there are no longer any enabled layers
within that document.
Doug Melvin wrote:
Which dyndoc
property would that be?Also, I
do not want to be using any recursivefunction to determine the parent of every layerI pass to eneabledragevents() as this would
addundully to the amount of
prosessing that any app would do.
----- Original Message -----
Sent: Wednesday, October 31, 2001
7:32 PM
Subject: Re: [Dynapi-Dev]
enableDragevents across frames Why not just use the dyndoc
property of the layer and then it all you need to do is enable dragging
AFTER you have added it to a document. This removes any problems
with frames and dyndocuments being passed. This is what I did in the
AfroAPI and it seems to have no problems.
Doug Melvin wrote:
This is NOT fixed.Here is the function as
is:DragEvent.enableDragEvents=function(f) { for (var i=0;i<arguments.length;i++)
{ var
lyr=arguments[i]; if (lyr.isDynLayer)
lyr.addEventListener(DragEvent.lyrListener); } if(f.isDynDocument)
f.addEventListener(DragEvent.docListener); else
DynAPI.document.addEventListener(DragEvent.docListener);
}; No note: the functions assumes that if you are
passing a dyndocument, it will be 'f'.but 'f' is the FIRST
parameter. How do you
enabled drage events?enabledDragevents(theDocument,TheLayer)
?orenabledDragevents(TheLayer,theDocument) ? Taht's right!! the _OPTIONAL_ parameter should
be the second one.So:Calling
enabledDragevents(TheLayer,theDocument) wil _NOT_ cause the
doclistener to be addedto the correct frame as the functio n only checks
if the first argument (f) is a dindocument!!!!! FUCK! How may time do we need to go throught this? Now, a CORRECTED
function:DragEvent.enableDragEvents=function() { var DocAdded=false;
for (var
i=0;i<arguments.length;i++) { var lyr=arguments[i];
if(lyr){
if(lyr.isDynLayer){
lyr.addEventListener(DragEvent.lyrListener); }else
if(lyr.isDynDocument){
lyr.addEventListener(DragEvent.docListener); DocAdded=true;
}
} } if
(!DocAdded)DynAPI.document.addEventListener(DragEvent.docListener);
};Now this function does not cxare
WHAT order you pass your arguments in.Not only that, but _THIS ONE
WORKS_. scenerio.Two
Frames:One has the Dynapi.onload stuff in it.The other does not.the
frame that has DynAPI.onload in it creates aDynDocument reffering to the
other frame.A DynLayer is then added to the other frame.The dynlayer is
then mad draggable - _In the other frame!!_
I dare you to make this work with the
current function. so:var
myDynDoc = new DynDocument(top.frame2);var myLayer =
myDynDoc.addChild(new
DynLayer(null,10,10,100,100));DragEvent.EnableDragevents(myLayer,myDynDoc);
You may now drag the
layer. -- Michael Pemberton
[EMAIL PROTECTED] ICQ: 12107010
-- Michael Pemberton [EMAIL PROTECTED] ICQ: 12107010
|