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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:09:37+00:00 2026-06-07T16:09:37+00:00

I am an ActionScript 3 developer who is just making his first way in

  • 0

I am an ActionScript 3 developer who is just making his first way in building a large-scale JavaScript app.
So I understand modules and understand that AMD is a good pattern to use. I read about RequireJS and implemented it. However, what I still don’t understand is how to achieve Cross-Module communication. I understand that there should be some kind of mediator…
I read articles and posts and still couldn’t understand how to implement it simply.
Here is my code, simplified:

main.js

require(["Player", "AssetsManager"], function (player, manager) {
    player.loadXML();
});

Player.js

define(function () {
    function parseXml(xml)
    {
        // NOW HERE IS THE PROBLEM -- how do I call AssetsManager from here???

        AssetsManager.queueDownload($(xml).find("prop").text());
    }

    return {
        loadXML: function () {
            //FUNCTION TO LOAD THE XML HERE, WHEN LOADED CALL parseXml(xml)
        }

    }

});

AssetsManager.js

define(function () {
    var arrDownloadQueue = [];

    return {
        queueDownload: function(path) {
            arrDownloadQueue.push(path);
        }
    }
});

Any “for dummies” help will be appreciated 🙂
Thank you.

  • 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-06-07T16:09:41+00:00Added an answer on June 7, 2026 at 4:09 pm

    To load up modules from another modules that you define(), you would simply set the first parameter as an array, with your module names in it. So let’s say, in your code, you wanted to load Player.js into AssetsManager.js, you would simply include the string Player in the array.

    This is simply possible because define‘s abstract implementation is equivalent to require, only that the callback passed to define expects a value to be returned, and that it will add a “module” to a list of dependencies that you can load up.

    AssetsManager.js

    define(['Player'], function (player) {
        //... Your code.
    });
    

    However, if I can add to it, I personally prefer the use of require inside of the callback passed to define to grab the dependency that you want to load, instead of passing parameter to the callback.

    So here’s my suggestion:

    define(['Player'], function () {
        var player = require('Player');
    });
    

    And this is because it’s much more in tune with CommonJS.

    And this is how main.js would look like formatted to be more CommonJS-friendly:

    require(["Player", "AssetsManager"], function () {
        var player = require('Player');
        var manager = require('AssetsManager');
        player.loadXML();
    });
    

    But the CommonJS way of doing things is just a personal preference. My rationale for it is that the order in which you input the dependency names in the array might change at any time, and i wouldn’t want to have to step through both the array and the parameters list.

    Another rationale of mine (though, it’s just pedantic), is that I come from the world of Node.js, where modules are loaded via require().

    But it’s up to you.

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

Sidebar

Related Questions

I am a java/php developer helping someone with actionscript. I don't understand why this
I am a ASP.NET web developer who wants to learn Flex and Actionscript. I
I'm an actionscript developer getting into jquery/javascript development. I have a question regarding event
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
In ActionScript 3 is there a way ( a hack - maybe through square
Im an experienced actionscript developer, and relatively new to Objective C. I decided a
i am not an action script developer nor flash designer, i just want to
I am a web developer well-versed in XHTML/CSS, JavaScript, Perl, PHP, and XML/XSL. I
This question if a bit off topic, I just wanted feedback from most ActionScript/Flex
Is there a way within ActionScript 3.0 to: Get all URLRequests() that are made

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.