• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Converting AS2 to AS3

Community Expert ,
Apr 08, 2009 Apr 08, 2009

Copy link to clipboard

Copied

Hi,

I'm trying to create a carousel effect for my photography website.

I've found a free template that I could use but it uses AS2 (I'm more familiar with AS3 so that I could change or add to the code).

Can anyone help me to convert the code to AS3?

Here's the code:

stop();

// total is length of label_list OR link_list
// OR total frames inside "flashmo thumbnails"
var total:Number = 9;
// length of label_list array and length of link_list array must be equal
// to length of frames inside "flashmo thumbnails" movieclip

var label_list:Array = new Array( " Poland 1998 ", "Romania 1999", "Slovakia 1999", "Slovakia 2000", "Germany 2001", "London 2002", "Croatia 2003", "Italy 2003", "Ukraine 2004");

var link_list:Array = new Array("http://www.flashmo.com/preview/flashmo_041_horizontal_scroller", "http://www.flashmo.com/preview/flashmo_042_vertical_scroller", "http://www.flashmo.com/preview/flashmo_043_intro", "http://www.flashmo.com/preview/flashmo_044_intro", "http://www.flashmo.com/preview/flashmo_045_elastic", "http://www.flashmo.com/preview/flashmo_046_thumbnail_xml", "http://www.flashmo.com/preview/flashmo_047_present", "http://www.flashmo.com/preview/flashmo_048_vertical_menu_xml",
"http://www.flashmo.com/preview/flashmo_048_vertical_menu_xml");

var radiusX:Number = 330;
var radiusY:Number = 90;
var centerX:Number = 450;
var centerY:Number = 250;
var speed:Number = 0.005;
tn_group_mc._visible = false;
info.text = ""; fm_label.text = "";

for( var i = 0; i < total; i++)
{
    var t = tn_group_mc.duplicateMovieClip("tn"+i, i);
    t.tn_mc.gotoAndStop(i+1); t.tn_shadow_mc.gotoAndStop(i+1);
    t.fm_label = label_list;
    t.fm_url = link_list;
   
    t.angle = i * ((Math.PI*2)/total);
    t.onEnterFrame = mover;
   
    t.fm_button.onRollOver = function()
    {
        fm_label.text = "" + this._parent.fm_label;
        info.text = "URL: " + this._parent.fm_url;
    }
    t.fm_button.onRollOut = function()
    {
        info.text = ""; fm_label.text = "";
    }
    t.fm_button.onRelease = function()
    {
        getURL( this._parent.fm_url );
    }
}
function mover()
{
    this._x = Math.cos(this.angle) * radiusX + centerX;
    this._y = Math.sin(this.angle) * radiusY + centerY;
    var s = this._y /(centerY+radiusY);
    this._xscale = this._yscale = s*100;
    this.angle += this._parent.speed;
    this.swapDepths(Math.round(this._xscale) + 100);
}
this.onMouseMove = function()
{
    speed = (this._xmouse-centerX) * 0.0001;
}

Adobe Community Expert
Adobe Certified Professional
TOPICS
ActionScript

Views

893

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2009 Apr 08, 2009

Copy link to clipboard

Copied

Dear,

have it...

Regards,

JON

var total:Number = 9;
var label_list:Array = new Array( " Poland 1998 ", "Romania 1999", "Slovakia 1999", "Slovakia 2000", "Germany 2001", "London 2002", "Croatia 2003", "Italy 2003", "Ukraine 2004");
var link_list:Array = new Array("http://www.flashmo.com/preview/flashmo_041_horizontal_scroller", "http://www.flashmo.com/preview/flashmo_042_vertical_scroller", "http://www.flashmo.com/preview/flashmo_043_intro", "http://www.flashmo.com/preview/flashmo_044_intro", "http://www.flashmo.com/preview/flashmo_045_elastic", "http://www.flashmo.com/preview/flashmo_046_thumbnail_xml", "http://www.flashmo.com/preview/flashmo_047_present", "http://www.flashmo.com/preview/flashmo_048_vertical_menu_xml",
"http://www.flashmo.com/preview/flashmo_048_vertical_menu_xml");
var radiusX:Number = 330;
var radiusY:Number = 90;
var centerX:Number = 450;
var centerY:Number = 250;
var speed:Number = 0.005;
info.text = "";
fm_label.text = "";

for( var i = 0; i < total; i++)
{  
    //"tn_group_mc" delete this movieclip from your stage and in linkage add the same name for the same movieclip.
    var t = new tn_group_mc();
    addChild(t);
   
    // you may open the below code as i do not have your movieclip
    //t.tn_mc.gotoAndStop(i+1);
    //t.tn_shadow_mc.gotoAndStop(i+1);
    t.fm_label = label_list;
    t.fm_url = link_list;
    t.angle = i * ((Math.PI*2)/total);
    t.addEventListener(Event.ENTER_FRAME, mover);
   
       t.fm_button.addEventListener(MouseEvent.ROLL_OVER, fn_onRollOver);
    t.fm_button.addEventListener(MouseEvent.ROLL_OUT, fn_onRollOut);
    t.fm_button.addEventListener(MouseEvent.CLICK, fn_onRelease);
}
function fn_onRollOver(eve)
{
    fm_label.text = "" + eve.target.parent.fm_label;
    info.text = "URL: " + eve.target.parent.fm_url;
}
function fn_onRollOut(eve)
{
    info.text = "";
    fm_label.text = "";
}
function fn_onRelease(eve)
{
    var request:URLRequest = new URLRequest(eve.target.parent.fm_url);
    navigateToURL(request);
}
function mover(eve)
{
   
    eve.target.x = Math.cos(eve.target.angle) * radiusX + centerX;
    eve.target.y = Math.sin(eve.target.angle) * radiusY + centerY;
    var s = eve.target.y /(centerY+radiusY);
    eve.target.scaleX  = eve.target.scaleY = s;
    eve.target.angle += eve.target.parent.speed;
   
    // need some work on it.
    //this.swapDepths(Math.round(this._xscale) + 100);
    //setChildIndex(eve.target, Math.round(eve.target.scaleX*100)+100);
}

stage.addEventListener(Event.ENTER_FRAME,mousemove);
function mousemove(eve)
{
    speed = (mouseX-centerX) * 0.0001;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2009 Apr 08, 2009

Copy link to clipboard

Copied

Hi Jon,

Thank you very much for a quick reply.

I'm getting an error message and the clips just change without the effect of a carousel. I'm attaching a screenshot as well.

Error message:

Frame1, Line 24:

1180: Call to a possibly undefined method tn_group_mc.

Adobe Community Expert
Adobe Certified Professional

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2009 Apr 09, 2009

Copy link to clipboard

Copied

LATEST

Dear,

In your AS2 code you have movieclip 'tn_group_mc" on the stage delete the same from the stage. For the same mvieclip in library give linkage name as "tn_group_mc".

Regards,

Jon

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines