A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: String into code

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    Question String into code

    Hi,

    I'm trying to create a series of scripts that will create some custom event listeners.

    I have three movie clips on my stage. One is a movieclip who's sole function is to hold array's and the event listeners. A second which moves around the screen. And a third that is motionless.

    The problem is that the argument I want to test (which activates the custom event) is held within a string.

    What I want to know is, how do you test to see if the string argument is true?

    Is it something similar to this:

    Code:
    var myCode:String="1<0";
    
    if(myCode){
    	trace('one is smaller than 0'); //Strangely apparently one IS smaller than 0!!!
    }
    I think I'm going about this in the wrong manner, however this is the only way I can think of this working... (since I need to be able to dynamically create these events)

    Thanks for any help,
    Pokenerd

  2. #2
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    When you try to evaluate a string there are only two possibilities.

    An empty string equates to false
    a string with anything in it equates to true

    this method you are trying to use will not work.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    6

    resolved Well...

    I was hoping to do something with square brackets, but it turns out those are only for objects, and references and what not...

    I think that d.eval might work however.

  4. #4
    Member
    Join Date
    Oct 2009
    Location
    Toronto, Canada
    Posts
    30
    research string slice and implode. check out the AS3 reference online for that. you may get pretty excited.

    p.s: i don't really know if AS3 has string.implode but check.
    Temet Nosce - Oracle

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    No, there's no implode method on String, but there is a join method on Array which does the same thing. It makes a lot more sense for the method to be on Array than String anyway.

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Quote Originally Posted by 5TonsOfFlax View Post
    No, there's no implode method on String, but there is a join method on Array which does the same thing. It makes a lot more sense for the method to be on Array than String anyway.
    Python uses join as a method of a string. Like: ",".join(mylist)


Tags for this Thread

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