Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 590435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:31:45+00:00 2026-05-13T15:31:45+00:00

How would I go about converting my actionscript 3 (on the timeline) into a

  • 0

How would I go about converting my actionscript 3 (on the timeline) into a class? As I am using the same functionality across multiple FLA files.

// IMPORTS

import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.external.ExternalInterface;


// VARIABLES

mcToolTip.toolTip.blendMode = BlendMode.LAYER;
mcToolTip.toolTip.text = "";
var toolio = false;
var settext;

var urlButton1:String = 'URL STRING 1';
var urlButton2:String = 'URL STRING 1';
var urlButton3:String = 'URL STRING 1';
var urlButton4:String = 'URL STRING 1';
var urlButton5:String = 'URL STRING 1';

// MISC

mcButton1.stop();
mcButton2.stop();
mcButton3.stop();
mcButton4.stop();
mcButton5.stop();

mcButton1.buttonMode = true;
mcButton2.buttonMode = true;
mcButton3.buttonMode = true;
mcButton4.buttonMode = true;
mcButton5.buttonMode = true;

// EVENT LISTENERS

//button1
mcButton1.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcButton1.addEventListener(MouseEvent.MOUSE_OUT,mout);
mcButton1.addEventListener(MouseEvent.MOUSE_OVER,button1Text);
mcButton1.addEventListener(MouseEvent.MOUSE_DOWN,callButton1);
mcButton1.addEventListener(MouseEvent.CLICK,mclick);

//button2
mcButton2.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcButton2.addEventListener(MouseEvent.MOUSE_OUT,mout);
mcButton2.addEventListener(MouseEvent.MOUSE_OVER,button2Text);
mcButton2.addEventListener(MouseEvent.MOUSE_DOWN,callButton2);
mcButton2.addEventListener(MouseEvent.CLICK,mclick);

//button3
mcButton3.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcButton3.addEventListener(MouseEvent.MOUSE_OUT,mout);
mcButton3.addEventListener(MouseEvent.MOUSE_OVER,button3Text);
mcButton3.addEventListener(MouseEvent.MOUSE_DOWN,callButton3);
mcButton3.addEventListener(MouseEvent.CLICK,mclick);

//button4
mcButton4.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcButton4.addEventListener(MouseEvent.MOUSE_OUT,mout);
mcButton4.addEventListener(MouseEvent.MOUSE_OVER,button4Text);
mcButton4.addEventListener(MouseEvent.MOUSE_DOWN,callButton5);
mcButton4.addEventListener(MouseEvent.CLICK,mclick);

//button5
mcButton5.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcButton5.addEventListener(MouseEvent.MOUSE_OUT,mout);
mcButton5.addEventListener(MouseEvent.MOUSE_OVER,button5Text);
mcButton5.addEventListener(MouseEvent.MOUSE_DOWN,callButton5);
mcButton5.addEventListener(MouseEvent.CLICK,mclick);

// FUNCTIONS

function mclick(e:MouseEvent):void {
    toolio = true;
    e.currentTarget.gotoAndStop(5);
    e.currentTarget.removeEventListener(MouseEvent.MOUSE_OUT,mout);
    e.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER,mover);
    settext = mcToolTip.toolTip.text;

    if (e.currentTarget !== mcButton2) {
        mcButton2.addEventListener(Event.ENTER_FRAME, playReverse);
        mcButton2.addEventListener(MouseEvent.MOUSE_OUT, mout);
        mcButton2.addEventListener(MouseEvent.MOUSE_OVER,mover);
    }

    if (e.currentTarget !== mcButton3) {
        mcButton3.addEventListener(Event.ENTER_FRAME, playReverse);
        mcButton3.addEventListener(MouseEvent.MOUSE_OUT, mout);
        mcButton3.addEventListener(MouseEvent.MOUSE_OVER,mover);
    }

    if (e.currentTarget !== mcButton4) {
        mcButton4.addEventListener(Event.ENTER_FRAME, playReverse);
        mcButton4.addEventListener(MouseEvent.MOUSE_OUT, mout);
        mcButton4.addEventListener(MouseEvent.MOUSE_OVER,mover);
    }

    if (e.currentTarget !== mcButton1) {
        mcButton1.addEventListener(Event.ENTER_FRAME, playReverse);
        mcButton1.addEventListener(MouseEvent.MOUSE_OUT, mout);
        mcButton1.addEventListener(MouseEvent.MOUSE_OVER,mover);
    }

    if (e.currentTarget !== mcButton5) {
        mcButton5.addEventListener(Event.ENTER_FRAME, playReverse);
        mcButton5.addEventListener(MouseEvent.MOUSE_OUT, mout);
        mcButton5.addEventListener(MouseEvent.MOUSE_OVER,mover);
    }
}

function mover(e:MouseEvent):void {
    stopPlayReverse(e.currentTarget as MovieClip);
    e.currentTarget.play();
    var fadeIn:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 0, 1, 0.5, true);
}

