Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
Clukey #1
Nested Functions
I am trying to use nested functions in a floater i am building, and right after
I edit the js document and reload dreamweaver the functions work, but if I
reload dreamweaver again without making any changes to the file it says the
nested function does not exist. Can anyone help me figure this out? Thanks
Clukey Guest
-
#40765 [NEW]: calling backtrace inside nested static class functions causes segfault
From: ndroege at bimp dot de Operating system: linux debian PHP version: 5.2.1 PHP Bug Type: Reproducible crash Bug... -
Nested classes?
Hi I'm following the blog reader example in the 2nd chapter of the 'Developing Rich Clients with Macromedia Flex' book, but using Flex Beta 2. ... -
Nested Forms?
Hi I'm still working on my diploma. And I'm just getting started with CF. I have a regular form. In this form I integrated a Flashform. How can I... -
hittest: nested MCs
I have multiple dynamically duplicated objects, called "units". Let's say I have 2 at the point this code is executed: ... -
#10743 [Com]: class functions & PHP core functions inconsistently clash ;)
ID: 10743 Comment by: destes at ix dot netcom dot com Reported By: jjones at net-conex dot com Status: Open... -
envision3d #2
Re: Nested Functions
Exit DW and try deleting the cache fle located in the configuration folder. Then open dreamweaver and try the floater, but don't reload it, just restart it and see if it makes a difference.
envision3d Guest
-
Clukey #3
Re: Nested Functions
That works the first time also, but as soon as I restart DW it has recreated
the cache file so it stops working again. So, I would have to delete the cache
file every time I exit dreamweaver for that to work.
Clukey Guest
-
Randy Edmunds #4
Re: Nested Functions
What do you mean by "nested functions"?
Randy
> I am trying to use nested functions in a floater i am building, and right after
> I edit the js document and reload dreamweaver the functions work, but if I
> reload dreamweaver again without making any changes to the file it says the
> nested function does not exist. Can anyone help me figure this out?Randy Edmunds Guest
-
Clukey #5
Re: Nested Functions
For Example:
number1.number2()
function number1() {
function number2() {
alert("this is function number 2")
}
}
Clukey Guest
-
envision3d #6
Re: Nested Functions
Why are you doing a nested function? Why not just create 2 seperate functions and call one of the functions inside the other.
envision3d Guest
-
Clukey #7
Re: Nested Functions
Because I need two versions of most every function. What I mean is if a=b then
I have to use a different set of functions then if a=c; and both sets of
functions accomplish the same goal, but they have to do it in different ways.
And since I would rather not have to go through every function and put that IF
statement, I just nested them and call the one I need.
Clukey Guest
-
envision3d #8
Re: Nested Functions
Would an overloaded function be useful? I honelsty have never used or have experience with nested functions. Sorry I couldn't be of more help.
envision3d Guest
-
-
envision3d #10
Re: Nested Functions
An overloaded function is are functions that have the same name but different
input parameters list. like:
function tellMeAJoke()
{
arguments
}
function tellMeAJoke(int a, int b)
{
arguments
}
function tellMeAJoke(string a, string b)
{
arguments
}
As you can see each funtion has the same name and will perform the same taks,
but based on the different input parameters. If I didn't explain it well
enough, you good do a google search for overloaded functions. Maybe someone
else could explain it better than me.
envision3d Guest
-
envision3d #11
Re: Nested Functions
I just noticed that you might be calling your nested function incorrectly. You
just have to call the container function. So if you had your function:
function number1() {
function number2() {
alert("this is function number 2")
}
}
simply call number1()
Have a peak at this link:
[url]http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions#Nes[/url]
ted_functions_and_closures
envision3d Guest
-
Clukey #12
Re: Nested Functions
I didn't know about overloaded functions, thanks, but I don't think that would
help because the functions basically have the same args they just have parse
the data differently.
If I simply called number1() it would not run number2() because all functions
have to be called specifically, as with the link you gave, the container
function always called the nested function. Also, I know it is possible to use
number1.number2() because they work fine right after I edit the file.
Clukey Guest
-
envision3d #13
Re: Nested Functions
What if you were to create a function that would check your values and return
true or false. Something like:
function checkValues(a, b, c)
{
arguments
return whatever;
}
Then have your two functions. Then in your code just say something like:
if (checkValues(a,b,c) == something)
{
perform this function
}else{
perform the other function
}
I know you are using nested functions for a specific reason, but I am just
trying to help you find a way around this problem you are having with the
nested function.
Have you done a test? Maybe create a very simple behavior and use a nested
function. See if you have the same problem with that nested function as well.
If not, then there may be something else causing the problem.
envision3d Guest
-
Clukey #14
Re: Nested Functions
Thanks, the reason I am using nested functions is because I already have half
the functions built for this extension and I didn't want to have to go through
all 39 (give or take) functions and put a huge "if", it would take too long and
make the code harder to read, so I thought nesting them would be the easiest.
My other option I have thought might work is to have my code like this,
function number1(f, [arg1, arg2, ...])
switch(f) {
case 1:
number2();
break;
case 2:
number3(arg1, arg2, ...)
break;
}
function number2() {
...
}
function number3() {
...
}
Then call number1(...)
But I was really hoping to get the nested functions working because it would
still be easier and simpler, but if there is any other better way to do this I
would be fine with that.
I made a simple command that would just alert something, and the nested
function didn't work, so maybe dreamweaver doesn't support them, but I still
can't figure out why it works in the floater right after I edit the file.
Clukey Guest
-
Deaf Web Designer #15
Re: Nested Functions
Clukey,
I don't know what is your "comfort zone" or level of experience working with
javascript coding.
As for your quoted statement, "...so maybe dreamweaver doesn't support
them...", you know Dreamweaver is ideally a HTML authoring app. That is to say,
you know some fundamentals of HTML and understand how it works, then your skill
become more intitution with HTML works and what's not. With understanding of
how HTML works, and that you would be able to "troubleshoot" when HTML acts up
or why it doesn't work as intended.
That analogy with javascript as opposed to HTML, to code javascript, you need
to have some fundemantals of javascript coding. The more comfort zone and
knowledge, as well as hands-on coding with javascript will definitely be of an
asset to you to develop some javascript code to perform specific task you want.
So if javascript coding is totally new enviornment for you, perhaps you want
to go this route with possible two ways: search engine or book(s).
Have you tried to do a bit of research using Google or Yahoo to locate some
possible tutorial and step by step? Or you might want to consider to buy a book
about javascript. There are pretty darn good number of good books covering
javascript.
Hope that helps, no? Cheers, DWD (Brian)
Deaf Web Designer Guest
-
Clukey #16
Re: Nested Functions
Thanks for the advice, but javascript is by no means new to me. Although thats
not to say I know all there is to know, as I am sure I sometimes don't do
things in the most "proper" or efficient way, but I am more than competent in
the language.
What I have found out in recent learning is that calling a nested function in
the manner "function1.function2()" actually is not supported within javascript
itself, the reason I thought it was is that when I was first making my
extension I was using Dreamweaver MX and for some reason it worked flawlessly.
Although, now having upgraded to version 8 I realize they don't work quite as I
thought.
Now what I am looking for is sort of a "best practices" help from other
experienced javascripters on how to create two sets of functions with the same
goal yet different methods of getting to that goal. And as I have already
created one of the sets I would rather not have to do something to every
function, and I was hoping there was a broader way of going about this.
Any help that can be provided on this would be much appreciated.
Clukey Guest
-
Tom Muck #17
Re: Nested Functions
Are you trying to call these from your main floater code? In your example,
number2 is a local function that will only work from inside number1.
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
[url]http://www.tom-muck.com/[/url]
Cartweaver Development Team
[url]http://www.cartweaver.com[/url]
Extending Knowledge Daily
[url]http://www.communitymx.com/[/url]
"Clukey" <webforumsuser@macromedia.com> wrote in message
news:esa7e7$m4n$1@forums.macromedia.com...> For Example:
>
> number1.number2()
>
>
>
> function number1() {
> function number2() {
> alert("this is function number 2")
> }
> }
Tom Muck Guest
-
Clukey #18
Re: Nested Functions
Right, I realized that just recently, because originally I was using
Dreamweaver MX to make my extension and it actually worked. So, now I have 8
and it doesn't work so I looked into it and realized that can't be done. Thanks
Clukey Guest



Reply With Quote

