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 7565377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:08:21+00:00 2026-05-30T14:08:21+00:00

I have a method that takes a few paramerters and dynamicly adds three images

  • 0

I have a method that takes a few paramerters and dynamicly adds three images to the stage it also adds a background image to the three images.

I am trying to figure out the following: How can I tween in the background movieclip and on complete tween in the three dynamic movieClips? Can I have a function within a function that shares the same variables?

Something like the following:

public function addImages(BackGround:String,Image1:String,Image2:String,Image3:String):void
        {


           var symbol_class:Class = getDefinitionByName(BackGround);
           var image1_class:Class = getDefinitionByName(Image1);
           var image2_class:Class = getDefinitionByName(Image2);
           var image3_class:Class = getDefinitionByName(Image3);

                  var main_bg = new symbol_class();
                  var image_1 = new image1_class();
                  var image_2 = new image2_class();
                  var image_3 = new image3_class();

          main_box.addChild(main_bg);

                  var BGTween:Tween = new Tween(my_thumb, "alpha", Strong.easeIn, 0,1,0.5, true);
                  BGTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);

                   //WHEN BACKGROUND TWEEN IS COMPLETE NOW ADD THE OTHER IMAGES AND FADE THEM IN.
                  function onFinish(e:TweenEvent):void {
                    BGTween.removeEventListener(TweenEvent.MOTION_FINISH, onFinish);

               main_box.addChild(image_1);
                     var image_1_tween:Tween = new Tween(image_1, "alpha", Strong.easeIn, 0,1,0.5, true);

                main_box.addChild(image_2);
                   var image_2_tween:Tween = new Tween(image_2, "alpha", Strong.easeIn, 0,1,0.5, true);

                main_box.addChild(image_3);
                    var image_3_tween:Tween = new Tween(image_3, "alpha", Strong.easeIn, 0,1,0.5, true);

                    }

        }
  • 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-30T14:08:23+00:00Added an answer on May 30, 2026 at 2:08 pm

    You’re close there, you can’t define a function within a function quite like that, but you can do the following:

           public function addImages(BackGround:String,Image1:String,Image2:String,Image3:String):void
           {
    
    
                  var symbol_class:Class = getDefinitionByName(BackGround);
                  var image1_class:Class = getDefinitionByName(Image1);
                  var image2_class:Class = getDefinitionByName(Image2);
                  var image3_class:Class = getDefinitionByName(Image3);
    
                  var main_bg = new symbol_class();
                  var image_1 = new image1_class();
                  var image_2 = new image2_class();
                  var image_3 = new image3_class();
    
                  main_box.addChild(main_bg);
    
                  var BGTween:Tween = new Tween(my_thumb, "alpha", Strong.easeIn, 0,1,0.5, true);
                  BGTween.addEventListener(TweenEvent.MOTION_FINISH, function(e:TweenEvent) {
                        //WHEN BACKGROUND TWEEN IS COMPLETE NOW ADD THE OTHER IMAGES AND FADE THEM IN.
                        (e.target as EventDispatcher).removeEventListener(e.type, arguments.callee);
    
                        main_box.addChild(image_1);
                         var image_1_tween:Tween = new Tween(image_1, "alpha", Strong.easeIn, 0,1,0.5, true);
    
                        main_box.addChild(image_2);
                       var image_2_tween:Tween = new Tween(image_2, "alpha", Strong.easeIn, 0,1,0.5, true);
    
                        main_box.addChild(image_3);
                        var image_3_tween:Tween = new Tween(image_3, "alpha", Strong.easeIn, 0,1,0.5, true);
                  });
          }
    

    This is called a closure because it’s an anonymous function that references values outside its immediate scope. You can read more about them on Wikipedia. Also note how the removeEventListener has changed, this is the way to remove an anonymous function because no name reference exists for it.

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

Sidebar

Related Questions

I am trying to have a method that takes in a username and will
I have code in my Page_load method that can take up to a few
I have a method that takes a list of entities ( Class es) and
I have a method that takes an array of queries, and I need to
So I have a method that takes a tag and wraps the selected text
Say I want to have a method that takes any kind of number, is
All, I have a method that takes a date (YYYY-MM-DD H:M:S) from the database
I'm wondering how to go about testing this. I have a method that takes
I have a search method that takes in a user-entered string, splits it at
I have a static method that takes a parameter and returns a class. the

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.