Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 3 of 3

Thread: Control TextField

  1. #1

    Control TextField

    Good day;

    I have been hammering at this for some time now, and it is getting a little frustrating.

    1. I have a document class that adds a TextField.

    2. The Doc class then adds another custom class (MovieClip).

    3. Inside that custom class (MovieClip) is a button with an addEventListener that needs to update the TextField on the main stage (or root).

    I have tried so many possible solutions that I am not going to list them here, I am sure I must be doing something fundamentally wrong...

  2. #2
    if you post your code that would be clearer, one of the methods to call the function from a helper class is sending the function name as a parameter to the helper class
    say you have a class constructor function

    public function MenuClass(str:String='menu.xml', __btnMoveSpeed:Number = 3 , __func:Function = null )

    __func paramater sends the function to the externall class so you could simply call it from the class

    hope this helps
    My Current Projects, a language school.
    İngilizce Kursu Istanbul

    hummer limo London

  3. #3

    Code

    //DOCUMENT CLASS//

    package
    {
    import flash.text.TextField;
    import flash.display.MovieClip;

    public class DocClass extends MovieClip
    {
    public var TF:TextField = new TextField();
    public var Holder:MovieClip = new MovieClip();
    public var CM:CustomMC = new CustomMC();

    function docClass():void
    {
    addChild(TF);
    TF.text = "cup"

    addChild(Holder); //Blank MC used for resizing//

    Holder.addChild(CustomMC);
    }
    }


    //CUSTOM MC//

    package
    {
    import flash.text.TextField;
    import flash.display.MovieClip;

    public class CustomMC extends MovieClip;
    {

    public var Page:MovieClip = new MovieClip();
    public var Cancel:TextField = new TextField();

    function CustomMC():void
    {
    addChild(Page);
    Page.addChild(Cancel);

    Cancel.addEventListener(MouseEvent.CLICK, CloseWindow);
    function CloseWindow():void
    {
    root.TF.text = "coffee"; //Option One - No Joy//
    stage.TF.text = "coffee"; //Option Two - No Joy//
    trace(Cancel.parent.parent.parent); // No Joy //
    MovieClip(root).TF.text = "coffee"; // No Joy //
    }
    }

    }
    }


    This is the basic structure, that hopefully clears up the question. I am not sure if I am missing something simple, or if you just can access an absolute path of the entire movie.

    I pulled this off the top off my head, so if there are small obvious issues, please ignore them, as they are likely a typo, and please focus on the structure and the means of communication between the custom class and the root (absolute path).

    Thanks in advance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012