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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:14:10+00:00 2026-05-13T06:14:10+00:00

I have a class named TextLink. The text is meant to be clicked on

  • 0

I have a class named TextLink. The text is meant to be clicked on and it should dispatch an event (which I’m not too concerned about yet)… currently it just prints out a message.
The class takes an x, y, and a string to set the text. Dead simple…
But it crashes the browser.

Instance calls in main:

package {
    import flash.display.Sprite;

    import nav.text.TextLink;

    public class test_array_of_objects extends Sprite
    {
        public function test_array_of_objects()
        {
            var ary:Array = new Array(5);
            var i:uint;
            var ty:uint;
            var tx:uint = 30;

            for(i=0; i<ary.length; i++)
            {
                ty = i * 20 + 20;   
                var tmp:TextLink = new TextLink(tx, ty, "some text" + i.toString());
                ary.push(tmp);
            }           
        }
    }
}

Class:

package nav.text
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.external.ExternalInterface;

    public class TextLink extends Sprite
    {
        public var tf:TextField = new TextField();

        public function TextLink(tx:uint, ty:uint, tft:String)
        {   
            tf.text = tft;
            tf.x = tx;
            tf.y = ty;
            tf.autoSize = TextFieldAutoSize.LEFT;

            addChild(tf);
        }

        private function rollfunc(e:Event):void
        {
            ExternalInterface.call("console.log", "got a clicky");  
        }

        /*
        protected function rollfunc(e:Event):void
        {   //dispatch a custom event 
            dispatchEvent(new Event(Event.COMPLETE));   
        }
        */
    }
}

You’ll notice that I have commented out the rollfunc function because I was going to add it later-
What I would like to do here is to dispatch an event for whoever is listening to the class so that I can do something specific with the event of clicking on the text. The instance would be defined by an addEventListener() call.

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-13T06:14:11+00:00Added an answer on May 13, 2026 at 6:14 am
    for(i=0; i<ary.length; i++)
    {
        ...
        ary.push(tmp);
    }
    

    This is an infinite loop. ary.push() will increase ary.length on each iteration and i will never be able to catch up to it.

    I think you want @outis’s second suggestion here; i.e. ary[i] = tmp

    Or just create an empty array and push things into it.

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

Sidebar

Related Questions

I have a class named toto which I send to a function that does
I have a class named InvoiceLine which has the following properties. public class InvoiceLine
I have a class named Page with a private property currently called _pageData which
So assume I have one class named Program which contains my whole program of
I have created a class named ListCell which is a subclass of UITableViewCell .
I have a class named fdetails and I do not want any other class
I have a class named DataBoundObject which is quite big. And works good. Its
I have a class named Individual, which has a variable, self.fitness. I have a
I have a class named Initializer which checks for Internet connection, load open feint
I have class named Controller_Home . It should inherit from Controller_Permissions and Controller_Template .

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.