RE: [flexcoders] Function from string?
Perhaps the following syntax will help: var func:String = yourFunctionName; this[func](); Regards, Keith Reinfeld From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of A. P. Damien Sent: Tuesday, November 05, 2013 10:48 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Function from string? I'm writing a game. Well, actually I guess it's more of a game engine. I want the game logic to be in a script. The script will take the form of a series of rooms, each of which can contain: . doors to other rooms . characters the player can interact with . things the player can pick up and use Any of these can have conditions on them. The condition can be expressed as: . Player must have (thing) in his inventory . Player must have at least X points . Player must have at least $Y money . Call function f That last seems to be a problem. I would like to be able to take a function name I've read from the script and call the corresponding function. Or, alternatively, the script can contain the name of a class which must contain a method named (for example) conditionTest. But I haven't figured out a way to convert a string to either a Function or a Class. Is there a way of doing this? If I were working in Javascript, I'd just call eval, but that seems to be forbidden in AS3, right? Can I do this? Or do I have to put all the functions I might want to call this way in an array, and look them up that way? Or what?
[flexcoders] Build Android app similar to iOS Newsstand app
Hello! I wanna build an Android app similar to iOS Newsstand app using Adobe Flex Flash Builder. Is it possible to achieve this goal.? My aim to build such app is simple: I've developed some Android Games (.apk files) using AIR for Android, when any app is installed to the Android devices it is shown to the main menu by default, so I need to hide that icons from the main menu and at the same time the icon should be displayed to the new app (as I said, app like a Newsstand app) and when the user clicks the game icon shown inside the new app, the game should play. My simple logic is I want my game to be organize within one app instead of main menu... so please can you help me out on how to start and how to achieve my goal... Thank you... :)
Re: [flexcoders] Function from string?
I'm writing a game. Well, actually I guess it's more of a game engine. I want the game logic to be in a script. The script will take the form of a series of rooms, each of which can contain: . doors to other rooms . characters the player can interact with . things the player can pick up and use Any of these can have conditions on them. The condition can be expressed as: . Player must have (thing) in his inventory . Player must have at least X points . Player must have at least $Y money . Call function f That last seems to be a problem. I would like to be able to take a function name I've read from the script and call the corresponding function. Or, alternatively, the script can contain the name of a class which must contain a method named (for example) conditionTest. But I haven't figured out a way to convert a string to either a Function or a Class. Is there a way of doing this? If I were working in Javascript, I'd just call eval, but that seems to be forbidden in AS3, right? Can I do this? Or do I have to put all the functions I might want to call this way in an array, and look them up that way? Or what? Hi, you can call this['funcname'] or similar if the class is known. You can call getDefinition if you need to match the class name It might make sense to have all the expected functions in an array, just to avoid that a script error calls functions that should not Regards Wolfgang
Re: [flexcoders] Function from string?
On 11/6/2013 9:16 AM, Keith Reinfeld wrote: Perhaps the following syntax will help: var func:String = “yourFunctionName”; this[func](); Thanks. I hadn't fully assimilated the fact that an object can also be treated as an array. Do I have to declare the class 'dynamic' for this trick to work? Or is it always legal to do this from inside the class? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: flexcoders-dig...@yahoogroups.com flexcoders-fullfeatu...@yahoogroups.com * To unsubscribe from this group, send an email to: flexcoders-unsubscr...@yahoogroups.com * Your use of Yahoo Groups is subject to: http://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [flexcoders] Function from string?
Both Array and Object support [] property access. Regarding converting a String to a Function: AS is compiled, not interpreted, so only strings that have been compiled into functions can be run. You can fill an object or array full of functions and choose one at runtime, but that is not the same as constructing a string at runtime and trying to run it. Eval() will do that in JS, but there is no AS equivalent. Some options are: 1) There are some AS3 eval() functions in third-party libraries. But they are unlikely to be fast. 2) You can send the string to a server, compile it into a SWF and load that SWF and run it. 3) If the function doesn't require much information from the rest of the app, you could write the string to JS and call eval on it via ExternalInterface -Alex On 11/6/13 2:02 PM, A. P. Damien apdam...@ca.rr.com wrote: On 11/6/2013 9:16 AM, Keith Reinfeld wrote: Perhaps the following syntax will help: var func:String = ³yourFunctionName²; this[func](); Thanks. I hadn't fully assimilated the fact that an object can also be treated as an array. Do I have to declare the class 'dynamic' for this trick to work? Or is it always legal to do this from inside the class? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e 62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo Groups Links
Re: [flexcoders] Retrieve current item on a DataGroup
If you need selection, why not use List? From: Jairo França ja...@tgi.inf.brmailto:ja...@tgi.inf.br Reply-To: flexcoders@yahoogroups.commailto:flexcoders@yahoogroups.com flexcoders@yahoogroups.commailto:flexcoders@yahoogroups.com Date: Tuesday, November 5, 2013 9:27 AM To: flexcoders@yahoogroups.commailto:flexcoders@yahoogroups.com flexcoders@yahoogroups.commailto:flexcoders@yahoogroups.com Subject: [flexcoders] Retrieve current item on a DataGroup I have a question that seems easy, but i can't solve. I have a DataGroup with a custom ItemRenderer. How can I retrieve the current item that was selected with a double click (something like a SelectedItem on a DataGrid)? Can I retrieve the itemRenderer instance of the element? Thansk My code is: s:Group height=100% width=100% s:Scroller height=100% width=100% id=scr s:DataGroup id=dg height=100% width=100% itemRenderer=myItemRenderer dataProvider={_data} doubleClickEnabled=true doubleClick=dg_doubleClickHandler(event) s:layout s:TileLayout/ /s:layout /s:DataGroup /s:Scroller /s:Group