ActionScript 3.0 :: How To Match Substrings Accurately
Mar 14, 2010
How to match substrings accurately?eg: I wanted to search whether any pronouns like he, she etc are present in a string say input.Where is he?Here I wanted to find whether the pronoun 'he' is present. But since the where contains the substring 'he' I can't get the result properly.I tried with RegExp and arrays and strings; using match(), search() indexOf(). They all do it the same way.My RegExp pattern is as below:
Code:
var pronouns:RegExp = /(i)|(me)|(us)|(he)|(him)|(she)|(her)|(it)|(they)|(them)|(that)/;
I wanted to find for eg, strings like
He is alright
Where is he
She is there
Who is it
I know them
In the above sentences I wanted to get the position of where the pronouns 'he' 'she' 'it' 'them' etc occurs.Why because if it occurs I wanted it to replace them with another words.
View 3 Replies
Similar Posts:
May 17, 2010
I have an embedable widget. For each impression, I would like to track the referrer (the page where the widget is embedded onto). Right now I am using ExternalInterface to use javascript to check window.location.href when its available, however, I am finding that most of the time I am unable to set the referrer.
I not using javascript correctly to get the referrer?
View 1 Replies
Jan 28, 2010
I have a container with masked bitmap in it. The scale and rotation of this container changes at runtime, and I need to draw the masked bitmap but cannot figure out the appropriate matrix calculations to do so.My code works correctly to reflect position, scale, offset for centering without rotation. When rotated, the angle is correct but the positioning is incorrect - I believe because the dimensions change when the rectangle is rotated.how to compensate for this in the positioning - here is some code:
// Adjust the transformation matrix to account for the position of the container
var tMatrix:Matrix = _imgContainer.transform.matrix;
//Offset for container
[code].....
View 4 Replies
Jan 25, 2012
As I understand, getTimer() is very inaccurate - on my own machine it always returns a value which is a product of ~16. (16, 33, 50, etc.) Is there a simple and efficient way to more accurately measure the time difference (delta) between two separate calls in my program?
View 1 Replies
Oct 19, 2010
I'm using mx.rpc.http.HTTPService to retrieve data from a web service. On the initial call to "loadWsData", HTTPService accurately retrieves all the data. However, on any and all subsequent calls HTTPService does not accurately retrieve the data; rather it some how always retrieves the first data set. I've confirmed that the web service is providing accurate data, both from web browsers and a ruby ws client script. If I terminate the flex app and restart it, it will retrieve the accurate data.
ActionScript Code:
private function loadWsData():void{
var webService:HTTPService = new HTTPService();
webService.url = serviceUrl;
webService.method = "GET";
webService.addEventListener(ResultEvent.RESULT, function(event:ResultEvent):void{
var rawData:String = String(event.result);
var user:Object = JSON.decode(rawData).user;});
webService.send();}
View 1 Replies
Jan 21, 2009
I'm learning AS3 as I modernize the VCR controls for our e-learning topics. The way we used to do it was load the wav into the timeline and keyframe to the audio. We have a little tracker bar you can click on to jump around, a tracker icon you can drag, play/pause and FF/RW buttons. In AS2, since the wav was in the timeline, I just had to worry about frame numbers.
It seems like the modern way to do it is to load the audio as an MP3 externally. How accurate will this be as far as sync'ing the audio to the animation when using the tracker bar and jumping around? I'll basically be mathematically slicing the bar graphic into pieces and using that to tell the animation what frame to start on, and converting that to a time for the audio to start.
View 4 Replies
May 4, 2006
As a test, I'm loading images (or references to images, more accurately) from an external XML file into Flash, each image representing where a thumbnail might appear in a portfolio, for example. I can get that to work fine. I have a couple of problems with the way the images appear, though. For one thing, when the 95 px X 95 px images are brought into the dynamically created 100 px X 100 px movieclips I have set for them, the JPGs stretch to fit... is this because I'm using the loadMovie method? The main difficulty I have, though, is my inability to get these individual movieclips containing JPG images to exhibit rollover and rollout behavior dynamically... without disturbing the image contained within.
Here's the code I have right now; my lame attempt at a dynamic rollover behavior is the for.. loop at the bottom, which is non-functional, by the way.
Code:
function loadXML(loaded) {
if (loaded) {
//according to "content2.xml," this would set the parser at "<projects>".
xmlNode = this.firstChild;
var thumbs:Array = new Array;
var description:Array = new Array;
[Code] .....
View 8 Replies
Dec 6, 2009
How to get value from match in ActionScript?
View 1 Replies
Jul 9, 2009
I'm pulling news information from an XML file. The root node is "article", the child nodes are (for example) "date", "title", "caption", "copy", "link", etc.
Each time an article is added, a couple button (mc's) will be added to the stage. One button when clicked displays a movie clip and attempts to update the dynamic textfields within to display just the date and caption. The other button when clicked displays a different movie clip and attempts to update the dynamic textfields within to display all of the information noted above.
Being that this is dynamic and coming from an XML file, I want to avoid having to write if ... else statements for every new article (and each button).
Is it possible to search an XML document and scan for a name/ID match to create certain actions?
In other words, If I were to give an MC a name of "thisButton123" and also give an XML article node an ID attribute of "thisButton123", I could say something like if the currentTarget.name == any of these XML node attributes than pull that nodes content. Eliminating the need to compare/contrast names and ID's specifically.
View 4 Replies
Jul 26, 2009
I have a problem in that I've made a web banner - text with motion and shape tweens. Trouble is when I test movie, it not only plays in a different font to the one I've used in the design (metaPlus normal) it misses out text!?I'm not getting an exact replication of what the fla file is.[code]
View 5 Replies
Jun 14, 2011
I have this piece of script, where I want to do a hittest when both the x AND y are not the same (and some other variables) now, that wouldnt be so hard, you think: if (MovieclipA.x!=MovieclipB.x && MovieClipA.y!=MovieclipB.y) but! if i now have a MovieclipC, which is on the same y coordinate as A, but not on the same x coordinate, the hittest wont execute..., as the y coordinates match...
it probably is really simple, but how can i solve this problem?
View 8 Replies
Oct 11, 2011
I'm counting lines of codes in my flash builder project, and I try to use Search function Ctrl+H, and search how many lines in *.as file, and I failed to match with /[.]+/, how can this be done?
View 6 Replies
Jun 23, 2010
I want to make a mail script. The user will enter the recipient's name, which is linked to variable "name". I've got a variable, EMAILA which is
ActionScript Code:
var EMAILA {
Cem : "cemgokmen97@gmail.com",
Muhittin : "gokmen@itu.edu.tr"
}
And on the SEND button, I have this code :
ActionScript Code:
on(release){
if(name){
getURL('mailto:'EMAILA[name]
}}
But for some reason when the mail client opens, the address does not appear in the "To" box.
View 6 Replies
Sep 7, 2010
I have a problem with XML filtering. [code]If there is only one result, trace is empty. If there are 2 results or more, they will be traced fine. Is it because one result is not an XML 'list'? If so, how do I get the results if there is only one match?
View 2 Replies
Jul 17, 2010
I've created a website in Flash and have posted it to the net. I want it to scale as the user resizes the window, but having little formal training in Flash I'm not entirely sure how to go about it.
View 4 Replies
Jun 25, 2009
I have this:
var regExp:RegExp = new RegExp("((.*?)%)");
and want everything between the ( and the %)the string looks like this: (-24%)I now get a return back "(-24" and have searched for a long time to find a solution but didn't find any.
View 2 Replies
Jan 12, 2010
If you have an array with six numbers, say: public var check:Array = new Array[10,12,5,11,9,4]; or public var check:Array = new Array[10,10,5,11,9,4]; How do you check for a match (of a pair?)
View 2 Replies
Mar 25, 2011
I'm trying to position an image on top of another image based upon the make-up of the smaller image. The smaller image is a cut-out of a larger image and I need it to be positioned exactly on the larger image to make it look like a single image, but allow for separate filters and alphas to be applied. As the images are not simple rectangles or circles, but complex satellite images, I cannot simply redraw them in code. I have quite a few images and therefore do not feel like manually finding the position of each image every and hard setting them manually in actionscript. Is there any way for me to sample a small 5-10 sq. pixel area against the larger image and set the x and y values of the smaller image if a perfect match is found? All the images are in an array and iterating through them has already been set, I just need a way to sample and match pixels. My first guess was to loop the images pixel by pixel right and down, covering the whole bitmap and moving to the next child in the array once a match was found, leaving the matched child where it was when the perfect match was found.
View 4 Replies
Sep 28, 2011
i'm itterating thru an array of text field objects and tracing the selected focus field when pressing tab, as well as each object.i'm trying to equate these object, but while they trace the exact same they are not.
m_InputFieldsArray = new Array(m_TitleTextInput, m_CommentsTextArea, m_EmailTextInput);
for (var i:Number = 0; i < m_InputFieldsArray.length; i++)
{
trace("Get Focus: " + Selection.getFocus());
[code]....
the first group traces the same, but apparently they do not match. Selection.getFocus() returns a string, while the array index is tracing the text field object. if i add toString() to the text field object it will trace as [Object object] how can i accomplish a match?
View 2 Replies
Aug 9, 2011
I am stuck with a string search
ActionScript Code:
var str:String = "this is better than what is better.";
var pattern:RegExp = /this.*better/gi;
var results:Array = str.match(pattern);
I want to search in a string from word1 to word2 and place all the results in an Array. So this should be accomplished using match().However the above code would return " this is better than what is better" while it should return "this is better". So the output takes the last match in the line, but I want it only to output till the first match in the line.
View 4 Replies
Jun 26, 2009
I have a list of items in XML that populate dynamic text boxes using the code below. I basically reference an attribute in the XML element to a specific instance name on a text box.
This works great for a few items, but I need to do this for several hundred, perhaps a thousand, items in an XML. Rather than copy & paste my code for each item and call out each specific text box and attribute value, is it possible to modify this code to match an instance name to the XML attribute value? In other words, one set of code that says "if the text box instance name is "x," provide the price of "x" from XML, but if the name is "y," provide the price of "y."
My xml code (3 item sample):
PHP Code:
<products>
<info_source id="SQL">
<item id="apples">$1.00</item>
<item id="oranges">$2.00</item>
[Code].....
View 4 Replies
Jul 19, 2009
I've got a video with a black rectangle that moves, tilts and zooms...is there any way flash can match an object to that? (for example, if I want to put an image over the black box?? Is there any way to detect where objects are in a video from flash? I've seen some things with web cams where snow collects on people in the cam, etc. so there's got to be some way to "find" things.
View 3 Replies
Mar 1, 2011
I'm trying to match up a shape so it vibrates to the sound on rollover.On rollout I'd like it to slowly deminish the vibration as the sound deminishes too.I've experimented with a number of functions with out success.I've included the source code i've been working on, Should the source file be required I will supply it on request.[code]
View 4 Replies
Aug 6, 2011
I have a movieclip that I am adding to the stage dynamically. The movieclip has to be placed at specific coordinates to match the current text field.The coordinates that show on the INFO tab are x=264 and y= 365. However, in order to get the movieClip to match those I have to set x to 398 and y to 200.If I set the coordinates to those in the INFO tab then the movieclip does not show; it appears off stage.
View 2 Replies
Apr 20, 2010
The package does not match the file path
View 4 Replies
Sep 24, 2010
I am working on a game that is set up like a slot machine. The first box contains a name, the second box cotains a piece of information about the person and the third box contains another piece of info. Each box has a movie clip in it that contains 10 frames, each frame has text in it (a name or piece of information). There are up and down arrows above the second and third box as the user can control what piece of info is in that box using the arrows (if the user clicks the up arrow they go up 1 fram to different info....if down down a frame to new info.) The first box is not user controled, it has a button that randomly generates the name the player is given with a spin animation.
The goal of the game is to match all three boxes the random name with the 2 user controlled pieces of info. If this happens I want the player to receive 20 points. However, if the player only matches one of the pieces of info to the random name then they should only get 10 points. If they do not match ny pieces then no points are awarded.
I figured the best way to do this would be to give the corresponding correct answers and names matching variable names and set it so if you have 2 matching variables you get 10 points and if you have 3 matching variables you get 20 points (no points awarded for 1 variable because 1 variable alone would be the name). My problem is that I dont know how to assign a frame a variable number and I also dont know if its even possible to do something like this. Am I on the right track or is there a much better way to set up scoring?
View 1 Replies
Jan 16, 2011
I have a paragraph of text on the stage that looks good (Helvetica Neue, Ultralight), but when I play the movie it looks much thinner and really bad. Why does the text on the stage not match the movie?
View 1 Replies
Nov 21, 2011
This person created this game:http:[url]....i was wondering if i wanted to match two different colours, how could i do this? for example, instead of matching two reds, if i wanted to match a red and green, how is this done?
View 2 Replies
Nov 22, 2011
Does anyone know why the font size in flash is smaller than in Microsoft .NET GDI+.Does anyone know how much smaller?Does anyone know how to calculate the font size to get the 2 to match?
View 2 Replies
Sep 1, 2009
Code:
var s:String = '%include %unquote(&open.gtestit&close);';
var re:RegExp = /([%&]?w+)/g;
var a:Array = s.match(re);
trace(a.join('
'));
I'm splitting the string up into words (w) where the word might have an optional % or & in front of it. The output is what I expect:
Code:
%include
%unquote
&open
gtestit
&close
Is there a way to get the index of each matched string in one call? I know I can walk the original string using the resulting array and get indexes, but was hoping there was something similar to MATCH(). Something like:
Code:
var array:Array = s.index_match(re);
and the results would be:
Code:
array[0] = 0
array[1] = 9
array[2] = 18
array[3] = 24
array[4] = 31
View 2 Replies