-
[Q] Re-Write Javascript to Actionscript 3
Is there a table or a guide that i can use to get the equivelant code for JavaScript to ActionScript 3 at all? Doing a google search brings up a whole lot of bubcus in tearms of usefull information on the subject.
If anyone knows of a table or anything of the like that would be great.
DSD
-
Senior Member
that should not be hard to figure out yourself :P e g let us take this js summary:
PHP Code:
function Cat(name, color){ /* Constructor: any code in here is run when the object is created */ Cat.cats++;
/* Private variables and functions - may only be accessed by private or privileged functions.
Note that 'name' and 'color', passed into the Class, are already private variables. */ var age = 0; var legs = 4; function growOlder(){ age++; }
/* Public variables - may be accessed publicly or privately */ this.weight = 1; this.length = 5;
/* Privileged functions - may be accessed publicly or privately May access Private variables.
Can NOT be changed, only replaced with public versions */ this.age = function(){ if(age==0) this.length+=20;
growOlder(); this.weight++; } }
/* Prototyped Functions - may be accessed publicly */ Cat.prototype = { talk: function(){ alert('Meow!'); }, callOver: function(){ alert(this.name+' ignores you'); }, pet: function(){ alert('Pet!'); } }
/* Prototyped Variables - may be accessed publicly. May not be overridden, only replaced with a public version */ Cat.prototype.species = 'Cat';
/* Static variables and functions - may be accessed publicly */ Cat.cats = 0;
In AS3, that could be something like:
PHP Code:
package { public class Cat { private var name:String, color:uint; public function Cat (name:String, color:uint) { this.name = name; this.cat = cat; } private var age:int = 0, legs:int = 4; private function growOlder():void { age++; } public var weight:Number = 1, length:Number = 5; public function ageIt /* iirc naming this just "age" would conflict with var above */ ():void { if(age==0) this.length+=20;
growOlder(); this.weight++; } public function talk():void { trace('Meow!'); } public function callOver():void { trace(this.name+' ignores you'); } public function pet():void { trace('Pet!'); } public var species:String = 'Cat'; public static var cats:int = 0; } }
The mapping is not 1:1 but pretty close.
-
Senior Member
ah, I missed Cat.cats++; in the constructor:
PHP Code:
public function Cat (name:String, color:uint) { this.name = name; this.cat = cat; Cat.cats++; }
-
Originally Posted by realMakc
that should not be hard to figure out yourself :P e g let us take this js summary: -=- snip --
Ok what im trying to achieve is to get this: Radar to display in flash. Either as a whole or as a 'projection' from the page itself. So i either want to know if its possible to recode this using AS3 or can i 'Project' it as a live feed of sorts to a swf file?
DSD
-
Senior Member
this link doesn't do much for me beyond looping several images. it requests jsoon data from this address, and there you can see actual image URLs. so it is just a matter of loading all these images into flash (using Loader or URLLoader class) and then swapping them on the screen every second. what I am saying is that here it is easier to replicate the behavior than to port javascript itself.
Last edited by realMakc; 10-16-2013 at 06:49 AM.
-
Originally Posted by realMakc
this link doesn't do much for me beyond looping several images.
Thats part of what the JS code does yes, but aside from looping the images i want to be able to utilize the scripts ability to automatically update the images to the next set without manual input.
Originally Posted by realMakc
it requests jsoon data from this address, and there you can see actual image URLs. so it is just a matter of loading all these images into flash (using Loader or URLLoader class) and then swapping them on the screen every second. what I am saying is that here it is easier to replicate the behavior than to port javascript itself.
If it were that simple I wouldent have come here for help with this.. Ive researched alot of different approaches to this, but noone has an answer as to how i can either, replicate this or project whats on the page into a SWF file.
I do appreciate the effort and help you are trying to provide.
DSD
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|