[BNM] Flash "if" statement @
Robert Stevens
robs_here at btinternet.com
Wed Nov 1 11:08:16 GMT 2006
Seb',
Thanks! Yes indeed - work fine now.
Cheers again,
Rob
--- Seb L <pluginseb at gmail.com> wrote:
> Try :
>
> if (emailAddress.indexOf("@")>=0) instead of if
> (emailAddress.indexOf("@"))
>
> indexOf returns -1 if the character isn't found
> within the string,
> otherwise it returns the position index of the found
> character. If you
> test a number as a boolean, it only returns true if
> the number == 1,
> as per this example :
>
> var num:Number;
> num = -1;
> trace(num==true); // displays "false"
> num = 0;
> trace(num==true); // displays "false"
> num = 1;
> trace(num==true); // displays "true"
> num = 2;
> trace(num==true); // displays "false"
>
>
> Hope this helps!
>
> cheers
> Seb Lee-Delisle
> http://sebleedelisle.com
>
> On 01/11/06, Robert Stevens
> <robs_here at btinternet.com> wrote:
> > Seb,
> >
> > Thanks for your reply.
> > Dunno, can't seem to get it working.
> >
> > Here's example of the code:
> > _root.form.my_btn.onRelease = function() {
> > emailAddress = _root.form.email;
> > if (emailAddress.indexOf("@")) {
> > _root.gotoAndStop("no_error");
> > }
> > };
> >
> > Do I need to specify 'String' in here somewhere.
> Is
> > that it?
> >
> > Thanks,
> >
> > Rob
> >
> >
> > --- Seb L <pluginseb at gmail.com> wrote:
> >
> > > Hi Robert,
> > >
> > > indexOf should work fine in this case... check
> for a
> > > result of -1 :
> > >
> > > var mystr:String = "12345 at 234";
> > > var mystr2:String = "123454t";
> > >
> > > trace(mystr.indexOf("@")); // returns 5
> > > trace(mystr2.indexOf("@")); // returns -1
> > >
> > > If that's still not working I suspect you have a
> > > referencing problem,
> > > make sure you're actually testing the right
> thing!
> > > I'd trace the value
> > > to make sure that it's what you should be
> checking.
> > >
> > > good luck :-)
> > >
> > > Seb
> > >
> > > On 31/10/06, Robert Stevens
> > > <robs_here at btinternet.com> wrote:
> > > > Hi All,
> > > >
> > > > An easy one here for many of you I'm sure.
> > > >
> > > > I have a function set up for a button which
> > > includes
> > > > an 'if' statement.
> > > > I simply need to check if the "@" symbol is
> > > present in
> > > > a form field.
> > > > I've tried the "indexOf" method but it didn't
> seem
> > > to
> > > > work.
> > > >
> > > > Thanks in advance,
> > > >
> > > > Rob
> > > >
> > > >
> > > > --
> > > >
> > > > BNM info/subscription/archives:
> > > http://www.brightonnewmedia.org/
> > > >
> > > > BNM archive search:
> > > http://www.roddis.org/bnm/search.php
> > > > BNM Del.icio.us tag:
> http://del.icio.us/tag/bnm/
> > > > BNM Flickr group:
> > > http://www.flickr.com/groups/bnm/
> > > >
> > > > BNM powered by http://www.screen-play.net/
> > > >
> > >
> > > --
> > >
> > > BNM info/subscription/archives:
> > > http://www.brightonnewmedia.org/
> > >
> > > BNM archive search:
> > > http://www.roddis.org/bnm/search.php
> > > BNM Del.icio.us tag: http://del.icio.us/tag/bnm/
> > > BNM Flickr group:
> http://www.flickr.com/groups/bnm/
> > >
> > > BNM powered by http://www.screen-play.net/
> > >
> >
> >
> > --
> >
> > BNM info/subscription/archives:
> http://www.brightonnewmedia.org/
> >
> > BNM archive search:
> http://www.roddis.org/bnm/search.php
> > BNM Del.icio.us tag: http://del.icio.us/tag/bnm/
> > BNM Flickr group:
> http://www.flickr.com/groups/bnm/
> >
> > BNM powered by http://www.screen-play.net/
> >
>
> --
>
> BNM info/subscription/archives:
> http://www.brightonnewmedia.org/
>
> BNM archive search:
> http://www.roddis.org/bnm/search.php
> BNM Del.icio.us tag: http://del.icio.us/tag/bnm/
> BNM Flickr group: http://www.flickr.com/groups/bnm/
>
> BNM powered by http://www.screen-play.net/
>
More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service