News:

If you need instructions on how to get through the hotels, check out the enclosed instruction book.

Main Menu

AS3 to AS2 Code Conversion Help

Farted by F U Clock, May 29, 2012, 02:29:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

F U Clock

Hey, I'm trying to program a site with some cool as-based skewing functionality. I found this simple chunk of code online that does exactly what I need it to:

import flash.events.Event;

stage.addEventListener(MouseEvent.MOUSE_MOVE, kk)

function kk(evt:Event):void
{
   
   var rotY: Number = (mouseY-(stage.stageHeight/2))/(stage.height/2)*(10);
var rotX: Number = (mouseX-(stage.stageWidth/2))/(stage.width/2)*(-10);
box_mc.rotationX = rotY;
box_mc.rotationY = rotX;
}

If you want to see it work just plug it into an AS3 file and make a movieclip with a center anchor point and give it instance name "box_mc" and move your mouse around.

Main issue is this code works in AS3, but AS2 doesn't load the "Event" class. I'm pretty ignorant of classes in general so I don't know how to go about converting this to AS2 functionality, or if it's even possible, but since the code is so simple I thought it might be doable. Any suggestions?

NINJA EDIT: In case you're wondering the reason we need it to be in AS2 is because this site is due in three days to meet the ad campaign going with it and the main skeleton of the site has already been built by a colleague o' mine in AS2.

AmberArachnidClock

It's definitely possible, you just have to change the whole syntax. I'll take a crack at it, be back in a few

AmberArachnidClock

This'll be a little sketchy but it might work.

1. Create a blank movieclip and place it on the stage. Instance name it mouseMov_mc

2.put this code in your frame on the stage:

_root.mouseMov_mc.onMouseMove = function() {
var rotY: Number = (_root._ymouse-(stage.height/2))/(stage.height/2)*(10);
var rotX: Number = (_root._xmouse-(stage.width/2))/(stage.width/2)*(-10);
box_mc.rotationX = rotY;
box_mc.rotationY = rotX;
};

tell me if that works

F U Clock

Thanks for the help. It's not functioning as far as I can tell, though I'm not getting any errors... Here's the .fla I set up. This is CS5 though... What's your version?

http://www.phgtestsite.com/skewertest.fla.zip

SpongeClock SquarePants

i'll try and have a look at this if i have time. Other way around (as2 to as3) would have been easier for me since as3 is about the only thing i still know

AmberArachnidClock

Okay so I didn't realize that this was 3d rotation. I'm not sure if you can do that in AS2. I wouldn't know how.