-
Converting AS 2.0 scroller to AS 3.0
Hi,
I'm trying to upgrade an AS 2.0 scroller to AS 3.0, but haven't got the first clue when it comes to removing stuff like _root etc.
My code is:
PHP Code:
function parallax (layer, speed)
{
var distance=_root._xmouse-Stage.width/2;
if (_xmouse > Stage.width/2){
layer._x -= distance*speed;
}else{
layer._x += distance*-speed;
}
if(layer._x <= 0){
layer._x = layer._x + layer._width/2;
}else if(layer._x >= layer._width/2){
layer._x = layer._x - layer._width/2;
}
}
profiles_mc.onEnterFrame = function() { parallax(this, 1/40); }
Can someone help me to work out how to make it work in AS 3.0, please?
Cheers.
-
I have no way of testing this to make it work for you but this would be a start:
PHP Code:
import flash.display.MovieClip; import flash.events.Event;
profiles_mc.addEventListener(Event.ENTER_FRAME, profilesEnterFrame);
function parallax(layer:MovieClip, speed:int):void { var distance:int = (_root._xmouse - (Stage.width / 2)); if (mouseX > (stage.stageWidth / 2)) { layer.x -= distance * speed; }else{ layer.x += distance * -speed; } if (layer.x <= 0) { layer.x = layer.x + layer.width / 2; }else if(layer.x >= layer.width / 2){ layer.x = layer.x - layer.width / 2; } }
function profilesEnterFrame(e:Event):void { parallax(profiles_mc, 1 / 40); }
If you post your files we can help further.
-
Bald By Choice
PHP Code:
function parallax(layer:String, speed:Number):void{ var distance:Number=stage.mouseX-stage.stageWidth/2;
if (mouseX > stage.stageWidth/2){ this[layer].x -= distance*speed; }else{ this[layer].x += distance*-speed; } if(this[layer].x <= 0){ this[layer].x = this[layer]._x + this[layer].width/2; }else if(this[layer].x >= this[layer].width/2){ this[layer].x = this[layer].x - this[layer].width/2; } }
-
Thanks for your help so far. I will post the files when I get home from work.
-
-
Paste this code into your actions, works for me:
PHP Code:
stop(); var arthur_mitchell:MovieClip = new MovieClip();
arthur_mitchell.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); arthur_mitchell.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); arthur_mitchell.addEventListener(MouseEvent.MOUSE_DOWN, amitchellVideo);
function mouseOverHandler(e:MouseEvent):void { arthur_mitchell.alpha = 0; }
function mouseOutHandler(e:MouseEvent):void { arthur_mitchell.alpha =.4; }
function amitchellVideo(e:MouseEvent):void { gotoAndStop("atkins"); }
import flash.display.MovieClip; import flash.events.Event;
profiles_mc.addEventListener(Event.ENTER_FRAME, profilesEnterFrame);
function parallax(layer:MovieClip, speed:Number):void { var distance:Number = (mouseX - (stage.stageWidth / 2)); if (mouseX > (stage.stageWidth / 2)) { layer.x -= (distance * speed); }else{ layer.x += distance * -speed; } if (layer.x <= 0) { layer.x = layer.x + layer.width / 2; }else if(layer.x >= layer.width / 2){ layer.x = layer.x - layer.width / 2; } }
function profilesEnterFrame(e:Event):void { parallax(e.target, 0.025); }
-
Thank you so much. There is one more issue, if you can help me fix it. I've tried to set the code so that when you click on a face it sends you to a new part on the timeline so that it will play a particular video. I was going to use different frames, but AS 3.0 doesn't like that, so can you suggest a slicker way of going about it...
Thank you so much again...
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
|