Skip to main content
Inspiring
June 23, 2015
Question

Modify actionscript 2 to actionscript 3

  • June 23, 2015
  • 1 reply
  • 321 views

Can anyone modify this code below from this actionscript 2 to actionscript 3.

Here is code.

import mx.utils.Delegate;

import mx.events.EventDispatcher;

class albumScroll extends MovieClip{

private var mc_drag : MovieClip;

private var mc_backscroll : MovieClip;

private var max_height : Number;

private var h_mcscroll : Number;

private var out_range : Number;

private var perc_to_range : Number;

private var startmc_drag : Number;

private var endDrag : Number;

private var perc_drag : Number;

private var setupscroll : Boolean;

private var n_maxview : Number;

private var addEventListener:Function;

private var removeEventListener:Function;

private var dispatchEvent:Function;

function  albumScroll(){

var scroll:MovieClip= this;

mc_drag= scroll.drag_mc;

mc_backscroll= scroll.backscroll_mc;

EventDispatcher.initialize(this);

}

public function setMeasure(x:Number, y:Number, h:Number):Void{

_x= x;

_y=y;

max_height= h;

setBackGround();

}

public function  setup(mc_scroll:MovieClip, maxview:Number):Void{

scrollMovieClip(mc_scroll, maxview);

}

private function setBackGround() : Void {

mc_backscroll._height= max_height;

}

private function scrollMovieClip(mctoscroll : MovieClip, maxw: Number) : Void {

out_range= mctoscroll._height-maxw;

if(out_range > 0){

perc_to_range= out_range*100/h_mcscroll;

setupScrollDrag();

}

}

private function setupScrollDrag() : Void {

var scroll:MovieClip= this;

startmc_drag= mc_drag._y;

endDrag= mc_backscroll._height-mc_drag._height;

mc_drag.onPress=Delegate.create(this, onDragBar);

mc_drag.onRelease=mc_drag.onReleaseOutside=Delegate.create(this, onStopDragBar);

if((mc_drag._y + mc_drag._height) >n_maxview){

mc_drag._y= n_maxview-mc_drag._height;

checkDrag();

}

}

private function onDragBar(){

mc_drag.startDrag(false,mc_drag._x,startmc_drag,mc_drag._x, endDrag);

this.onEnterFrame= Delegate.create(this,checkDrag);

}

private function onStopDragBar(){

stopDrag();

this.onEnterFrame= null;

}

private function checkDrag() : Void {

perc_drag=mc_drag._y*100/endDrag;

dispatchEvent({type:"scrolla", target:this,perc:perc_drag});

}

}

import mx.utils.Delegate;

import mx.transitions.Tween;

import mx.transitions.easing.*;

stop();

var mainRoot:MovieClip = this;

var mcscroll:MovieClip = mainRoot.image_mc;

var maskscroll:MovieClip = mainRoot.mask_mc;

mcscroll.setMask(maskscroll);

var scrollMc:MovieClip = mainRoot.attachMovie("scrollnew", "scrollnew", 0);

scrollMc.addEventListener("scrolla", Delegate.create(this, onScrollDrag));

startScroll = mcscroll._y + 5;

scrollMc.setMeasure(mcscroll._x+mcscroll._width+61.5, mcscroll._y+108.9, maskscroll._height);

scrollMc.setup(mcscroll, maskscroll._height);

function onScrollDrag(event_obj:Object):Void {

var perc:Number= event_obj.perc;

var max_move:Number = ((mcscroll._height + 80)-maskscroll._height);

var y:Number = (max_move*perc/100);

mcscroll._y = startScroll-y;

}

I have attach two files .as and .fla

http://noren.freevar.com/album.fla

http://noren.freevar.com/albumScroll.as

This topic has been closed for replies.

1 reply

sinious
Legend
June 23, 2015

To get help with your needs you should scope your question down to the portion you're having trouble with.

If you don't know AS3 at all, this wouldn't be the place to come to get something like this done. It's up to you to learn AS3 and convert your own code. You're welcome to post questions about any part of the conversion process as you go. It's quite a leap up.