Skip to main content
Inspiring
August 29, 2007
Question

Behaviors without helper functions

  • August 29, 2007
  • 3 replies
  • 291 views
Hi all, I'm trying to create a behavior that doesn't require a behavior
function, is this possible using the behaviors API?
Dreamweaver requires a behaviorFunction() function in behaviors, and
returnig an empty string results in a message "The Action will not be
applied".

Is it possible to insert behaviors without a behaviorfunction?
Sure I can create proxy functions that in turn call the actual command (eg
alert()) but this seems a lot of overhead to put into the document.

Joris

This topic has been closed for replies.

3 replies

Inspiring
August 29, 2007
In exchange for this overhead, you have the DW API adding all the
functionality of the Behaviors Window and its helper functions,
including removal of all your code from the head of the page when you've
deleted the last instance of yoru behavior from the body, allowing users
to select events from a dropdown, etc.

--


E. Michael Brandt

www.divaHTML.com
divaPOP : standards-compliant popup windows
divaGPS : you-are-here menu highlighting
divaFAQ : FAQ pages with pizazz

www.valleywebdesigns.com
JustSo PictureWindow
JustSo PhotoAlbum

--
Inspiring
August 29, 2007


"E Michael Brandt" <michael@valleywebdesigns.com> wrote in message
news:fb3rqv$qv3$1@forums.macromedia.com...
>
> If you read the Extension help you'll see that certain functions are
> indeed required by each type of Extension, whether Behavior, Command, or
> Object. And certain methods are disallowed by each type as well.
>

Yes i have the manual in front of me, i'm building a behavior to call
commands in the AIR runtime, the air object is just available in the
document when the AIRAliases.js is included, it doesn't need a "helper"
function.
So what i'm doing now is inserting a proxy function to call the original
function, return the name of the proxy function from behaviorFunction and
wrap the call, that just seems like a lot of overhead.

Joris



function AIR_exec(cmdName) { //v1.0
if(typeof air != 'Object'){
alert('ERROR: AIR object not loaded, please include AIRAliases.js');
} else {
var cmd = 'air.'+cmdName+'(';
for(var i=1; i<arguments.length; i++){
cmd += (i==1) ? arguments : ','+arguments;
}
cmd += ')'
eval(cmd);
}
}

//Return the name of the function that we want to be inserted into the
user's document.
function behaviorFunction(){
return "AIR_exec";
}

//Returns the actual function call string that will be inserted into the
event handler
function applyBehavior() {
addAIRAliases();
return "AIR_exec('trace',"+document.theForm.traceMessage.value+")";
}

Inspiring
August 29, 2007

If you read the Extension help you'll see that certain functions are
indeed required by each type of Extension, whether Behavior, Command, or
Object. And certain methods are disallowed by each type as well.

--


E. Michael Brandt

www.divaHTML.com
divaPOP : standards-compliant popup windows
divaGPS : you-are-here menu highlighting
divaFAQ : FAQ pages with pizazz

www.valleywebdesigns.com
JustSo PictureWindow
JustSo PhotoAlbum

--