A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Who doesn't my code work anymore?

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    272

    Who doesn't my code work anymore?

    This code works or should I say worked fine. When exporting it as flash 8 swf or projector it no longer works:

    function check_answers(){
    one = m1v + m2v + m3v + m4v + m5v + m6v + m7v + m8v + m9v + m10v + m11v;
    two = ru1v + ru2v + ru3v + ru4v + m2v + ru5v;

    if ((one == "maintenance") && (two =="runway")) {
    gotoAndStop("win");
    } else {
    gotoAndStop("lose");
    }
    }

    When I check it, it comes up with no errors. Everything else works fine, but when I go to check....well, no matter what I always lose, even though everything is correct.

    Am I missing something? Or does this not actually work in Flash 8?

    Thanks in advance,

    Frustrated already...........

  2. #2
    Actionscript 3, postproduction georgecalgary's Avatar
    Join Date
    Jun 2005
    Location
    Toronto
    Posts
    229
    Not the right way.
    Suggest:
    a. Restrict your variables with 2.0 syntax style, such as: var one:String
    b. Use debug & trace.

  3. #3
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Quote Originally Posted by designforce
    if ((one = "maintenance") && (two = "runway"))
    Thats not correct way to check for equality. You are assigning values with "=" so it always returns true and you never get to lose frame. The code in your first post works, but you need to make sure all the variables are actually strings. Check the values of all those m1v... m11v...ru1v. Also use trace before if statement to make sure one and two are correct:

    ...
    two = ru1v + ru2v + ru3v + ru4v + m2v + ru5v;
    trace(one);
    trace(two);
    if ((one == "maintenance") && (two =="runway")) {
    ...

  4. #4
    Senior Member
    Join Date
    Sep 2000
    Posts
    272

    Thank you both

    I changed code as suggested and have attached my Flash8 file:

    function check_answers(){
    one = m1v + m2v + m3v + m4v + m5v + m6v + m7v + m8v + m9v + m10v + m11v;
    trace(one);
    two = ru1v + ru2v + ru3v + ru4v + m2v + ru5v;
    trace(two);
    if ((one == "maintenance") && (two == "runway")) {
    gotoAndStop("win");
    } else {
    gotoAndStop("lose");
    }
    }

    Tried it with var, trace for each and still no go. now I always end up at "lose" regardless. Trued exporting as AS1, AS2, no difference. Publish as Flash 6 and 7 and it works.

    I appreciate your guidance, but still no go in flash 8. File attached

    Any other ideas?

    TIA
    Time for some coffee.........
    Attached Files Attached Files
    Last edited by designforce; 09-17-2005 at 11:10 AM. Reason: attaching file

  5. #5
    Senior Member
    Join Date
    Sep 2000
    Posts
    272

    What trace revealed

    I used the trace method and this is what it revealed: In flash 6 and 7 it returns the words - maintenance and runway, however using flash 8 it returns: <TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">m</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">a</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">i</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">n</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">t</FONT></P> and more but I cut it off.

    What is going on. The input text fields are not set to HTML, so this is rather puzzling and frustrating.

    Any guidance?

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    In Flash8 you should not use text field variables, instead you should use text field instance names. This will work (I used toString() to convert undefined values to empty strings):

    two = ru1.text.toString ()+ ru2.text.toString () + ru3.text.toString () + ru4.text.toString () + m2.text.toString () + ru5.text.toString ();
    if ((two == "runway")) {
    gotoAndStop ("win");
    } else {
    gotoAndStop ("lose");
    }

  7. #7
    Senior Member
    Join Date
    Sep 2000
    Posts
    272

    Thanks!

    Tonypa - Thanks so much. I was going crazy.

    I always thought using textfield variables was the way to go, but hey, you have shown me the light.

    Thanks again, I hope that someday I can return the favor.

    Cheers!

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    The Flash8 help says you should only use variables on dynamic text field if you publish to Flash6 or earlier.

    Glad it helped

  9. #9
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Well this sure complicates things...

    **post deleted**
    Last edited by Ray Beez; 09-30-2005 at 02:03 PM.

  10. #10
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    But Ray, textfieldname.text IS a variable too, you can use that exactly same way you used variable attached to text field in earlier versions:

    myotherVar=textfieldname.text;

  11. #11
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Yeah sorry, my code had OTHER problems beyond textfield variables.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center