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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:04:07+00:00 2026-05-24T02:04:07+00:00

I am relatively new to ActionScript (have started with it 2 months ago), and

  • 0

I am relatively new to ActionScript (have started with it 2 months ago), and have a little doubt of ‘procedure’ or ‘technique’ related to passing information between objects.

I have made a class that Pops-up a window that contains a panel with a textbox and two buttons, one for accepting, other for cancelling. It should work as a prompt in which you enter some text, and then if you like the changes, you accept, else, you cancel and the text you entered is discarded.

The thing I’m not sure how to handle is how to receive the text, once the user presses ‘Accept’, from the class I want to receive it from.

So, the approach I took is a bit cumbersome: firstly, when launching the popup, I associate with it a function (called onResult() in the code) from the ‘class that launches’, which will be called after the user presses the ‘Accept’ or ‘Cancel’ buttons; secondly, to get the text that the user inserted in the box, I keep a reference to it public from my class.

Please have a look at the code here:
http://pastebin.com/Kmud8rBe

I’ve also programmed in Android before, and the approach there would be much cleanier, just putting the text result from the popup inside a bundle inside an intent, and receiving it from the launched class. Here, I have to pass functions and such, which I don’t like at all (although it works!).

So, my question is, for you ActionScript gurus out there, how would you approach this?

Thanks and regards!

pepillo

  • 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-24T02:04:08+00:00Added an answer on May 24, 2026 at 2:04 am

    good that you created a class for your popup-functionality but why did you make all functions static? normal class with normal methods would be better … and let the class extend from Sprite so that you can add the instance right to the stage.

    package
    {
        import flash.display.Sprite;
    
        public class Popup extends Sprite
        {
            public function Popup (label:String)
            {
               // add text and buttons ...
            }
        }
    }
    

    then you can just say:

    var pop:Popup = new Popup("message");
    addChild(pop);
    

    and to get the data back after the popup is closed you would do sth like this:

    private function onPressedAccept(event:MouseEvent):void
    {
        var text:String = _label.text;
    
        // dispatch a custom event which saves the text as its data
        dispatchEvent(new MyEvent(MyEvent.ACCEPT, text));
    
        // close popup ...
        parent.removeChild(this);
    
        // or you would remove the popup in the ACCEPT eventlistener ...
    }
    

    listening for accept/cancel:

    var pop:Popup = new Popup("message");
    addChild(pop);
    
    // add eventlistener
    popup.addEventListener(MyEvent.ACCEPT, onAccept);
    popup.addEventListener(MyEvent.CANCEL, onCancel);
    
    private function onAccept(event:MyEvent):void
    {
       trace(event.data);
    }
    

    link about creating custom events:
    http://www.8bitrocket.com/2007/7/31/Creating-Custom-Events-In-Flash-AS3-ActionScript-3/

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

Sidebar

Related Questions

I'm relatively new to Nant, what i'd like to do is have a task
Im an experienced actionscript developer, and relatively new to Objective C. I decided a
I am relatively new to ASP.NET programming, and web programming in general. We have
I'm relatively new to CSS, and have used it to change the style and
Relatively new to mySQL so this is probably an easy one: I have a
Being relatively new to the software industry I have come across a question of
I am relatively new to django. I have defined my db schema and validated
I am relatively new to web development and web applications. I have heard about
I'm relatively new to python, have done it a bit for my physics university
I am relatively new to Objective-C and now I have a problem in my

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.