Evaluating a variable that contains a variable

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Evaluating a variable that contains a variable

    Hello, all:

    I have a bindable variable that contains the name of another variable that I
    want to return. Example:

    [Bindable]
    var price:String = "dollars";
    [Bindable]
    var dollars: Number = "10.00"

    If I use {price} in some expression, the output is 'dollars'. I am looking for
    a way to use {price} and have it output '10.00'. How would I do this in AS 3?

    This would be like the ColdFusion function 'Evaluate()', where
    #Evaluate(price)#, which would return '10.00'.

    Any ideas would be highly appreciated. Thanks,

    Carlos


    cheftimo Guest

  2. Similar Questions and Discussions

    1. #39251 [NEW]: variable variable class array property is read only
      From: taskfreak at gmail dot com Operating system: mac os PHP version: 5.1.6 PHP Bug Type: Class/Object related Bug...
    2. #22237 [Com]: PHP crashes when class references property using variable variable
      ID: 22237 Comment by: rep at devdomain dot com Reported By: peter at globalvision dot com dot au Status: Closed...
    3. [PHP] evaluating dynamic variable
      this worked for me. <? $entries = 20; for ($i=1; $i<=$entries; $i++) { if(isset($_POST) && $_POST !== ''){ echo "Hello $i<br />"; } }
    4. evaluating dynamic variable
      Hi, I'm having trouble evaluating a dynamic variable. I want to check if the variable $_POST is an empty string, as you'll see from the code....
    5. Datalist - how (if) to use a sub variable or session variable in the footer?
      Hi, sorry to be greedy with all my posts lately, but can you tell I'm doing new things this week? I've just done my first datalist (a simple...
  3. #2

    Default Re: Evaluating a variable that contains a variable

    I thought this might work, but it does not:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    [Bindable]
    private var price:String = String(dollars);
    [Bindable]
    private var dollars: Number = 10.00;

    private function clickHandler():void{
    dollars = 20.00;
    }
    ]]>
    </mx:Script>

    <mx:Button label="Click Me" click="clickHandler()"/>
    <mx:TextArea id="txtArea" width="300" height="200" text="{price}"/>
    </mx:Application>

    Greg Lafrance Guest

  4. #3

    Default Re: Evaluating a variable that contains a variable

    You can do it like so.

    TS

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[

    [Bindable]
    private var price:String;
    private var currencyString:String = "dollars";
    private var dollars: Number = 10.00;

    private function clickHandler():void{
    price = this[currencyString];
    }
    ]]>
    </mx:Script>

    <mx:Button label="Click Me" click="clickHandler()"/>
    <mx:TextArea id="txtArea" width="300" height="200" text="{price}"/>
    </mx:Application>

    VarioPegged Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139