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

  • Home
  • SEARCH
  • 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 128527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:38:59+00:00 2026-05-11T05:38:59+00:00

I have this AS2 code that does some simple animations when I rollover a

  • 0

I have this AS2 code that does some simple animations when I rollover a mc using TweenLite.

I feel that I have a lot of repeating code.

Is there a way to be able to just specify a function like this

boxLink(a);

and have the rest of the code, with the path to the target movieclip in the function instead of in the function variable?

How can I make this code as short as possible?

Is it possible to convert a variable:String to a variable:MovieClip? How would i do that in this example?

 import gs.*;  import gs.easing.*;   function imageAlpha(mc_target:MovieClip) {     mc_target.onRollOver = function() {             TweenLite.to(mc_target,1,{_alpha:100, ease:Back.easeOut});     };      mc_target.onRollOut = function() {             TweenLite.to(mc_target,1,{_alpha:60, ease:Back.easeOut});     };  }      function boxLink(mc_function:MovieClip, mc_target:MovieClip, mc_image:MovieClip, linkURL:String) {     mc_function.onRollOver = function() {             TweenLite.to(mc_target,0.5,{_xscale:150, _yscale:150, ease:Back.easeOut});             TweenLite.to(mc_image,1,{_alpha:100, ease:Back.easeOut});     };      mc_function.onRollOut = function() {             TweenLite.to(mc_target,0.5,{_xscale:100, _yscale:100, ease:Back.easeOut});             TweenLite.to(mc_image,1,{_alpha:60, ease:Back.easeOut});     };      mc_function.onRelease = function() {             if (linkURL) {             getURL(linkURL);             }     };  }     imageAlpha(a_box.image);  imageAlpha(b_box.image);  imageAlpha(c_box.image);  imageAlpha(d_box.image);   boxLink(a_box.link1,a_box.arrow1,a_box.image,'http://www.google.no');  boxLink(a_box.link2,a_box.arrow2,a_box.image,'http://www.google.no');  boxLink(a_box.link3,a_box.arrow3,a_box.image,'http://www.google.no');   boxLink(b_box.link1,b_box.arrow1,b_box.image,'http://www.google.no');  boxLink(b_box.link2,b_box.arrow2,b_box.image,'http://www.google.no');  boxLink(b_box.link3,b_box.arrow3,b_box.image,'http://www.google.no');   boxLink(c_box.link1,c_box.arrow1,c_box.image,'http://www.google.no');  boxLink(c_box.link2,c_box.arrow2,c_box.image,'http://www.google.no');  boxLink(c_box.link3,c_box.arrow3,c_box.image);   boxLink(d_box.link1,d_box.arrow1,d_box.image,'http://www.google.no');  boxLink(d_box.link2,d_box.arrow2,d_box.image,'http://www.google.no');  boxLink(d_box.link3,d_box.arrow3,d_box.image); 
  • 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. 2026-05-11T05:38:59+00:00Added an answer on May 11, 2026 at 5:38 am

    Use arrays instead of named variables

    a_box.link_1, a_box.link_2, ..., a_box.link_3  

    becomes

    a_box.link[ i ] where i = 0 to n-1, n = number of links 

    Similarly for arrows.

    Next, create a wrapper for boxLink()

    public function  boxLinkWrapper(x:BoxType, url:string='http://www.google.no') :ReturnType {     for (i:int = 0; i < x.link.size; ++i) {         boxLink(x.link[ i ], x.arrow[ i ], x.image, url);     } } 

    Also, since you have a number of such boxes, put them in an array:

    var boxes:Array = new Array(); boxes.push(new Box('a')); //a_box boxes.push(new Box('b')); //b_box 

    and wrap up the steps you’d need for each box:

    public function  processBox(x:BoxType):SomeReturnType {     imageAlpha(d_box.image);     boxLink(a_box.link1,a_box.arrow1,a_box.image,'http://www.google.no'); } 

    and run a for-loop over the array boxes, or use the forEach() member function:

    boxes.forEach(processBox); 

    Don’t forget to replace BoxType, SomeReturnType and ReturnType by the appropriate types. Does that help? (Note: this is untested code, but should get you started!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is pretty weird, but I copied & pasted your… May 11, 2026 at 8:17 pm
  • Editorial Team
    Editorial Team added an answer file_get_contents will do what you want $output = file_get_contents('http://www.example.com/'); echo… May 11, 2026 at 8:17 pm
  • Editorial Team
    Editorial Team added an answer The Windows equivalent of Ctrl+D is Ctrl+Z Enter. May 11, 2026 at 8:17 pm

Related Questions

I have a large codebase that targetted Flash 7, with a lot of AS2
I build and maintain a set of Flash components that is distributed to publishers
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
I have a bash shell script that loops through all child directories (but not

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.