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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:42:01+00:00 2026-05-16T01:42:01+00:00

I have hit a road block on this and would highly appreciate if someone

  • 0

I have hit a road block on this and would highly appreciate if someone can help me on this, please. What I am trying to do is to use shared runtime library by loading a swf (‘index.swf’) which has numerous library objects which are named in sequence such as:

(orange1,orange2,orange3,orange4)
(red1,red2,red3,red4)

I am able to load the swf(‘index.swf’) without any issues and even am able to load the right library asset, but I have to declare the full name as string such as getDefinition(‘orange1’). What I would like to do is to match first three letters of string and then run a for loop to load up all the classes that match the first three letters. I usually can do this by employing indexOf() method.

here is my code:

public function loadContent():void
{

ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onloadHandler);
ldr.load(req);

}

public function progressHandler(eProgress:ProgressEvent):void
{
var percent:Number = (eProgress.bytesLoaded / eProgress.bytesTotal);
trace(percent);
}

public function onloadHandler(e:Event):void
{
// THIS IS WHERE I AM TRYING TO MATCH THE STRING
var str:String = "red";
str = (str.indexOf(str));
var ref1:Class = e.currentTarget.applicationDomain.getDefinition(str) as Class
trace(ref1);

}

I would highly appreciate your help.

Thanks.

  • 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-16T01:42:01+00:00Added an answer on May 16, 2026 at 1:42 am

    I think your problem lies in the following lines of code:

    str = (str.indexOf(str));
    var ref1:Class = e.currentTarget.applicationDomain.getDefinition(str) as Class 
    

    indexOf() returns the index of the first occurrence of the specified substring or -1 if the substring doesn’t exist. So , you are passing a string representation of some int (either -1 or 0, 1, 2, etc) to getDefinition()… which probably isn’t returning a class reference.

    Assuming you have some clips named red1, red2, red3, red4 I would do something like the following:

    for (var i:int=0; i < 4; i++) {
         var classRef:Class = e.currentTarget.applicationDomain.getDefinition("red" + (i+1).toString()) as Class;
         trace(classRef);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really hope someone can help on this because I'm learning cocoa and have
I've recently hit a road block trying to use the MvcSiteMapProvider . In my
I'm writing a simple shopping cart application and have hit a road block. Currently
I am starting out with OrchardCMS and have hit a road block (for me
I'm doing a poker game and have hit a wall. Any help would be
I've hit a road block while building this shell program which includes some javascript
I'm quite new to programming and have just hit a simple road block that
I am trying to learn how Python reloads modules, but have hit a roadblock.
I'm trying to do a cross domain POST request and have hit a wall
I have hit another roadblock and need some help: In windows, a filename like

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.