function mout(e:MouseEvent):void {
    var mc:MovieClip = e.currentTarget as MovieClip; 
    if (mc !== null) {
        mc.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
    }
    if ( toolio == false ) {
        var fadeOut:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 1, 0, 0.5, true);
    }
    if (settext != undefined) {
        mcToolTip.toolTip.text = settext;
    }
}

function playReverse(e:Event):void {
    var mc:MovieClip = e.currentTarget as MovieClip; 

    if (mc.currentFrame == 1) {
        stopPlayReverse(mc);
    } else {
        mc.prevFrame();
    }
}

function stopPlayReverse(mc:MovieClip):void {
  if ((mc!==null) && mc.hasEventListener(Event.ENTER_FRAME)) {
    mc.removeEventListener(Event.ENTER_FRAME, playReverse);
  }
}

function button1Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 1"; }
function button2Text(e:MouseEvent):void { mcToolTip.toolTip.text = "Menu 2"; }
function button3Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 3"; }
function button4Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 4"; }
function button5Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 5"; }

function callButton1(evt:MouseEvent):void { ExternalInterface.call("button1", urlButton1);}
function callButton2(evt:MouseEvent):void { ExternalInterface.call("button2", urlButton2);}
function callButton3(evt:MouseEvent):void { ExternalInterface.call("button3", urlButton3); }
function callButton4(evt:MouseEvent):void { ExternalInterface.call("button4", urlButton4);}
function callButton5(evt:MouseEvent):void { ExternalInterface.call("button5", urlButton5);}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:31:45+00:00Added an answer on May 13, 2026 at 3:31 pm

    First thing, it appears you have “Automatically declare stage instances” checked in your settings. I avoid this like the plague. Follow the directions here: under “disabling stage instance auto-declaration.” Unchecking that box will force you to declare your other stage instances, like mcToolTip and the mcButtons. But it will help in future development efforts (trust me.)

    Anyway, I figured this would be your document class since you said it was used per swf. I named it MyFirstClass, you probably want a better name. You need to chance “BOTH” instances of that name… one in the class signature “public class MyFirstClass extends MovieClip” and the second in the constructor (the function with the same name as the class) which gets run as soon as the class is “instantiated“

    Put this file in the same directory as your .fla. Add “MyFirstClass” as the document class.

    Read up on more info about how to write your own class: here

    package {
        import fl.transitions.*;
        import fl.transitions.Tween;
        import fl.transitions.easing.*;
        import flash.external.ExternalInterface;
        impprt flash.display.MovieClip;
    
        public class MyFirstClass extends MovieClip {
            public var toolio = false;
            public var settext;
    
            public var urlButton1:String = 'URL STRING 1';
            public var urlButton2:String = 'URL STRING 1';
            public var urlButton3:String = 'URL STRING 1';
            public var urlButton4:String = 'URL STRING 1';
            public var urlButton5:String = 'URL STRING 1';
    
            public function MyFirstClass():void {
    
                mcToolTip.toolTip.blendMode = BlendMode.LAYER;
                mcToolTip.toolTip.text = "";
    
                mcButton1.stop();
                mcButton2.stop();
                mcButton3.stop();
                mcButton4.stop();
                mcButton5.stop();
    
                mcButton1.buttonMode = true;
                mcButton2.buttonMode = true;
                mcButton3.buttonMode = true;
                mcButton4.buttonMode = true;
                mcButton5.buttonMode = true;
    
                // EVENT LISTENERS
    
                //button1
                mcButton1.addEventListener(MouseEvent.MOUSE_OVER,mover);
                mcButton1.addEventListener(MouseEvent.MOUSE_OUT,mout);
                mcButton1.addEventListener(MouseEvent.MOUSE_OVER,button1Text);
                mcButton1.addEventListener(MouseEvent.MOUSE_DOWN,callButton1);
                mcButton1.addEventListener(MouseEvent.CLICK,mclick);
    
                //button2
                mcButton2.addEventListener(MouseEvent.MOUSE_OVER,mover);
                mcButton2.addEventListener(MouseEvent.MOUSE_OUT,mout);
                mcButton2.addEventListener(MouseEvent.MOUSE_OVER,button2Text);
                mcButton2.addEventListener(MouseEvent.MOUSE_DOWN,callButton2);
                mcButton2.addEventListener(MouseEvent.CLICK,mclick);
    
                //button3
                mcButton3.addEventListener(MouseEvent.MOUSE_OVER,mover);
                mcButton3.addEventListener(MouseEvent.MOUSE_OUT,mout);
                mcButton3.addEventListener(MouseEvent.MOUSE_OVER,button3Text);
                mcButton3.addEventListener(MouseEvent.MOUSE_DOWN,callButton3);
                mcButton3.addEventListener(MouseEvent.CLICK,mclick);
    
                //button4
                mcButton4.addEventListener(MouseEvent.MOUSE_OVER,mover);
                mcButton4.addEventListener(MouseEvent.MOUSE_OUT,mout);
                mcButton4.addEventListener(MouseEvent.MOUSE_OVER,button4Text);
                mcButton4.addEventListener(MouseEvent.MOUSE_DOWN,callButton5);
                mcButton4.addEventListener(MouseEvent.CLICK,mclick);
    
                //button5
                mcButton5.addEventListener(MouseEvent.MOUSE_OVER,mover);
                mcButton5.addEventListener(MouseEvent.MOUSE_OUT,mout);
                mcButton5.addEventListener(MouseEvent.MOUSE_OVER,button5Text);
                mcButton5.addEventListener(MouseEvent.MOUSE_DOWN,callButton5);
                mcButton5.addEventListener(MouseEvent.CLICK,mclick);
            }
    
            // FUNCTIONS
    
            public function mclick(e:MouseEvent):void {
                toolio = true;
                e.currentTarget.gotoAndStop(5);
                e.currentTarget.removeEventListener(MouseEvent.MOUSE_OUT,mout);
                e.currentTarget.removeEventListener(MouseEvent.MOUSE_OVER,mover);
                settext = mcToolTip.toolTip.text;
    
                if (e.currentTarget !== mcButton2) {
                    mcButton2.addEventListener(Event.ENTER_FRAME, playReverse);
                    mcButton2.addEventListener(MouseEvent.MOUSE_OUT, mout);
                    mcButton2.addEventListener(MouseEvent.MOUSE_OVER,mover);
                }
    
                if (e.currentTarget !== mcButton3) {
                    mcButton3.addEventListener(Event.ENTER_FRAME, playReverse);
                    mcButton3.addEventListener(MouseEvent.MOUSE_OUT, mout);
                    mcButton3.addEventListener(MouseEvent.MOUSE_OVER,mover);
                }
    
                if (e.currentTarget !== mcButton4) {
                    mcButton4.addEventListener(Event.ENTER_FRAME, playReverse);
                    mcButton4.addEventListener(MouseEvent.MOUSE_OUT, mout);
                    mcButton4.addEventListener(MouseEvent.MOUSE_OVER,mover);
                }
    
                if (e.currentTarget !== mcButton1) {
                    mcButton1.addEventListener(Event.ENTER_FRAME, playReverse);
                    mcButton1.addEventListener(MouseEvent.MOUSE_OUT, mout);
                    mcButton1.addEventListener(MouseEvent.MOUSE_OVER,mover);
                }
    
                if (e.currentTarget !== mcButton5) {
                    mcButton5.addEventListener(Event.ENTER_FRAME, playReverse);
                    mcButton5.addEventListener(MouseEvent.MOUSE_OUT, mout);
                    mcButton5.addEventListener(MouseEvent.MOUSE_OVER,mover);
                }
            }
    
            public function mover(e:MouseEvent):void {
                stopPlayReverse(e.currentTarget as MovieClip);
                e.currentTarget.play();
                var fadeIn:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 0, 1, 0.5, true);
            }
    
            public function mout(e:MouseEvent):void {
                var mc:MovieClip = e.currentTarget as MovieClip; 
                if (mc !== null) {
                    mc.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
                }
                if ( toolio == false ) {
                    var fadeOut:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 1, 0, 0.5, true);
                }
                if (settext != undefined) {
                    mcToolTip.toolTip.text = settext;
                }
            }
    
            public function playReverse(e:Event):void {
                var mc:MovieClip = e.currentTarget as MovieClip; 
    
                if (mc.currentFrame == 1) {
                    stopPlayReverse(mc);
                } else {
                    mc.prevFrame();
                }
            }
    
            public function stopPlayReverse(mc:MovieClip):void {
              if ((mc!==null) && mc.hasEventListener(Event.ENTER_FRAME)) {
                mc.removeEventListener(Event.ENTER_FRAME, playReverse);
              }
            }
    
            public function button1Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 1"; }
            public function button2Text(e:MouseEvent):void { mcToolTip.toolTip.text = "Menu 2"; }
            public function button3Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 3"; }
            public function button4Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 4"; }
            public function button5Text(e:MouseEvent):void {   mcToolTip.toolTip.text = "Menu 5"; }
    
            public function callButton1(evt:MouseEvent):void { ExternalInterface.call("button1", urlButton1);}
            public function callButton2(evt:MouseEvent):void { ExternalInterface.call("button2", urlButton2);}
            public function callButton3(evt:MouseEvent):void { ExternalInterface.call("button3", urlButton3); }
            public function callButton4(evt:MouseEvent):void { ExternalInterface.call("button4", urlButton4);}
            public function callButton5(evt:MouseEvent):void { ExternalInterface.call("button5", urlButton5);}      
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 429k
  • Answers 429k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The before method adds something. To get a relative use… May 15, 2026 at 1:33 pm
  • Editorial Team
    Editorial Team added an answer I indent the subsequent lines 2 levels: def method(self, alpha,… May 15, 2026 at 1:33 pm
  • Editorial Team
    Editorial Team added an answer Byron's former answer in code :) $excluded_parents = array(1, 4,… May 15, 2026 at 1:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.