Can't add to display list from a class

in my Main.as file, this works as expected:
var t:TextField = new TextField();
t.text = "hello in main";
addChild(t);
However, when I create an instance of a class, and I have
that same code in the constructor of that class, the text doesn't
show up. I am creating the text field variable at the class level,
not the contstructor level, so I think the variable should still
hang around.
Do I have to get an instance of the stage, or something?
thanks

I don't know anything about your application but there are at
least two ways to add an instance from within other class:
1. stage.addChild(t)
2. Instantiate the class that creates text field --> add
this instance to the display list of where you instantiated it
(given that you class that creates the text field is a display ob
ject too).
Sorry, I cannot be more specific unless I know more about
your architecture and logic.

Similar Messages

  • Problem adding to the display list from a class

    If I try to convert as3 in an mxml file into a class file and
    create an instance of the class, I am unable to add the instance to
    the display list. The original mxml file is at the bottom of the
    page. The modified mxml file and its associated class are below.
    The problem is that I cannot use addChild(myComponent); So how to I
    add the UIComponent to the Display list?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import LoadSwf
    private var myLoader:LoadSwf
    public function init():void{
    myLoader=new LoadSwf()
    ]]>
    </mx:Script>
    </mx:Application>
    Class:
    package{
    import flash.display.MovieClip;
    import com.adobe.viewsource.ViewSource;
    import flash.events.Event
    import mx.core.UIComponent
    import flash.display.Loader
    import flash.events.TimerEvent;
    import flash.events.StatusEvent
    import flash.net.LocalConnection
    import flash.net.URLRequest
    import flash.net.URLVariables
    import flash.utils.Timer;
    public class LoadSwf{
    private var request:URLRequest
    private var loader:Loader = new Loader();
    private var conn:LocalConnection = new LocalConnection();
    private var myComponent:UIComponent=new UIComponent();
    private var swfTimer:Timer;
    private var myParameters:URLVariables ;
    public function LoadSwf(){
    request= new URLRequest("Login.swf");
    myParameters= new URLVariables()
    myParameters.loginID = "101";
    myComponent.addChild(loader);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    finishedLoading);
    loader.load(request);
    private function finishedLoading(e:Event):void{
    //PROBLEM IN THE FOLLOWING LINE!!!!!!!
    addChild(myComponent);
    swfTimer = new Timer(10);
    swfTimer.addEventListener(TimerEvent.TIMER,sendData);
    swfTimer.start();
    private function sendData(e:Event):void{
    conn.addEventListener(StatusEvent.STATUS, onStatus);
    conn.send("myConnection", "lcHandler",
    myParameters.loginID);
    private function onStatus(event:StatusEvent):void {
    if (event.level=="status") {
    trace("LocalConnection connected");
    swfTimer.stop();
    }else if (event.level=="error"){
    trace("FAILED to connect")
    }

    "SiHoop" <[email protected]> wrote in
    message
    news:[email protected]...
    > If I try to convert as3 in an mxml file into a class
    file and create an
    > instance of the class, I am unable to add the instance
    to the display
    > list. The
    > original mxml file is at the bottom of the page. The
    modified mxml file
    > and its
    > associated class are below. The problem is that I cannot
    use
    > addChild(myComponent); So how to I add the UIComponent
    to the Display
    > list?
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > layout="absolute"
    > creationComplete="init()">
    > <mx:Script>
    > <![CDATA[
    > import LoadSwf
    > private var myLoader:LoadSwf
    > public function init():void{
    > myLoader=new LoadSwf()
    > }
    > ]]>
    > </mx:Script>
    > </mx:Application>
    > Class:
    > package{
    > import flash.display.MovieClip;
    > import com.adobe.viewsource.ViewSource;
    > import flash.events.Event
    > import mx.core.UIComponent
    > import flash.display.Loader
    > import flash.events.TimerEvent;
    > import flash.events.StatusEvent
    > import flash.net.LocalConnection
    > import flash.net.URLRequest
    > import flash.net.URLVariables
    > import flash.utils.Timer;
    > public class LoadSwf{
    > private var request:URLRequest
    > private var loader:Loader = new Loader();
    > private var conn:LocalConnection = new
    LocalConnection();
    > private var myComponent:UIComponent=new UIComponent();
    > private var swfTimer:Timer;
    > private var myParameters:URLVariables ;
    > public function LoadSwf(){
    > request= new URLRequest("Login.swf");
    > myParameters= new URLVariables()
    > myParameters.loginID = "101";
    > myComponent.addChild(loader);
    >
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    > finishedLoading);
    > loader.load(request);
    > }
    > private function finishedLoading(e:Event):void{
    > //PROBLEM IN THE FOLLOWING LINE!!!!!!!
    > addChild(myComponent);
    You didn't add this component to the Application, so I
    wouldn't expect to
    see anything you add in this component in the Application.
    HTH;
    Amy

  • HT1694 how can i add the contact list from my msn account

    I need help entering my contact list

    The instructions are in the article that you were reading when you posted your question that ultimately led you to here. Take a look at the kb article again.
    http://support.apple.com/kb/HT1694?viewlocale=en_US&locale=en_US
    After you set up the account, you have to select the items that you want to sync so go to Settings>Mail, contacts, calendars and tap the MSN email account. In the next screen you should be able to select Mail, Contacts, Calendars and Reminders and you can choose how many days back to sync email.

  • Noobie question: How do I add something to the display list from a non-main class?

    I know how to use addChild() within the main class to add
    something to the stage display list and have it appear on the
    screen, but how do I add something to the stage display list from
    code within another class?
    So for example say I want to add some text (myTextField) to
    the stage's display list from within NotTheMainClass' code, could
    you give an example of the necessary code?

    you must pass a reference to a display list object or create
    one that's available to your class.
    there are so many ways to do this i'm not sure how you want
    to proceed. but you can create a globally available reference to
    the stage and root timeline:

  • Can you have two detail lists from the basic list at the same time?

    Hi
    Can you have two detail lists from the basic list at the same time?
    If yes how and if no why?
    Thanks
    Venkat

    No   ... it is not   possible   of   2 detail  list at   one time   from the basic  list ...
    you can  increament   the SY-LSIND  .... But you can not   display  both the windows   at single time  ...
    it is  possible  to  display  2 Detail list  in ALV   ......  from one  basic  list   using  the  Blocked  list  concept    .
    Sample Program on BLOCK LISTS
    Report   zblock_list
    * Declarations for BLOCK ALV DISPLAY
    *--type pools
    TYPE-POOLS:slis.
    DATA:x_layout TYPE slis_layout_alv,
    t_field TYPE slis_t_fieldcat_alv,
    *--field catalog
    x_fldcat LIKE LINE OF t_field,
    *--to hold all the events
    t_events TYPE slis_t_event,
    x_events TYPE slis_alv_event,
    t_sort TYPE slis_t_sortinfo_alv,
    x_sort LIKE LINE OF t_sort ,
    *--Print Layout
    x_print_layout TYPE slis_print_alv.
    *----Macro to add field catalog.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    DEFINE add_catalog.
    clear x_fldcat.
    x_fldcat-fieldname = &1.
    x_fldcat-seltext_m = &2.
    x_fldcat-outputlen = &3.
    x_fldcat-tech = &4.
    x_fldcat-col_pos = &5.
    x_fldcat-no_zero = 'X'.
    x_fldcat-ddictxt = 'M'.
    x_fldcat-datatype = &6.
    x_fldcat-ddic_outputlen = &7.
    if &6 = 'N'.
    x_fldcat-lzero = 'X'.
    endif.
    *--build field catalog
    append x_fldcat to t_field.
    END-OF-DEFINITION.
    *----- data declerations.
    data: v_repid like sy-repid.
    data: begin of itab occurs 0,
    matnr like mara-matnr,
    ernam like mara-ernam,
    meins like mara-meins,
    end of itab.
    data: begin of jtab occurs 0,
    matnr like makt-matnr,
    maktx like makt-maktx,
    end of jtab.
    select matnr ernam meins
    up to 20 rows
    from mara
    into table itab.
    select matnr maktx
    up to 20 rows
    from makt
    into table jtab.
    v_repid = sy-repid.
    *DISPLAY alv
    * Initialize Block
    call function 'REUSE_ALV_BLOCK_LIST_INIT'
    exporting
    i_callback_program = v_repid.
    *Block 1:
    *INITIALIZE
    refresh t_field. clear t_field.
    refresh t_events.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    add_catalog:
    'MATNR' 'Material' '18' '' '1' 'C' '18',
    'ERNAM' 'Created By' '12' '' '2' 'C' '12',
    'MEINS' 'Unit' '5' '' '3' 'C' '3'.
    *--build table for events.
    x_events-form = 'TOP_OF_LIST1'.
    x_events-name = slis_ev_top_of_list.
    append x_events to t_events.
    call function 'REUSE_ALV_BLOCK_LIST_APPEND'
    exporting
    is_layout = x_layout
    it_fieldcat = t_field
    i_tabname = 'ITAB'
    it_events = t_events
    it_sort = t_sort
    tables
    t_outtab = itab
    exceptions
    program_error = 1
    maximum_of_appends_reached = 2
    others = 3.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *--BLOCK 2(SUMMARY REPORT)
    *INITIALIZE
    refresh t_field. clear t_field.
    refresh t_events.
    *field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
    add_catalog:
    'MATNR' 'Material' '20' '' '1' 'C' '18',
    'MAKTX' 'Description' '40' '' '2' 'C' '40'.
    *--build table for events.
    x_events-form = 'TOP_OF_LIST2'.
    x_events-name = slis_ev_top_of_list.
    append x_events to t_events.
    * Append table block.
    call function 'REUSE_ALV_BLOCK_LIST_APPEND'
    exporting
    is_layout = x_layout
    it_fieldcat = t_field
    i_tabname = 'JTAB'
    it_events = t_events
    tables
    t_outtab = jtab
    exceptions
    program_error = 1
    maximum_of_appends_reached = 2
    others = 3.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    *--CALL FM TO DISPLAY THE BLOCK REPORT.
    call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    * exporting
    * is_print = x_print_layout
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    form top_of_list1.
    skip 1.
    write: 10 'List 1',
    /5 '--------------------'.
    skip 1.
    format reset.
    endform.
    form top_of_list2.
    skip 1.
    write: 10 'List 2',
    /5 '--------------------'.
    skip 1.
    format reset.
    endform.
    reward  points if it is  usefull ....
    Girish

  • I can not add the smart lists to ipod

    I can not add the smart lists to ipod, itunes If (when clicking the lists are empty) but notas add to the ipod touch are not added automatically.

    Experiencing exactly the same error. The error only occurs on the clustered gateway. Non-clustered gateways work fine. I followed Kristian's whitepaper exactly except that I didn't use a service template to create the gateway cluster. All NICs are connected
    to the proper switches. There are no relevant events/errors on the hosts or the gateway cluster nodes.
    Troubleshooting steps taken so far...
    1. reboot everything
    2. deleted the network service from VMM and re-added
    3. Verified that HNV is working on the host cluster by disabling "host dedicated to gateway" and moving an NVGRE VM to the cluster.
    4. Verified all other networks are working properly on the host cluster.
    5. Deleted and re-added all NICs in the gateway cluster.
    6. Verified that the gateway can be configured using Powershell on the host and remote.
    Now I'm going to create another clustered gateway and another non-clustered gateway to reproduce the problem.
    Any other suggestions would be greatly appreciated.

  • How can I sync my contact list from laptop to iphone?

    How can I sync my contact list from laptop to iphone?  My contact list is in Microsoft Outlook.  I want to go from laptop to iphone and not vice versa.

    I use iCloud to sync calendar and contacts using Outlook 2010 on my Win 8.1 Update 1 laptop, Outlook 2010 on a Win 7 desktop, an iPhone 5S, an iPhone 4 and an iPad 4. For example if I make a change/add/delete a contact on my iPhone 5S the change is reflected over on the other devices basically instantaneously...
    https://www.apple.com/icloud/
    You need to setup iCloud on an iOS device first...

  • How can I add multiple email addresses  from spreadsheet into email?

    how can I add multiple email addresses  from spreadsheet into email?

    I have tried that, but the system reads the emails as one long email and I can't find any way of separating them - it ignores spaces, colons and I have also tried putting them through a word doc... still does not work. It works perfectly easily on a PC system!! ( I have just moved to a mac!)
    any ideas would be good
    thanks

  • Can't add music my iPhone from iTunes.  When I try to drag a song over to my phone, I get the circle w/ the syncing line through it, but it does not update/load.  [Manually manage music and videos] is checked. And, this is the only Mac I have ever used to

    Can't add music my iPhone from iTunes.
    When I try to drag a song over to my phone, I get the circle w/ the syncing line through it, but it does not update/load.
    [Manually manage music and videos] is checked. And, this is the only Mac I have ever used to add music to my phone.
    Also, just updated the phone's software today, and iTunes' software is already up to date.

    Hi Gregg,
    Have you tried resetting the device (nothing will be lost): Hold down the Home and Power buttons at the same time and continue to hold them down until the Apple appears (up to 30 seconds). Once the Home screen redisplays, see if your Music app is behaving normally.
    Cheers,
    GB

  • HT4759 How can I add or delete iphones from my icloud account?

    How can I add or delete iphones from my icloud account?

    Hi Inspiration69,
    I apologize, I'm a bit unclear on your question. If you are asking how to set up your iCloud account on your iPhone, you may find the following page helpful:
    Apple - iCloud - Setup
    https://www.apple.com/icloud/setup/ios.html
    Regards,
    - Brenden

  • How can I import my contact list from my pc to my ipad

    How can I import my contacts list from my pc to mu ipad?

    Have you received any replies?

  • How can I import My contact list from gmail to Icloud??

    How can I import My contact list from gmail to Icloud??

    If you have a mac or pc
    I would try to export the contact from gmail
    Import the contact to mac or pc
    And then sycronise your device with it.

  • How can i import my contact list from the Nokia Suite to my I phone?

    how can i import my contact list from the Nokia Suite to my I phone?

    Oscar, keep in mind that my suggestion could not be the best one.
    I have a copy of Nokia suite on my Windows XP partition on my Mac, just to test it.
    The second icon on the upper row explains as a syncronisation with Outlook.
    Try to do it and later you should use the iClod manager from Apple and Sync Outlook to ìiClod and to any iPhone iPod and so on.

  • How can I get my contact list from my I phone 5 to my I pad?

    how can I get my contact list from my I phone 5 to my I pad air?

    One way is via iCloud. Settings > iClouds > Contacts on for both.

  • Can i add to my balance from a credit card

    can you add to your balance from a credit card that is your own?

    Store credit doesn't work that way. To increase store credit you redeem a gift card or certificate.

Maybe you are looking for

  • How to get specific file based on last modified

    Hi, I have a problem. what I am doing in my program is unzipping few files in c:\temp. the folder structure is like this c:\temp\patch\abc.doc c:\temp\patch\abc.txt c:\temp\patch\myfolder\xyz.doc c:\temp\patch\myfolder\myFile\xyz.txt what I mean to s

  • BW Estimation Model

    HI Gurus,            I am currently trying to build a BW Estimation model . I would be greateful if you'll could suggest me as to the different objects types and the complexity factors for each objects.  I have labeled some tasks related to Info Obje

  • Phone is deleting texts immediately, no text or call log on my phone

    My phone just started errasing text messages and calls all of a sudden. I didn't change any settings, and i've gone through all of them, and nothing seems to be different. But I can't even read texts because it erases them so quickly, and there is no

  • Integration with FaceBook....Help me

    plz  tell me how can i integrate with facebook...... very difficult for me...

  • E61 Problem with Outgoing Mail Server "Unable to s...

    Hi all, I have the following Problem.I have bought from the same ISP two different domain's and mail accounts.One with .com and the other with .info extension. If I try to send and receive e-mail's with my ".com" account it works fine,no problem occu