A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] simple flashcard script

Hybrid View

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I don't really get the syntax you are using, I reccognize it as shorthand and I see guys like Wilbert use it. So rather than fix it per say I rewrote it as

    Code:
    forward.onClick = function() {
    trace (i==cards.length-1);
    if (i==cards.length-1){
    	i=0;
    	}else{
    	++i
    	}
    	txt2.text = cards[i][0];
    	
    }
    and that works fine.

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    those are tertiary operators, a shorhand way of writing "if" clauses....very popular and yes......used by Wilbert wherever appropriate

  3. #3
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Yes, I use it sometimes
    There's nothing wrong with the code in this case. It's a little KM problem.
    If you change your variable declaration from

    var i = 0;

    into

    var i:int = 0;

    The error is gone.
    I would advise you to use the debug version of the Flash Player. In this case for example it shows an error that might help Bob fix the problem.

  4. #4
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Ah the var i:int=0 was the only thing missing! Thank you! I probably shouldn't be using shorthand like that and should be writing it all the way out, but I figured if it worked in javascript it would work in flash, and it does.

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