ActionScript 2.0 :: Adding String Data To An Expression For Evaluation?
Nov 15, 2007I have the following function:
Code:
getInfo = function (input, arrayData, desiredResult)
{
[code].....
I have the following function:
Code:
getInfo = function (input, arrayData, desiredResult)
{
[code].....
Is there a light weight expression evaluator for as3. It should take in a string as a input
something like "5 < 2" and evaluate it to a Boolean say true or false. Of course I gave a simple example but the expression could be complex too. "(3 < 5) && (2 > 5 )"
Possible Duplicate:In Flash, how would I run an e4x statement when that statement is stored in a String?I know there is an existing question regarding this problem, but it got no replies.Ideally, I would like to stick an e4x expression in a string and run it.
var tempXML:XML = someXML;
var stringe4x:XML = "pictures.picture.(size > 200)";
tempXML.eval(pictures); //something instead of eval
Since AS3 doesn't have eval, this doesn't work; however, there is the ability to use elements() and attributes() to get the elements or attributes on the same XML node level, but this doesn't work for the more complicated e4x filters such as "(id > 300)" or ".." notation.
I need to convert a string such as "x*y+2" (from an input text field) into an expression x*y+2, so that it can be evaluated normally, eg f=x*y+2. The variables x and y are already defined and can have various values; I need to evaluate the strings as expressions.
I have tried f=Number("x*y+2") but it seems to work only when the string is actually a number such as "1.2e-4".
I need to evaluate an expression in a string at run time . Not sure how to achieve this in Flex. My requirement is as follows
var test:String = "myparams.id=10" ;
//test will be a string populated at runtime.
// I need to treat it as an expression and evaluate it at runtime
[Code]....
is it possible to do something like this action script 3?
I believe the eval function earlier allowed this, but now it has been depreciated?
I have a string "5^2". Is there a way to calculate the value of the expression stored in the string?
View 3 RepliesI'm trying to find the number of newlines in a string using the Actionscript 3.0 RegExp engine. Using the string.match function and RegExp(" ","g") does not find the newlines in a string which contains newlines. Is there something I need to add to the pattern or something else that I am missing?
View 1 RepliesI am using RegExp to search for character sequences within strings. I was wondering if/what is the proper way to use a string stored in a variable as a regular expression. For example: [code]I'll have to use another string manipulation tool to search for the sequence.
View 5 RepliesI want the user to input a regular expression, which is then used.
I'm using following at the moment.
PHP Code:
var filterEx = new RegExp(filterTxt.text.split("/")[1], filterTxt.text.split("/")[2]);
filterTxt is a textbox, when traceing the pattern is seemingly correct, but i.e.:
[Code]...
give me the Regular Expression that can check if a given string has any HTML code in it, and coming to think of it I would be bothered with <a href="something">something</a> exactly.
View 2 RepliesI have some text that is displaying from a database table and inside that text is a web address (i.e.,
[Code]...
This time want to know is it possible to use the user input string as part of reqular expression for instant search... I am aiming to add search feature in my game.. Where i m going to have several items available in list... what i am planning is to have a text box from which i will accept user input and perform instant search am still a noob in AS3... so whether using RegExp meet my goal ?
View 3 RepliesI have a singleton class that looks something roughly like this (only with more bindable public properties):
public class Session extends EventDispatcher
{
private var _Id:String;
private static const _instance:Session = new Session( SingletonLock );
private static const SESSID_CHANGED:String = 'SessionIdChanged';
[Code]...
The abnormal behavior I'm discovering is that the event listeners registered through registerOnSessionChange are indeed being called when the session Id changes, but the MXML data binding expression is not updating. I've tried all combinations of dispatching the event during the capture phase, and making it not cancelable, but to no avail. My understanding of [Bindable (event= ...)] is that the MXML should update the url string when the event specified is dispatched, so what am I doing wrong or misunderstanding?
Note: I realize there are lots of different ways of doing the singleton pattern in Actionscript, but unless the way I am doing it is actually causing my problem somehow,
Does anyone know the regular expression to test if a single string character has both upper and lower case character?
eg. All A-Z and a-z.
We have implemented a Flash photo slideshow on our site and it works just fine for most of our users. Whenever the xml.load(success) returns false I have the Flash email me a debug report. For the life of me I can not find a common thread between all of these people having problems with the Flash. I don't think it's a cross-domain issue because it works for most people, and I have the crossdomain.xml files where they should be.
[Code]...
I have decided of using AS3 on my Evaluation Quiz because only AS3 supports saving pdf file. I need this feature for reports/tracking.
The question now is where can I get Poll/Evaluation Quiz Template?
var btn:Button;
if(btn != null && btn.label != '') {
mx.controls.Alert.show("d");
}
In the above if clause, is it guaranteed that the first condition(btn != null) will be evaluated before the second condition?
We have developed a web application. (Eclipse - Dynamic Web Project). We are deploying it as .war file. We want to implement evaluation period license check on this .war file. (Most of the functionalities are Java SOAP Web services and Web UI is in Flex). I have written a Java code for generating the license file and thread for checking the remaining days. (Checking is continuous as the application is supposed to run for days). What is the best way to implement this functionality on the web application using the generated license file?
View 1 RepliesFlash is returning decimal floating point formats in evaluation results under the IEEE 754-1985 format.I looked it up and this seems to be how ActionScript 3 was designed to follow that standard which creates these results.This doesn't happen in the ActionScript 2 compiler. It only happens under ActionScript 3, paste these trace statements and compile so you can see what I mean:
Code: Select alltrace(48.48 + 0.01) // returns 48.489999999999995
trace(18.48 + 0.01) // returns 18.490000000000002
this one is ok: Code: Select alltrace(18.49 + 0.01) //returns 18.5
I need a two decimal place precision result as this is for an algorithm that I'm trying to use to round up or down by a penny so I can't simply convert it to an integer but there's no pattern that I can see so I can predict results for it either.I can't have a $18.8999999999995.
Is there any function in flash that allows for 'in-line evaluation'?
For example, in php I can type
eval ( 'php statement here' );
and php will execute 'php statement here' as if I typed it as a command. I'm trying to execute dynamic code is the problem.
Simply put, is there short circuit evaluation in flash. If not, is there a way to do something like it and still retain the elegance of short circuit evaluation?
View 5 RepliesIs there any function in flash that allows for 'in-line evaluation'? For example, in php I can type
eval ( 'php statement here' );
and php will execute 'php statement here' as if I typed it as a command. I'm trying to execute dynamic code is the problem.
im using PHP with MySQL to send information to my flash file using GETs.Using FlashVars i have managed to get the users 'id' with this i can send my questions/searches to a PHP script which access the database and returns the information to the html page.What i would like to do now is add the information sent back to the html page to a variable inside flash for example:
var usr_name = get_user_name(id) || 'Unknown'; // "Unknown" should just be for offline use.
but this just returns 'Unknown' this is the function used:
public function get_user_name(usr_id){
loadData('search.php',"quest=name",'usr_id='+usr_id);
}[code]......
If i just type the URL into a web browser i get the name outputed.
I meant to call it "Convert a value to a variable". Using CS3, AS2: If I have a variable that's a string value = the name of another variable, can I extract the value and then look for the extracted value's matching variable name to get it's value?
Ex:
color = "blue"
box = "color"
(Assuming I don't know the value of box) How would I get the value of "box" out so I could search for the value "color" as if it were a variable? I need to convert a value to a variable name is what i'm getting at... I think.
I have recently moved from AS2.0 to AS3.0 and I am trying to get to grips with event handling. I am managing for things like key presses and mouse clicks
I am successfully tracing a string as either "login successful" or "login unsuccessful" from a PHP file on a local host and it traces as working in my Login class. Now I want to listen for the "login successful" string, currently tracing in my Login class and if it works, call an EventHandler in my Main class which will execute the next step.
Here's my code so far
PHP Code:
private function onLogin(e:Event):void
{
var loader:URLLoader = URLLoader(e.target);
[Code]....
I meant to call it "Convert a value to a variable".Using CS3, AS2:If I have a variable that's a string value = the name of another variable, can I extract the value and then look for the extracted value's matching variable name to get it's value?[code](Assuming I don't know the value of box) How would I get the value of "box" out so I could search for the value "color" as if it were a variable? I need to convert a value to a variable name is what i'm getting at.
View 4 RepliesI have a dynamic text box called "tbNotes".I need to be able to see if the text box contains a website address. If it does contain a website address, I need to have a movieclip called "hilight" appear over that text.I have been messing around with this for a while but can't figure out how to search the text box to see if it contains "www." Then if it finds the "www." then make the "hilight" moviclip visible and start at the x position of the first w and the width end at the end of ".com".
View 1 RepliesI want to add a newline to a string text and I was wondering if there is a newline constant in actionscript 3? For example in .net there is an Environment.NewLine that is a string, containing "
" for non-Unix platforms, or a string containing "
" for Unix platforms.
is it possible to add the values from a string to an array?For example my string looks like this:
var bookmarks:String = "book1, book2, book3";
And I need to add these values to the end of an array?
I am making an flash calculator. The only problem is that all the calculator flash applications always use input textboxes to use the numbers, but I need buttons. The first thought was to use a string, and add all the numbers together. The only problem is that I cant add two strings together because flash thinks that it is not a numeric variable. I have tried to use the
var:Number function but it still isn't working.