SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    EDIT: I'm using Actionscript 3
    Last edited by Pokenerd; Nov 14, 2009 at 16:16. Reason: Clarifying information, made more readable

  2. #2
    SitePoint Zealot evilunix's Avatar
    Join Date
    Jun 2008
    Location
    York, UK.
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In javascript you would use the eval function to evaluate a string as code. I'm not sure about action script but I think it's based on javascript so worth looking into?


Tags for this Thread

Bookmarks

Posting Permissions

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