Actionscript 3 :: Javascript Implement Math Functions Using Its Own Algorithms Or Outsource To Cpu/processor?
Nov 20, 2011
ActionScript3 states the following:
Note: The Math functions acos, asin, atan, atan2, cos, exp, log, pow, sin, and sqrt may result in slightly different values depending on the algorithms used by the CPU or operating system. Flash runtimes call on the CPU (or operating system if the CPU doesn't support floating point calculations) when performing the calculations for the listed functions, and results have shown slight variations depending upon the CPU or operating system in use.
My web application works with very large and small numbers that I suspect may see a difference depending on which machine is running it (especially with mobile devices whose processors aren't as powerful as desktop machines'). My question is, is this behavior a function of the language?
That is, I assume some languages implement their own algorithms for the above functions, and so may be more consistent (except for differences in round-off errors introduced by the choice of processor/CPU that would exist for all languages).
Anyone know if Javascript has it's own algorithms, or does it outsource them to the CPU/processor like ActionScript?
View 1 Replies
Similar Posts:
Feb 18, 2010
often seen in simple flash games. So you can look at an example. http:[url]....Green object shots a bullet and what i want to acheive is to run bullet toward black bar even if bullet is shot to the left side of the screen. Bullet should make a circle, slow down and change direction to the bar and finally proceed faster and faster to the bar. Simply it should behave like remote control rocket chasing enemy. Right now i am with this: Code: Select all
function movingBull(e:Event):void [code].........
//of course i dont know what should be inside if statement
//to make the code work.
View 2 Replies
Dec 2, 2003
I want to make a graph. Specifically, a graph of a normal population distribution.I think (please correct me if I'm wrong) that the best way for me to do this is to use two arrays for coordinates and use the lineTo function to connect the dots:
- An Index array up to about 300 as the "x-axis"
- A Second array to represent the "y-axis" created using the formula for normal population applied to each entry of the index array
So I need to create these two arrays in FMX. the first array i think should be created with a For loop: for(i=0;i<a.length;i++){} The second array somehow applying my formula to each entry in array 1.I believe my methods are correct, but I am having a great deal of trouble getting the AS down properly and I can't find many good sources on it.
View 4 Replies
Apr 23, 2011
I am learning AS3 and I try to remake an SimDate game. I have studies the functions and the Steps of the game and now I try to make the Functions myself.
I have 5 Attributes:
Strength
Knowledge
Charm
Health
Dollars
For each of them I have defined a variable. Now I need to make an math function. If I want to raise str:
statusstrenght = statusstrenght + addstr
This code is not the original. My other code is down below. I only wanted to show the process.
addstr == Math.random() *5
I wanted that the variable statusstrenght starts with 10. If I press the train Strenghtbutton the action addstr will be started and updates the statusstr with the new value. That's what I had in mind but I cant define the new value off statusstrenght + addstr. Do I have to add a new variable with newstatusstrenght or can I just overwrite the value of statusstrenght if I press the train strength button ?
Here is the code. The math functions aren't working. It is AS3.
import flash.events.*;
var statusstrenght:Number = 10;
var statusknowledge:Number = 10;
var statuscharme:Number = 10;
var statushealth:uint = 100;
var statusdollar:uint = 100;
[Code] .....
View 2 Replies
May 19, 2003
So, right now when I want to find the distance between two points, I go: dist = Math.sqrt((this_x-that_x)*(this_x-that_x)+(this_y-that_y)*(this_y-that_y)) BLECH! I don't want to do that every time. So I want to make a nice little function that I can apply to an object. Problem is, I don't know how to do this. Is it possible to end up with something as easy as: Math.dist(thisclipname, thatclipname)? How do you guys set up functions that do bulky math and return nice clean numbers?
View 4 Replies
Jan 29, 2012
I need to execute some javascript string code from flash swf file using actionscript 3.
I read that it could be done by passing the javascript code to the parent html document , using externalinterface.call function. Then I assume it will be faster if I can declare functions in the javascript code in the HTML document in the first use of externalinterface.call funtion ; if flash code calls the javascript code repeatedly. So let me ask you how to do that. For details , any javascript to be loaded is unknown in design time and I can not prepare a javascript file to be loaded.
View 2 Replies
May 17, 2011
I'm starting a project for browsers which requires some complex data processing. The algorithm I'm using is 50-100x faster when accelerated with GPU.
I could use JavaScript, Flash or other technologies with the browser.Is there any way I can access the GPU to accelerate the processing of my math?
View 3 Replies
Feb 18, 2009
I would like to ask if there are any articles that explains the overhead added to a flash program when using the Math functions in AS2.0?
View 0 Replies
Jul 26, 2010
I used a webkit to show a flash , but now I want to add a play button and control the flash , How to do ?
View 1 Replies
Jan 14, 2009
I've been on a mission to create a flash registration form that communicates with Joomla / CCBuilder. So far, I managed to figure everything out by myself but after a week and a half of working on this, I really want to get it out of the way. So I'm stumped on how to make a flash registration form using the code I made / was provided.
Here is part A of the form:
Code:
<form action="http://www.mywebsiteexample.com/index.php?option=com_comprofiler&task=registers&Itemid=53" method="post" id="cbcheckedadminForm" name="adminForm" enctype="multipart/form-data">
<input type="hidden" name="id" value="0" />
[Code]...
View 0 Replies
Dec 21, 2010
I have a website with a flash image viewer. Once user clicks on flash button, I need to give a confirmation modal dialog before saving the file and if user clicks on OK only I have to pop file download dialog. Confirmation dialog with in flash is not an option for me. So I have to invoke JS function to pop a confirmation.Within the site, a custom DHTML confirmation modal dialog is used and it has two JS callback functions one for "OK" and the other for "Cancel" button click event handers. I have to use this modal dialog for this need.With Flash player 10 security features, it is unable to pop flash file download dialog via JavaScript
View 1 Replies
Jul 22, 2009
Let's say I have a slider that can go between 0 and 1.The SoundTransform.volume also ranges between 0 (silent) and 1 (full volume),but if I use a linear function,let's say SoundTransform. volume = slider.volume, the result is rather not pleasing.I really haven't studied the human ear,but I overheard once that human perception is logarithmic, or something similar. What algorithms should I use for setting the SoundTransform.volume?
View 7 Replies
Sep 22, 2011
I'm doing a project where I manually create sorting algorithms.After several tests I found out that my heapsort is way quicker than quicksort (I think it should be the other way around), my selection sort is also faster than insertion sort.I'm testing using integers from -100 to 100, randomly generated, 5000 values in an array (I modified this number several times, still the same problems).My quicksort isn't in-place.I thought that maybe flash's recursive functions are slow? my heapsort uses loops, unlike quicksort. That's just a hypothesis though. I start a timer, run the class's exec() function, stop the timer and calculate the elapsed time.[code]
View 3 Replies
Mar 7, 2011
Here is the problem:
var p:int = 0;
var n:Number = 0;
n = 32.999999999999999;
p = Math.floor(n);
trace(p); // returns 33
n = 32.11111111111111;
p = Math.floor(n);
trace(p); // returns 32
I would expect both of these to return 32. I have searched, and it seems this is an unreported bug in AS3. Or ... am I doing something wrong?
View 4 Replies
May 1, 2011
I am working on a simple drawing application, and i need an algorithm to make flood fills.The user workflow will look like this (similar to Flash CS, just more simpler):the user draws straight lines on the workspace. These are treated as vectors, and can be selected and moved after they are drawn.user selects the fill tool, and clicks on the drawing area. If the area is surrounded by lines in every direction a fill is applied to the area.if the lines are moved after the fill is applied, the area of fill is changed accordingly.Anyone has a nice idea, how to implement such algorithm? The main task is basically to determine the line segments surrounding a point. (and storing this information somehow, incase the lines are moved)[code]
View 3 Replies
Sep 26, 2005
Wat is the diffrence between these two?
View 2 Replies
Jun 3, 2009
I am working with an older (CS3) file in CS4. I have some simple javascript on an actions frame on the site. Example:
Code:
commercial_btn.onRelease = function() {
getURL("JavaScript:openWin('commerical.html', '600', '620')");
}
For some reason this code is being disabled when I publish. When I click on it in preview, it brings up a browser window. But when I publish it, on my computer that is not connected to the internet, it says something like "Adobe flash player has stopped..." and when I test it on the computer which is connected to the internet, it doesn't do anything at all. Only one Javascript pop up works - it has slightly different code and is in a different place. I tried applying the code to these other buttons but no luck.
View 2 Replies
Mar 16, 2010
I am trying to register a javascript-function from Flash, using the navigateToURL function like this:
navigateToURL(new URLRequest('javascript:function init(){ ...doSomething()... }', '_self' ));
to have the function init() available via ExternalInterface --> ExternalInterface.call("init", This works fine in Firefox, but Internet Explorer fails to register the function.
View 5 Replies
Jan 20, 2010
I am using ExtrernalInterface.call(javascript_function, args); to call javascript functions from Flex. But this fails in case of browsers that have javascript disabled. Is there any other way to call javascript functions from flex?
View 3 Replies
Jun 17, 2009
I'm having some trouble calling a JavaScript function from the HTML file I've embedded my SWF in.
I'm currently using Flash 8.
I'm trying to to simply call a function which will open an alert window, but when I click my button, nothing happens.
Flash Code:
import flash.external.*;
testbutton.onRelease = function() {
ExternalInterface.call("testAlert", "Yay, it finally worked");
}
[Code].....
View 0 Replies
Sep 1, 2009
How to call a javascript method from flash ?? am having a simple javascript code ie
<script type="text/javascript">
function helloWorld() {
alert('Hello World');
}
</script>
Now how to call the method helloWorld() from flash ?Similarly how to call a php method also ?? am having the php code as,
<html>
<body>
<?php
function writeName()
[code]....
now i want to call writeName() from flash ?? how to achieve these things from flash ?
View 1 Replies
Aug 19, 2011
I am learning programming abstract data types. Trying to build custom hash table based dict.SO far I've created a class place holder.
public class HashMapDict implements IDict
{
private var _map:Array;[code].....
What I am thinking about is to use cryptography libs for hash generation. But I am a bit confused with how it should work. e.g. Tried to look on several libs like as3crypto (http:/url]....) and it seems to produce hash in a way I don't really think can be used for indexes in arrays.
View 3 Replies
Feb 16, 2009
I have a code in which I have to use Math.round if a certain value is for example 3.67 (67 is higher than 50) and Math.ceil if a value is for example 3.23 (23 is lower than 50). What can I do to make flash calculate if what after the dot �.� in 3.23 (for example) is higher than 50?
View 2 Replies
Jun 17, 2009
I'm having some trouble calling a JavaScript function from the HTML file I've embedded my SWF in.I'm currently using Flash 8.I'm trying to to simply call a function which will open an alert window, but when I click my button, nothing happens.
Flash Code:
import flash.external.*;
testbutton.onRelease = function() {
ExternalInterface.call("testAlert", "Yay, it finally worked");
[code]....
View 1 Replies
Sep 1, 2009
How to call a javascript method from flash ?? am having a simple javascript code ie
<script type="text/javascript">
function helloWorld() {
alert('Hello World');
}
</script>
Now how to call the method helloWorld() from flash ??
Similarly how to call a php method also ?? am having the php code as,
<html>
<body>
<?php
[Code].....
now i want to call writeName() from flash ?? how to achieve these things from flash ?
Wats the code i have to write in flash cs3 ??
View 4 Replies
Sep 21, 2010
just a quickie - im sure this is possible but for some reason its not working, - can you put variables within javascript calls, ie
getURL("javascript:swffit.fit('my_flash',1024,(700 +_root.imageHeight));");
where _root.imageHeight is a variable within flash
anyone know where i may be going wrong?
View 2 Replies
Aug 29, 2010
I use the following jQuery code to access functions in my SWF (FP 10.1 SWF embedded via SWFObject): $('#FlashApp')[0].someFunc(); This works fine in every browser.. except for Internet Explorer (surprise!). Surely, the point of jQuery is to make this code work across all browsers? I'd really rather not write extra code to check for IE. How can I talk to my SWF in a browser independent way?
View 3 Replies
Jul 21, 2011
I'm loading website by using htmlLoader.loadString(someHtml). There are included JS sources.Is there any chance to get access to functions which are inside this JS file?
I also set property placeLoadStringContentInApplicationSandbox to true.
View 2 Replies
Jan 5, 2009
I am using prototype.js to make AJAX calls. I need to do this in a flash document to replace the contents of a <div> which contain a Flash movie, to be replaced by HTML.
Here's the code on the button:
Code:
on(Release){
[code]....
View 1 Replies
Sep 1, 2009
How to call a javascript method from flash ?? am having a simple javascript code ie
<script type="text/javascript">
function helloWorld() {
alert('Hello World');
}
</script>
Now how to call the method helloWorld() from flash ??
Similarly how to call a php method also ?? am having the php code as,
<html>
<body>
<?php
[Code]....
now i want to call writeName() from flash ?? how to achieve these things from flash ?
Wats the code i have to write in flash cs3 ?
View 1 Replies