Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-10-2012, 09:24 PM   #1
Bounty_y2k
Member
 
Join Date: Jun 2012
Posts: 74
Send a message via Skype™ to Bounty_y2k
Default If empty variable

ActionScript Code:
on(keyPress "<Left>") {                 if (_root.x11 = "") {                     x11 = m1;                     x12 = m2;                     x13 = m3;                     luckystrike();             }         }
This code should do on key press left to check if variable x11 is empty and if it is to change those 3 variables,but it does not do that it actually sets x11 to empty i mean it erases the data in that variable...why? i tried this too "if(_root.x11 = undefined)" its the same again...
Bounty_y2k is offline   Reply With Quote
Old 07-11-2012, 03:16 PM   #2
neilmmm
Senior Member
 
neilmmm's Avatar
 
Join Date: Oct 2005
Location: dorset
Posts: 1,637
Default

double == sign for evaluating

Code:
  if (_root.x11 == "") {
does that work?
neilmmm is offline   Reply With Quote
Old 07-12-2012, 08:27 PM   #3
anx
Ben Fhala
 
anx's Avatar
 
Join Date: Oct 2005
Location: NYC
Posts: 90
Default

by the way if you did it in AS3 it would give you a warnning message when you do an assinment in as1/2 you need to be more carful one qeuals(=) is to assign things and two are to compare ''=='

in your case your if statement was

if("")

or in other words you asked if empty string and the answer to that is always true as an empty string is something. just adding into what @neilmmm said.
__________________
Learn how to Flash online school | fla.as - Open source | @02Geek
anx is offline   Reply With Quote
Old 07-13-2012, 03:36 PM   #4
suresh02sd
Registered User
 
Join Date: Jul 2012
Location: Brooklyn, NY
Posts: 34
Default

cool i didn't know that thanks.
suresh02sd is offline   Reply With Quote
Old 07-20-2012, 05:36 AM   #5
Bounty_y2k
Member
 
Join Date: Jun 2012
Posts: 74
Send a message via Skype™ to Bounty_y2k
Default

I still can't make it work...
ActionScript Code:
on(keyPress "<Left>") {                 if (_root.x11 == "") {                     x11 = m1;                     } else {                     x21 = m1;             }         }
It should do:
If variable is empty fill it,if its not fill other one...
Bounty_y2k is offline   Reply With Quote
Old 07-23-2012, 02:56 AM   #6
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

Have you tried tracing your variables from inside that code to check if they're being targeted?

Try this:

ActionScript Code:
on(keyPress "<Left>") {                 trace(_root.x11+" | "+typeof(_root.x11));                 if (_root.x11 == "") {                     x11 = m1;                     } else {                     x21 = m1;             }         }

and post back what it displayed in the output panel!
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 07-23-2012, 04:13 AM   #7
Bounty_y2k
Member
 
Join Date: Jun 2012
Posts: 74
Send a message via Skype™ to Bounty_y2k
Default

I got this as output:
Code:
x | string
x is just an text inside dynamic text field,when i erased the text (the "x") inside text field and tried again i got this output:
Code:
undefined | undefined
Bounty_y2k is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:21 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.