Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-16-2006, 10:58 AM   #1
Incrue
the ever-living
 
Incrue's Avatar
 
Join Date: Jan 2006
Location: inside this plane
Posts: 113
Send a message via MSN to Incrue
Default AS2 to AS3 example

So, how this code would be in AS3???
Please help me to understand, i can only understand with examples...
origin = new Object();
origin.x = 150;
origin.y = 150;

focalLength = 300;

figureA.x = -50;
figureA.y = 0;
figureA.z = 0;
figureA.dir = 1;

figureB.x = 0;
figureB.y = 0;
figureB.z = 250;
figureB.dir = 1;

figureC.x = 50;
figureC.y = 0;
figureC.z = 500;
figureC.dir = 1;

speed = 20;
backAndForth = function(){
this.z += speed*this.dir;
if (this.z > 500){
this.z = 500;
this.dir = -1;
}else if (this.z < 0){
this.z = 0;
this.dir = 1;
}

var scaleRatio = focalLength/(focalLength + this.z);
this._x = origin.x + this.x * scaleRatio;
this._y = origin.y + this.y * scaleRatio;
this._xscale = this._yscale = 100 * scaleRatio;
this.swapDepths(-this.z);
};
figureA.onEnterFrame = backAndForth;
figureB.onEnterFrame = backAndForth;
figureC.onEnterFrame = backAndForth;
Incrue is offline   Reply With Quote
Old 02-16-2006, 05:17 PM   #2
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,859
Default

this is a very AS1 type example. you would be able to do this in as3, in a simmiliar way to which you have there, but because you are dynamically accessing and creating functions it will be slower than doing it the right way in AS3

there are a ton of blogs about that have examples of AS3 applications.
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.