ActionScript 3.0 :: ''if" Statements When Dealing With A Stream Of Sensor Data?
Apr 17, 2010
After a not inconsiderable effort I've managed to get a touch sensor attached to a microprocessor talking to flash. It gives a constant analog input giving a value between 0 and around 300. When it reads 0, the sensor is being pushed hard enough, and my aim is to get an object to appear on the screen every time the sensor is pressed so that it reads 0.[code]Which works, when the sensor reads 0 it traces "zero", except it does it every time it reads the sensor, so there's huge great list of "zero"s generated.What i want is for it to trace "zero" only the first time it detects a zero, and not do it again until the value rises past zero and back down again.Is there a conditional way to do this? Something like "If previous value was greater than zero and this value is equal to zero, trace zero. if not, do nothing"?
View 2 Replies
Similar Posts:
Apr 5, 2011
I have a sensor that sends data as text file. Data format as follow: dat=110405120000+000.00+000.00+005.65+000.00+040.71+000.00+000.00+000.20.
How can i parse this data? The output i want is:
date: 05-04-11
time: 12:00:00
ch01: 000.00
ch02: 000.00
[Code].....
View 2 Replies
Jul 21, 2009
I am having trouble getting audio stream meta data from an Akamai FMS stream. Everything is undefined and I'm not sure why. I am hoping maybe someone will notice something that I am overlooking. The stream is connecting and playing without a problem I just can't seem to figure out why all the meta data is undefined.
[Code]...
View 6 Replies
Mar 15, 2012
I am extending the b2ContactListener to find out the normals of my collisions. However, every time I get a contact with a sensor, the normal is always 0,0. How do I get the normal if one of the bodies is a sensor?
override public virtual function BeginContact( contact : b2Contact ) : void
{
var normal : b2Vec =
[Code]...
View 1 Replies
Dec 19, 2011
Below is code that has a timer countdown that reads off of the computer. Below in bold is code to read "if it reaches the date, go to and play frame (2).
[Code]...
Below is code that is manual input - I had set up a dynamic txt field in flash named it : raffle_tix_remain When loaded on to the host I can manulally update the xml code and the change will take effect. raffle_tix_remain.text = root.loaderInfo.parameters.raffle_tix_remain;
My question: Since the raffle_tix_remain is a manual input from a user to xml Is there a way to tell flash once it refreshes and "raffle_ tix_ remain" goes to (0)zero gotoAndPlay(2); and let it play like a "sold out" sign i guess that would be a if else statement.
[Code]...
View 1 Replies
Apr 9, 2010
I have a movieclip that is scrolled by means of a 'sensor' on each side of the stage. The clip scrolls fine in both directions, however here is my problem:When the users mouse leaves the stage, the movie clip stops dead in it's tracks, and this does not provide a nice smooth effect. Looking at the code below, is there any way I could tell the animation to ease out when the users mouse leaves the stage rather than simply stop suddenly?
class Sensor extends MovieClip {
public function Sensor() {
}
[code].....
View 1 Replies
Jan 17, 2011
extract bitmap data from an flv stream?
View 2 Replies
Oct 7, 2004
If they get a question wrong in my quiz ( weakest link) the money clip goes to zero and it goes onto the next question. If they get it right the money clip advances and they go onto the next question. I want to include each time that it should only go onto the next question if all questions have been asked. SO i want an extra if clause in both sections, saying if current question is more than 11 go to '#game over"The questions are saved in the frame of the quiz
_root.qArray = new Array("question: A;B;C;D")
_root.qArray.push("Question?:A;B; C; D")
There are 11 questions.At the moment at the section with choosing answers I have
function selectAnswer(n) {
// correct
if (answers[n] == correctAnswer) {
_root.money.nextFrame();
[code].....
View 1 Replies
Dec 14, 2011
I'm trying to get data from a namespaced xml file in a flex app. There is a root namespace (xmlns="blah") and another namespace (xmlns:i="blah"), and I'm able to access most tags using the following:
var ns:Namespace = doc.namespace();
var result:XMLList = doc.ns::element;
However, there are several tags that are subject to change in the application, and i'd like to not hardcode them, possibly using the elements method:
var result:XMLList = doc.elements(configuredField);
Is there a way to get elements with namespaces using the elements method, or a similar way to get XML elements in flex using a parameter?
View 1 Replies
Mar 2, 2012
I am making a strategy game and came across a kind of problem. Basically, I don't know how to deal with the dynamic creation of the units I need. Should I use some big switch statement or is there a more ideal solution?
View 3 Replies
Dec 7, 2009
I'm making a small memory game that is XML driven (users can upload images into the game). I've come to the point where I need to check if the user has filled out certain nodes or not, and if so; check that the input is valid - int when int is expected and whatnot.
What are the ways to check this, and which is best? So far I've only tried checking if a node is == "" or not, but I imagine there must be better ways. I will include lots of switches for the user which should all be optional. This calls for a neat way to validate it.
View 1 Replies
Aug 14, 2011
I would like to send and receive OpenSoundControl in an AIR application, on the opensoundcontrol.org website I have found existing libraries for many languages, but none for Action Script so far, do you know of one that could be readily used?
View 1 Replies
Apr 23, 2009
I have an app that has a fullscreen button that goes into fullscreen NO_SCALE. Keeps everything looking sharp. However, all of my movieclip positions aren't correct. To fix this, I need to use:
Code:
stage.addEventListener(Event.RESIZE, stageResize);
Then, in my stageResize function, I duplicate all my movieclips' x and y and (if necessary) widths. This seems wrong and cumbersome.
Here's an example of what I'm talking about. Full Screen - Doesn't Work Clicking on fullscreen brings you to fullscreen but the mc positions stay put. Here's the code for this one:
Code:
var btn_fullScreen:btnFullScreen = new btnFullScreen();
var btn_normalScreen:btnNormalScreen = new btnNormalScreen();
var bar_bg:barbg = new barbg();
[Code].....
View 3 Replies
Jul 1, 2009
Everything dealing with sharedObjects in the first frame is this:
[AS]
var PlannerData:SharedObject = SharedObject.getLocal("PlannerData");
SubjectChoices = PlannerData.data.subjectChoices;
if (SubjectChoices == undefined) {[code]....
Going to the second frame from the first frame, the data is perfect. Going back to the first frame from the second, I'll trace the data many times throughout the code without an onEnterFrame, and it'll tell me that the Array is good...But when I trace the onEnterFrame, it shows the Array is [undefined, undefined, ...] like..undefined 17 times.
View 1 Replies
Jan 25, 2011
I have an AS3 swf which users can upload jpg images to my EC2 instances which sit behind and Elastic Load Balancer. The jpg images are converted into bytearray data and sent using URLLoader.load(URLRequest)I make 2 calls when uploading, one to upload a large version, then another to upload a thumbnail version. A PHP script to which the bytearray data is uploaded converts this to a file using file_put_contents($destination,$GLOBALS["HTTP_RAW_POST_DATA"])Is it possible to combine these two requests into a single request which contains both the bytearray data for the large and thumbnail images and 'split' the HTTP_RAW_POST_DATA to create 2 files at the server. This would be better than uploading the bytearray for the large version then using something like ImageMagick to resize the resulting image into a thumbnail which I realise is another option.
View 1 Replies
Jul 28, 2011
I'm using Flash CS5.5. I had some unfinished work on flash 8 and I'm running actionScript 2.0 In one of my scenes I had come up with a good button set up I wanted to use in all of my scenes. So I duplicated the scene, and proceeded to re-name my layers on the new scene according to the new content in the form of bitmaps. Well, on the output I got warnings such as: "duplicated label on layers". My SWF is still showing normally but I don't know what to do with the warnings. Is there something I should have done other than double clicking directly on the old labels on the layers and chaging their name?
View 1 Replies
Mar 9, 2010
I have a Flash web app which displays user submitted PNG files. Files are uploaded to the server via some API prior to being displayed. I'd like to make sure no "bad" files are served to Flash, where "bad" is entirely unspecific. Is there a way to validate PNG files against the PNG specs (this would catch corrupted files)? Or any best pratice on dealing with untrusted image files? I only need to handle PNG, so JPG, GIF etc. support is necessary. Language mostly does not matter, though I'd prefer Python solutions. This is on a Unix webserver.
View 1 Replies
Sep 3, 2010
I'm creating a container and it's content at runtime. Here's a rough structure:
--VBox
----Form
-------FormItem
[Code]...
I've tried also validateNowand other similar methods. What I have here:
1. The HScrollBar is being added.
2. We increase a bit the width of container, so it disappears.
3. When it disappears, the validating throws the null-pointer exception when it tries to measure the non-existing scrollbar. I've also tried to add validateProperties before validation, but it didn't worked either.
View 1 Replies
Jun 25, 2011
I want to have a series of functions that execute one after another instead of one within another.
here's what I mean
[Code]...
View 2 Replies
Oct 3, 2011
I think there are 2 different practices with dealing with display object on the stage.You draw all the objects on the stage and then manipulate the "visible" attribute to show or hide them.You use addChild and removeChild to manipulate the visiblity.How do you think what is the best method for this?
View 3 Replies
Oct 5, 2011
In my project, there is a frame(png files) placed on the top of all symbols. After that, I apply mouse click event to the symbols that place underneath the frame symbol, but when I run the the game, I cannot click to the below symbols but only the frame symbol, although the frame is transparent.
The problem is, although the png picture has some transparent area, the mouse click cannot pass through it. Is there solution? Is there anyway I can disable a symbol from being clicked and mouse click event can recognize the symbol placed under it?
View 1 Replies
Mar 19, 2007
How do professional programmers deal with preferences for their application?when there are options to be chosen in an application, does the program is full of "if" to detect what option has been chosen?Let's say that there is a call to 30 functions in the program.But the user has got to choose between an option A or B that would modify the way those 30 functions work.Would you have to write 60 functions and then place an "if" condition each time to go to the needed one...
Or would it be possible to write at run time (after the program has read the preferences) the corresponding functions? So that it wouldn't be necessary to check conditions each time?The goal being to gain total speed in critical functions preventing their run to be slowed down by condition requests.
View 2 Replies
Jul 16, 2011
I have an associative array of values called definitionsArray which I use as references to instantiate classes in a run time shared library.I instantiate and push the object into a new array. The problem is when I try to access or do anything basically with that new array.As they are objects they don't seem to like being in a display list for example.
HTML Code:
var definitionsArray:Array;
var bubblesArray:Array;
var currentBubble:*;[code]...
View 11 Replies
Dec 21, 2010
I need to adapt it so that instead of looping all the way back to the beginning, it instead goes to points further into the animation (such as say 10 seconds in) rather than all the way back to the start.[code]Now, I'm thinking that what needs to be changed is the autoRewind = true section, but being a complete novice, I don't even know where to begin. I've seen online sections dealing with a goto command, but my attempts to alter the code haven't worked correctly
View 4 Replies
Dec 29, 2010
I can find in the Adobe's help that masks dont function when dealing with 3d (properties). In this case I stuck on big obstacle in my project,where I wanted to deal with masks, and .z property. I wanted to tween mainMovieClip via TweenLite to make it going away from view.mainMovieClip has mask inside it ( added by the code), and certainly after tween is done mask is unaplied anymore, what is more disgusting functionality for eventListeners (clicks) attached to movieClips behind the mask gone far away. So in the end mask does not work, and everything behind it doesnt too..I need some specialist if my approach to the problem could be somehow a solution. I tried by it doesnt seem to work:I thought that if before tween I would disable the mask, by just setting
mainMovieClip.someMaskHolderMc.mask = null;
and then after tween is done, I could re-set it:
mainMovieClip.someMaskHolderMc.mask = someMasker;
but I end with nothing though, apart of that after tweening I can click once of the areas I had eventListeners before the tween, and then
all functionality disappear. Masks do not work too .
View 2 Replies
Apr 18, 2011
With continued help from this forum I am getting closer to having a working program. I look forward to being able to help others like myself once I finish learning the AS3 ropes.I have created a 12 x 9 random number grid that populates each cell with a corresponding image based on each cell's numeric value. I have also created a shuffle button that randomizes the numbers in the grid. The problem I am running into is getting my button-click event to clear the current images off the grid in order to assign new ones (i.e. deleting the display stack objects in order to place news ones in the same locations).My question is this: what is the best way to handle an implicit coercion from an array to a sprite? I have pasted my entire code below so that you can see how the functions are supposed to work together. My trouble apparently lies with not being able to use an array value with a sprite (the sprite represents the actual arrangement of the grid on the display stack while the array starts out as a number than gets assigned an image which should be passed to the sprite).
View 10 Replies
Aug 5, 2010
I'm trying to deal with an error that happens when an XML files is "loaded" that doesn't exist.Line that causes the error:
Code:
loader.load(new URLRequest(url));
I've tried putting a try catch(e:Error) around it, I'm tried an event listener for IOErrorEvent:IOError, but I can't seem to deal with the error.
Error message:Quote: Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: [File Name] at blah blah.....
View 4 Replies
Oct 12, 2010
I need to load in a large CSV file (>1MB) and parse it. Generally this is quite easy to do by splitting first on linebreaks and then commas. The problem is though that some entries contain Strings that include their own commas. When this spreadsheet is converted to CSV, the lines containing commas are wrapped in quotes.
I've written a parser that first escapes all the commas in these strings, then splits it on linebreaks and then commas, and then unescapes the values again.
This is quite a slow process for such a long string, as I need to iterate through the whole string. Does anyone know a faster or more optimised method of dealing with this?
View 3 Replies
Jul 12, 2010
Seeing as I don't have too much formal education Flash/OOP in general, this is just one of those thing I can't seem to quite deal with gracefully. All I'm trying to do is to be able to load/reset my an instance of my game's main class (not the first class that gets pulled up by Flash, but the one that actually has games logic in it), which of course extends MovieClip. It took me a while before I could even make an instance in it, because it would silently crashed when I would try to do so, and what didn't help was that the output window stopped working, and I had to completely reinstall flash. As far as I remember I simply fixed it by taking out the "stage." from any of the lines of codes that had it.
[Code]...
View 6 Replies
Sep 22, 2009
I am trying to send data from Flash to .Net through POST. When I send a normal String variable, it works fine. But when I try to send an XML as string, it shows me: Error #2032: Stream Error, error.
View 4 Replies