ActionScript 3.0 :: Strange Number Addition With Timer Ticks?
May 21, 2010I find the output of the following code extremely strange!
ActionScript Code:
package {
import flash.display.Sprite;
[code]....
I find the output of the following code extremely strange!
ActionScript Code:
package {
import flash.display.Sprite;
[code]....
Is there a way to set a fixed number of ticks on a DateTimeAxis?
View 3 Replieshow can I add number to a current variable in actionscript. My variable has data coming though php(numeric data) so I want to create an if statement to say this:
If the data number(let's use 5) is equal to 5+any number then do something.
Should be pretty simple but I can't seem to figure it out right now, how can I say "any number" with code?
ActionScript Code:
if(myVar == myVar+1){
//do something;
}
Thing is the + number is uknown... so + 1 may not work cause the number may be higher than 1.
I created a movie clip that i want to act as a button. Inside that movie clip i place 2 graphic symbols (in different layers) that each have a tween of 30 frames. In a different layer i put a stop(); at frames 1 and 30. Then i create a fourth layer writing the following code for all 30 frames:
Code:
var rewind:Timer = new Timer(10);
var rootButton:MovieClip = MovieClip(parent);
rootButton.RR_mc.buttonMode = true;
rewind.addEventListener(TimerEvent.TIMER, rewindHandler);
[Code]...
1. On mouse over the movie clip (RR_mc) start playing normaly untill frame 30 where stops.
2. On mouse out the movie clip starts rewind going frames backwards. Now if i put my mouse over the movie clip, before rewind reach frame 1 the rewind stops and the movie start playing again. 2b. If the movie clip reach frame 1 after rewind, then is not stopping and continues to give frame 1 (if you put a trace(this.currentFrame(); you get infinite 1s). On mouse over the movie clip afterwards i can see that trying to start play but it's progress is max 2-3 frames before the rewind routine pull it back at frame 1.
3. If i transfer the timer and it's function to the parent directory then everything work fine.
I want to write all the code for the button inside the child directory of that button, is it possible?
My problem is quite simple to describe, in flex: 0.8 - 0.2 = 0.6000000000000001 I'm sure the first two members are 0.8 and 0.2 and are Number class, why would this happen?? And another thing, I cast the value from * type like this:
var value:*=0.8;
var castValue:Number = Number(value);
But nothing more, if I trace value I get 0.8 not 0.800000000000001 or something.
I'm doing some calculation with numbers and would like to only print an integer (the number without the decimals).I thought that the toFixed() method of the Number class would do the trick, and it does most of the time. But quite frequently strange values are returned. Here are 2 examples:
Number(0.002).toFixed(0) returns
"0." while
Number(1.002).toFixed(0) returns
"1" (without the period)
Once in a while, Number(0.002).toFixed(0) returns "1"
Needless to say that's not the expected behaviour. Am I not using this method correctly?
*edit: I know I just have to do int(0.002) to get 0 but I'd like to understand that strange behaviour.
I've created a circle and I need to draw equal separated ticks along ityou know like in a humanscale analogue machine.
View 5 RepliesI want to pass a number value to a Timer. How do I do this? My number and integer values for other variables work fine.
I get null object reference and coercion of value, because I'm not passing to 'timer' properly. I don't want to say my variable's a number, I want to say it has a number value.[code]...
I'm making a snake game and on every tick the snake moves. because the snake is moving a whole unit on each tick the animation is jumpy. The game is on an invisable grid so the snake can only change directions at specific points. Would it be considered better practice to have a timer that will move the snake a pixels at a time counting it with a variable, and on every n tick run the code to change direction. Or is it better to have two separate timers; one for move the snake a pixel at a time and another for changing the snakes direction?
View 1 RepliesI am running a sweepstakes like thing and want my users to all be able to load the page and have the exact same countdown and number generator running. I tried this in AS3 but each user caches their own swf file and gets a different result from the random number generator, and the as3 countdown is a few seconds off from each user. How would I go about making a countdown that is the exact same for each user looking at it at the same time and then a random number generator where every user will see the same result it gives? Is it even possible?
Sorry I wasnt clear on this. I would like to have it where the viewers could see the number being generated when the timer runs out. Kind of like watching the lotto on TV. Again, not sure if this is possible. I have looked around, I know as3, some php, and some javascript. I have given up on doing this in flash.
I'm using a CartesianChart with a DateTimeAxis to display weekly data in a Flex application.When I set dataUnits="weeks" and labelUnits="weeks" on the DateTimeAxis, it automatically places each major tick on a Sunday. However, I would like to provide users with the option of beginning the week on a Sunday or a Monday. How can I ask the DateTimeAxis to instead place the major ticks on a Monday (or some other day of week)?For example, if the user is looking at total sum of something over the week, and requests that weeks start on a Sunday, the Series data would look like:
x: Date(July 11, 2010) y: 25
x: Date(July 18, 2010) y: 30
x: Date(July 25, 2010) y: 32
[code]......
i am trying to create a timer that when it reaches to the number 10 it changes the text in a dynamic text box, i have got the timer counting but when it gets to 10 it doesnt do anything.here is my code:
Code:
stop()
cooltimer.text = "0";
var myTimer:Timer=new Timer(1000,0);[code]....
Here we go... i know, that i have to CAST them... but how? The idea is to add (adition) two strings...
a:String = "20";
b:String = "10";
c:String = a+b;
I get c=2010 and not 30 as i expected... i guess i have to cast, but how?
i want to add two numbers, which has entered in two input text fields.[code]here if i entered 3 in one text field and 2 in another text field. the result is comming like 32. It should be "5".
View 4 RepliesI am trying to figure out a way to add 2 colors (hex values) to generate a new color.I am not sure as to how this can be computed. Is the new color an average of the hex values of the 2 colors?
View 7 RepliesSo I've defined my variable:_global.current = 1;And below i am accessing an MC called 'carousel_holder', which has an MC named 'bar' and inside this MC is a final MC named 'bar1'.So ive tested my path and can hard code it fine, so its not a paths issue but i think my syntax is incorrect:_root.carousel_holder+".bar"+current.gotoAndPlay(" start");
View 4 RepliesIn flex, I am trying to do date deduction and addition, but couldn't find a way to do it.
e.g.: public var dateNow:Date=new Date();
How can I get the Date 3 months earlier than dateNow?
if container like VBox have autoScrollPolicy for both scrolls. if VerticalScrollBar is added, why the horizontalScrollBar automatically added.. is there any option to avoid the horizontalScrollBar addition to container.. without using horizontalScrollPolicy="off"
View 1 RepliesI have created an item renderer spark list in flex , but i want to call a function on addition of new row in list and not afterwards. I am getting a data object in rendered list in it i am getting the type of data to be displayed in list ie. either text or image. So on addition of new data in list i want a function to be called up in rendered list that checks the type of data received and then it will either create and add an image element or a text element. So the main problem is how i get a function called on addition of data. I have tried events like datachange and added but they keep on calling the function over and over again when we scroll the list but i want the function to be called once only on addition of data and not after wards. Below is the renderer list code , maybe you will get a better idea of what i am trying to do:
[Code]...
how to put the images deynamically into flash-the complete procedure. what all is to be done in flash n xml n how to connect them properly.
View 1 RepliesI am trying to add two variables, but my AS is joining them
volume1=function(answer1){
aa=wtft*12;
aaa=wtin;[code]....
There is more to this script, but I cut it down to this in order to focus on the error, which results in a joining aa and aaa. i.e. aa=36 aaa=4 results in a=364, where what I want would be a=40
has anyone had any problems with addition? I'm trying to get two numbers to add and instead it is concatenating them together as a string, however when I multiply, divide, or even subtract them it works fine.
View 10 RepliesI am developing an Audio Player application in Adobe AIR with Flex SDK 3.2. I wanted to know if i can play songs in other audio formats?
View 2 RepliesI have a divided box that has 3 panels in it... when a certain tab in tab navigator is clicked, then the sidebar with the three panels changed. One tab might show one Panel, another tab might show two of the panels and so on.
I can turn panels invisible and hide the dividers and ever almost positions the panels right, but the dividers still exists so it's not as dynamic as I would like.
Is their an easier way to add and remove panels from the Divided box that won't take as much manual configuration and hacking to make look right?
The problem is once I hide a panel the divider still exists.
Why do these numbers produce different results. Leading zero-trails shouldn't affect the result!!! GRRR!! :P
[Code]....
All of these produce in correct answers except the last one (which is the standard equation with no leading-zeros.)
I've created a MXML Component that consists of two TextInput boxes (user can input a "name" and "description"). I'm attempting to add and remove this component dynamically to a VBox in an MXML application. I've achieved addition thusly:
[Code]....
However, I cannot seem to get the remove() going after trying various ways with box.removeElement().
Why not have the Adobe Flash CS5 product directly generate mp4 and other formats in addition to SWF?From my chair (as an Adobe Flash CS5 user) it
-Going about using other additional software has direct effect on a software budget.
-Costs extra manhours to gather information of how it is done.
-Costs extra manhours/user time to process.
-Perhaps even increases the likelihood for errors and noise in re-processing already processed files (SWF->{F4V,MOV,MP4}) (F4V->{MP4,MOV},)relative to the original source FLA file?
i have two tree one tree lets say TreeDrag is drag enabled and other is drop enabled lets say TreeDrop.. when i drag item from TreeDrag to TreeDrop,, i want to show feedback and everything else normal except the addition of dragged item in TreeDrop..
View 1 RepliesSay for example I have a ball and I would like to move it towards a specific angle and a specific magnitude I would use something like:
[Code]...
Now if I wanted to change this force, for example, add a force to it, say, with magnitude 0.5 and angle 20, how would I do that?
I am working on a very simple game in Flash. I want to make all the animations framerate agnostic, so that I can change the framerate without affecting the flow and speed of the game.I read somewhere that if you want to do that, you simply create a Timer object and attach an event listener to this timer.
What if I have many objects that have to listen to the same timer? See the code to understand what I am trying to do. At this stage nothing breaks, but the event does not fire.Here is the Main class, the one that runs on swf execution:
public class Main extends MovieClip {
private static var _stage:Stage;
private static var _timer:Timer;
[code]....