Ask a Question related to Macromedia Flash Sitedesign, Design and Development.
-
Bill Murphy #1
Help with text boxes and If's
[url]http://www.purplealien.net/lightdwarf/test/[/url]
This is where you will find my little fun name generator. I like it so far.
The problem is that if someone leaves a field blank then the "us" still
appears on the scroll. This is not good. I am trying to get the Action
script so that if the field is blank then it will just leave the
corresponding text box blank as well. I am not getting it right. This is
what I have so far. With some variations as I am trying to figure it out.
Any suggestions would be excellent. Thanks in advance.
on (release) {
given = (_root.given.text);
if (given = "") {
_root.givenhg.text = " ";
} else {
_root.givenhg.text = ""+given+"us";
}
}
on (release) {
family = (_root.family.text);
if (family = "") {
_root.familyhg.text = " ";
} else {
_root.familyhg.text = ""+family+"us";
}
}
Bill Murphy
E-mail: [email]billmurphy@sympatico.ca[/email]
"Communication is everything, without it we have nothing."
Bill Murphy Guest
-
Pasting text with autoformatting in few text boxes
My main problem is how to paste to 3 separate text-boxes plain text like this and have it formatted automaticly: 700,000 Cliff Road, Tramore,... -
Text boxes like this...
Hi there, does anyone know if there is Flash drawing tool used to create static text boxes like this: http://www.aroots.com/ If not in... -
Hyperlink text issue, two text boxes, one disfuntional
Hi, I have created a frame in director with two buttons and two text documents. When you click one button, you see a text document, when you click... -
Deleting text from text boxes
a "footer" on this document. I actually discovered this feature myself by accident the other day. In the document, click on "view" and drag down... -
seperating columns in a text box into multiple text boxes?
Berney: You probably are better off doing this separating in the query data source for your form. You can use string commands to find which... -
rlc5611 #2
Re: Help with text boxes and If's
You need to check for something more than "".
First of all add trace(given) for debugging so you can see what given really
is. "" is defined. It could be that the variable is still undefined. If you see
that this is happening, change your code to if(given == "" or given ==
undefined)...
By running the trace, you should see what you need to check for.
rlc5611 Guest
-
Bill Murphy #3
Re: Help with text boxes and If's
on (release) {
given = (_root.given.text);
family = (_root.family.text);
if (family == undefined && given == undefined) {
_root.givenhg.text = " ";
_root.familyhg.text = " ";
} else if (family == undefined) {
_root.familyhg.text = " ";
_root.givenhg.text = ""+given+"us";
} else if (given == undefined) {
_root.givenhg.text = " ";
_root.familyhg.text = ""+family+"us";
} else {
_root.givenhg.text = ""+given+"us";
_root.familyhg.text = ""+family+"us";
}
trace(given);
trace(family);
}
The above is my new code that I am now trying. Thanks to rlc5611 for the
direction. Now I am still having some problems. It seems to work for the
first try. Then it just keep returning a Undefined for both given and
family. On the first try it doesn't fully work because it still gives "us"
results. Any ideas would be greatly appreciated.
Bill Murphy
E-mail: [email]billmurphy@sympatico.ca[/email]
"Communication is everything, without it we have nothing."
On 4/5/04 5:52 AM, in article c4ra99$gqk$1@forums.macromedia.com, "rlc5611"
<webforumsuser@macromedia.com> wrote:
> You need to check for something more than "".
>
> First of all add trace(given) for debugging so you can see what given really
> is. "" is defined. It could be that the variable is still undefined. If you
> see
> that this is happening, change your code to if(given == "" or given ==
> undefined)...
>
> By running the trace, you should see what you need to check for.
>
Bill Murphy Guest
-
rlc5611 #4
Re: Help with text boxes and If's
Working with things that are (possibly) unitialized is always difficult. Try
forcing the variable to something known prior to asking for its input. Force
the variable to "" or null prior to the check. I prefer the null as "" is still
something even though it is apparently nothing.
rlc5611 Guest
-
Bill Murphy #5
Re: Help with text boxes and If's
on (release) {
given = (_root.given.text);
family = (_root.family.text);
if (family == "Type here." && given == "Type here.") {
_root.givenhg.text = " ";
_root.familyhg.text = " ";
} else if (family == "Type here.") {
_root.familyhg.text = " ";
_root.givenhg.text = given+"us";
} else if (given == "Type here.") {
_root.givenhg.text = " ";
_root.familyhg.text = family+"us";
} else {
_root.givenhg.text = given+"us";
_root.familyhg.text = family+"us";
}
trace(given);
trace(family);
}
This is what I am trying now. It is not that it doesn't work. It just does
not work the second time you try it. The first time it works just fine and
then if I think of another name I want to try it out. I enter it and then
the given and family return undefined. They will always, after the first
try, return undefined. I do not get it.
Bill Murphy
E-mail: [email]billmurphy@sympatico.ca[/email]
"Communication is everything, without it we have nothing."
On 4/5/04 11:44 PM, in article c4t93i$huf$1@forums.macromedia.com, "rlc5611"
<webforumsuser@macromedia.com> wrote:
> Working with things that are (possibly) unitialized is always difficult. Try
> forcing the variable to something known prior to asking for its input. Force
> the variable to "" or null prior to the check. I prefer the null as "" is
> still
> something even though it is apparently nothing.
>Bill Murphy Guest
-
rlc5611 #6
Re: Help with text boxes and If's
I tried the URL and could not see where you are using "Type here." anywhere but
maybe you have not yet posted that mod. Can you put the mod on your site so I
can see what you are saying?
Also, depending on how your clips are set up in which timelines, your script
could cause problems. I would recommend to be safe that you not have a variable
with the same name as a movie clip (i.e. "given").
thanks,
rlc5611 Guest
-
Bill Murphy #7
Re: Help with text boxes and If's
Thanks for all your help so far rlc5611.
I did change what you suggested. Now it is not working at all. I am really
not understanding Action script. Several times I had it so what I thought
should work. Once I get this to work I will probably not know why I didn't
see it before. Anyway it is up now in all its wrong glory.
[url]http://www.purplealien.net/lightdwarf/test/[/url]
Thanks again for anyone's help.
Bill Murphy
E-mail: [email]billmurphy@sympatico.ca[/email]
"Communication is everything, without it we have nothing."
PS: the code as it is now.
on (release) {
gn = (_root.given.text);
fn = (_root.family.text);
if (fn == "Type here." && gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = "";
} else if (fn == "Type here.") {
_root.familyhg.text = "";
_root.givenhg.text = given+"us";
} else if (gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = family+"us";
} else {
_root.givenhg.text = gn+"us";
_root.familyhg.text = fn+"us";
}
trace(given);
trace(family);
}
On 4/6/04 4:42 AM, in article c4tqgu$a8j$1@forums.macromedia.com, "rlc5611"
<webforumsuser@macromedia.com> wrote:
> I tried the URL and could not see where you are using "Type here." anywhere
> but
> maybe you have not yet posted that mod. Can you put the mod on your site so I
> can see what you are saying?
>
> Also, depending on how your clips are set up in which timelines, your script
> could cause problems. I would recommend to be safe that you not have a
> variable
> with the same name as a movie clip (i.e. "given").
>
> thanks,
>Bill Murphy Guest
-
rlc5611 #8
Re: Help with text boxes and If's
i'll go look. Don't forget to change the two traces at the bottom. Should be trace(gn) and trace(fn)
rlc5611 Guest
-
rlc5611 #9
Re: Help with text boxes and If's
yes the traces are causing the biggest problem at the moment. You are now tracing the movie clips instead of variables. Change them as I said in previous post.
rlc5611 Guest
-
rlc5611 #10
Re: Help with text boxes and If's
Also you did not change all the occurences of your original "family" and
"given" variables. Look on lines 9 and 12 of your script. Those variables are
now undefined. change it to fn + "us" and gn + "us" to fix that bug.
rlc5611 Guest
-
rlc5611 #11
Re: Help with text boxes and If's
I have found it useful in testing these logicals to see which branch you are
actually following. Please try the following which will give you feedback on
what your logic is actually doing:
on (release) {
gn = (_root.given.text);
fn = (_root.family.text);
if (fn == "Type here." and gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = "";
wasentered = "neither";
} else if (fn == "Type here.") {
_root.familyhg.text = "";
_root.givenhg.text = gn+"us";
wasentered = "given only";
} else if (gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = fn+"us";
wasentered = "family only";
} else {
_root.givenhg.text = gn+"us";
_root.familyhg.text = fn+"us";
wasentered = "both";
}
trace(wasentered);
}
If you will try this you should be able to see what the logical error. I just
spotted it myself. You will need to modify your two middle else if statements
to something like:
} else if (fn == "Type here." and not gn == "Type here.") {
and
} else if (gn == "Type here." and not fn == "Type here.") {
at least I think that is right.
rlc5611 Guest
-
rlc5611 #12
Re: Help with text boxes and If's
I have found it useful in testing these logicals to see which branch you are
actually following. Please try the following which will give you feedback on
what your logic is actually doing:
on (release) {
gn = (_root.given.text);
fn = (_root.family.text);
if (fn == "Type here." and gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = "";
wasentered = "neither";
} else if (fn == "Type here.") {
_root.familyhg.text = "";
_root.givenhg.text = gn+"us";
wasentered = "given only";
} else if (gn == "Type here.") {
_root.givenhg.text = "";
_root.familyhg.text = fn+"us";
wasentered = "family only";
} else {
_root.givenhg.text = gn+"us";
_root.familyhg.text = fn+"us";
wasentered = "both";
}
trace(wasentered);
}
If you will try this you should be able to see what the logical error. I just
spotted it myself. You will need to modify your two middle else if statements
to something like:
} else if (fn == "Type here." and not gn == "Type here.") {
and
} else if (gn == "Type here." and not fn == "Type here.") {
at least I think that is right.
rlc5611 Guest
-
Bill Murphy #13
Re: Help with text boxes and If's
Thank you thank you thank you. You stuck with me and this project. I really
want to thank you. It is pretty much ready now. I just added a new part.
Some name will now show specific results. I can add as many name as I like
into the code. Thanks again.
on (release) {
gn = (_root.given.text);
fn = (_root.family.text);
if (fn == "" && gn == "") {
_root.givenhg.text = "";
_root.familyhg.text = "";
} else if (gn == "Jervis" && fn == "Johnson") {
_root.givenhg.text = "Fanaticus";
_root.familyhg.text = "Lordus";
} else if (gn == "Scott" && fn == "Kelly") {
_root.givenhg.text = "Light Dwarfus";
_root.familyhg.text = "Funnyus";
} else if (gn == "") {
_root.givenhg.text = "";
_root.familyhg.text = fn+"us";
} else if (fn == "") {
_root.familyhg.text = "";
_root.givenhg.text = gn+"us";
} else {
_root.givenhg.text = gn+"us";
_root.familyhg.text = fn+"us";
}
trace(gn);
trace(fn);
}
you can find it at [url]http://www.purplealien.net/lightdwarf/test/[/url]
Thanks again for all your help.
Bill Murphy
"Communication is everything without it we have nothing."
On 4/7/04 9:23 AM, in article c50vch$s1d$1@forums.macromedia.com, "rlc5611"
<webforumsuser@macromedia.com> wrote:
> I have found it useful in testing these logicals to see which branch you are
> actually following. Please try the following which will give you feedback on
> what your logic is actually doing:
>
> on (release) {
> gn = (_root.given.text);
> fn = (_root.family.text);
> if (fn == "Type here." and gn == "Type here.") {
> _root.givenhg.text = "";
> _root.familyhg.text = "";
> wasentered = "neither";
> } else if (fn == "Type here.") {
> _root.familyhg.text = "";
> _root.givenhg.text = gn+"us";
> wasentered = "given only";
> } else if (gn == "Type here.") {
> _root.givenhg.text = "";
> _root.familyhg.text = fn+"us";
> wasentered = "family only";
> } else {
> _root.givenhg.text = gn+"us";
> _root.familyhg.text = fn+"us";
> wasentered = "both";
> }
> trace(wasentered);
> }
>
> If you will try this you should be able to see what the logical error. I just
> spotted it myself. You will need to modify your two middle else if statements
> to something like:
>
> } else if (fn == "Type here." and not gn == "Type here.") {
>
> and
>
> } else if (gn == "Type here." and not fn == "Type here.") {
>
> at least I think that is right.
>Bill Murphy Guest
-
rlc5611 #14
Re: Help with text boxes and If's
As my father always told me - if it ain't broke don't fix it BUT......
If you store your name pairs in arrays, you could perform the tests in a
simple loop and it would greatly clean up your script.
Make it do what you want first. Optimize it later. Just always keep a backup
copy that works.
rlc5611 Guest



Reply With Quote

