Simple Class and the Display List

I have very simple code for a class:
package
    import flash.text.TextField;
    import flash.display.Sprite;
    public class Greeter extends Sprite
        public function Greeter()
            var txtHello:TextField = new TextField();
            txtHello.text = "Hello World";
            trace("hi");
            addChild(txtHello);
The above file is saved as Greeter.as in say folder  C:\test
I then create a Fla file named test_display.fla (saved in C:\test) and its contents are:
import Greeter;
var tt:Greeter = new Greeter();
Now the Output window shows hi due to the trace statement but the addChild method should show
Hello World in the Flash movie but it does not. The only way to get Hello World to the Flash Movie
is to change the test_display.fla to:
import Greeter;
var tt:Greeter = new Greeter();
addChild(tt);
In other words I have to use the addChild method twice ( once in Greeter.as and once in test_display.fla )
to get Hello World to display in the Flash movie. Does anyone know why this is so?

Thanks Andrei1,
I honestly am having trouble with your answer. I am sure it is correct, I just don't get it right now.
As a slight twist on the original code say for example you want to get Hello World to output
inside the output window NOT the Flash movie. I see the code snippet  inside the class it reads:
var txtHello:TextField = new TextField();
txtHello.text = "Hello World";
So now inside the FLA file ( not inside the class file )  I have tried various ways to get Hello World to print in output window:
I have tried trace(tt.text);  and I get an error.
So the question is I know tt is an instance of Greeter and inside Greeter I see
where Hello World is assigned via:
txtHello.text = "Hello World";
So the question is why can't I get Hello World to print in the output window ( using trace) via
the instance tt somehow?

Similar Messages

  • Question about timeline navigation and the display list-

    I’ve got a movieclip called “rotatorProxy” that spans the entire timeline. I’ve got nav buttons that jump to various frames on that timeline. I need to get the display depth of rotatorProxy each time the nav buttons move the playhead. The AS3 code is easy enough:
    var zIndex:int = this.getChildIndex(getChildByName("rotatorProxy")) ;
    my problem is where to put it. If I put this code in any script that executes in the target frame, it works, but only if I hit the nav buttons slowly. If I bang on a single nav button rapidly, getChildByName("rotatorProxy”) can return null. I don’t know much about how the display list works but I assume the display list is rebuilt after every jump and the frame scripts are executing asynchronously, so it’s possible my getChildByName call is  executed before the display list is complete. Is there an event or some other handle that would allow me to call my code before the frame is rendered but after the display list is complete?

    Wow, thanks for the fast response...
    “if rotatorProxy exists in all frames, it should never return null.”
    That’s what I thought, but not what I’m seeing, rapidly jumping around on the timeline seems to confuse the player and it temporarily looses track of rotatorProxy.
    You can sort of see it in action here: http://www.appliedcd.com/newACT/act.html
    The zIndex is used to establish the depth of the rotating screens which have been added to the display list via AS. If you bang on the nav buttons quickly you’ll see the stacking order screw up, if you had been in the development environment you’d see the null error thrown.
    I’ll see if I can use the render event to sort this out. I know testing in the frame after the jump will work, but it’s cleaner if I can establish the proper stacking order before the first jump frame is rendered.

  • Using a devices camera and adding the image to the display list

    Hi,
    My students and I have not been able to make an AIR app that can take a picture using the devices camera and then add the image to the display list. We are able to open the devices camera and of course take a picture, but that's it.
    We've been using these two tutorials/examples:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/CameraUI.ht ml
    and
    http://tv.adobe.com/watch/adc-presents/input-for-mobile-devices-camera/
    I've uploaded our project: http://www.dayvid.com/professor/camera.zip
    Can someone help us out?
    Thanks!
    Below is the main document class:
    package  {
    import flash.desktop.NativeApplication;
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.ErrorEvent;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.MediaEvent;
    import flash.media.CameraUI;
    import flash.media.MediaPromise;
    import flash.media.MediaType;
    import flash.events.MouseEvent;
         public class Main extends MovieClip{
              private var deviceCameraApp:CameraUI = new CameraUI();
              private var imageLoader:Loader;
              public function Main()
                   this.stage.align = StageAlign.TOP_LEFT;
                   this.stage.scaleMode = StageScaleMode.NO_SCALE;
                                     camera_btn.addEventListener(MouseEvent.CLICK, cameraBtnClicked);
                          private function cameraBtnClicked(event:MouseEvent):void
                                    if( CameraUI.isSupported )
                                                      result_txt.text = "Initializing camera...";
                                                      deviceCameraApp.addEventListener( MediaEvent.COMPLETE, imageCaptured );
                                                      deviceCameraApp.addEventListener( Event.CANCEL, captureCanceled );
                                                      deviceCameraApp.addEventListener( ErrorEvent.ERROR, cameraError );
                                                      deviceCameraApp.launch( MediaType.IMAGE );
                   else
                                                      result_txt.text = "Camera interface is not supported.";
              private function imageCaptured( event:MediaEvent ):void
                   result_txt.text = "Media captured...";
                   var imagePromise:MediaPromise = event.data;
                   if( imagePromise.isAsync )
                    result_txt.text = "Asynchronous media promise.";
                    imageLoader = new Loader();
                    imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );
                    imageLoader.addEventListener( IOErrorEvent.IO_ERROR, cameraError );
                    imageLoader.loadFilePromise( imagePromise );
                   else
                    result_txt.text = "Synchronous media promise.";
                    imageLoader.loadFilePromise( imagePromise );
                    showMedia( imageLoader );
              private function captureCanceled( event:Event ):void
                   result_txt.text = "Media capture canceled.";
                   NativeApplication.nativeApplication.exit();
              private function asyncImageLoaded( event:Event ):void
                   result_txt.text = "Media loaded in memory.";
                   showMedia( imageLoader );   
              private function showMedia( loader:Loader ):void
                   this.addChild( loader );
              private function cameraError( error:ErrorEvent ):void
                   result_txt.text = "Error:" + error.text;
                   NativeApplication.nativeApplication.exit();

    Hi,
    Do I have to add the picture to the cameraroll in order to add it to the AIR apps display list?
    Both examples from Adobe claim that their examples work. Do they not?
    In the example, the event handler asyncImageLoaded is never called. The output text field shows -   result_txt.text = "Asynchronous media promise."; So the Event.COMPLETE is being added. But I don't think it's being dispatched.
    Any ideas?

  • 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

  • [svn:fx-trunk] 12542: When adding a mask to the display list need to validate it and all its children .

    Revision: 12542
    Revision: 12542
    Author:   [email protected]
    Date:     2009-12-04 10:38:32 -0800 (Fri, 04 Dec 2009)
    Log Message:
    When adding a mask to the display list need to validate it and all its children.  Previously the children were not validated and their display list was updated before properties were committed or measure was done.  RichText was not set up to handle this.
    QE notes:
    Doc notes:
    Bugs: SDK-24511
    Reviewer:  Evtim, Deepa
    Tests run: checkintests, fxg, primitives, Group
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24511
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/utils/MaskUtil.as

    AFAIK, the only way to do this is to write a system modifcation.
    The BADI is executed only once at startup of the session, so that makes it merely static. (A strange point in time, I discussed it with SAP and they just shook their heads)
    I had the same problem with some other F4-Helps and it was a big hazzle. From my experience, no straight answer.

  • [svn:fx-trunk] 11641: A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks , not just alpha masks.

    Revision: 11641
    Author:   [email protected]
    Date:     2009-11-10 18:29:57 -0800 (Tue, 10 Nov 2009)
    Log Message:
    A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks, not just alpha masks.
    QE notes: Please include tests for multiple graphic content nodes with masks under a .
    Doc notes: N/A
    Bugs:
    SDK-24133 - Multiple non-Group maskees don't work when using maskType="luminosity"
    Reviewer: Deepa
    Tests run: Checkintests, Bug test case
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24133
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java

    Revision: 11641
    Author:   [email protected]
    Date:     2009-11-10 18:29:57 -0800 (Tue, 10 Nov 2009)
    Log Message:
    A simple fix - we need to keep track of the display list index for non-clipping masks such as luminosity masks, not just alpha masks.
    QE notes: Please include tests for multiple graphic content nodes with masks under a .
    Doc notes: N/A
    Bugs:
    SDK-24133 - Multiple non-Group maskees don't work when using maskType="luminosity"
    Reviewer: Deepa
    Tests run: Checkintests, Bug test case
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24133
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java

  • Refresh the display list

    Hi experts,
      i am using one standard function module in my program.  i am calling this program using a submit and return statement in another program.In the standard funtion module one write statement is used.  My issue is once the function module is called and the program is returning to the main program. once it is returned the main program got stopped and going to the next screen and showing the list whatever which is written by using write statement. i think this is happening because of the return statement. but i want to suppress the display list.
    Thanks in advance.
    Arul

    Use addition EXPORTING LIST TO MEMORY of the SUBMIT statement.
    Like:
    SUBMIT report EXPORTING LIST TO MEMORY
                  AND RETURN.
    Regards,
    Naimesh Patel

  • Is the "Display list of web app items submitted by a user" feature not available in the free trial?

    Is the "Display list of web app items submitted by a user" feature not available in the free trial? I can see it in the tutorials but its not available when I am logged in.

    Its just named a little differently now. You should be able to add the module {module_webappscustomer} through the Modules toolbox in the web page editor window, as indicated below. Please note that webapps feature is available only for webCommerce sites. Read more about the available modules and its usage in detail here - http://kb.worldsecuresystems.com/134/bc_1345.html?bc-partner#main_Web_App_Modules
    Thanks,
    Vinayak

  • Replacing items in the display list

    I have a series of objects in a display, half of which have to be updated regularly. The items are originally added to the display list in pairs and are of 2 different types. My display list look like this:
    object1
    object2
    object1
    object2
    object1
    object2
    To update the display list, I delete half of the objects, so my list now looks like this:
    object1
    object1
    object1
    I now want to add the updated objects to the list, but doing so makes the list look like this so the objects no longer alternate:
    object1
    object1
    object1
    object2
    object2
    object2
    Is there a better way to think about deleting and adding objects to the display list so I can maintain my alternating list?
    Thank you!

    So, you mean to say that the objects will be displayed one after the other? just like a list? if so, go with list with itemrenderers, ArrayCollection + filters / sorting. All you do is maintain the data in a order, the list wil take care of displaying the itemrendderers .. this way it is more maintainable and scalable.

  • Help Removing events on a portion of the Display List

    Hey all
    Basically I'm looking for a "switch" that I can use to shut
    of all events for a Display Object and all of its descendants in
    the Flash display list / scene graph.
    I have a Display Object with a good number of descendants
    that have various MouseEvent listeners/handlers assigned to them.
    I'd like to be able to remove/disable all of these mouse-related
    events (or just all event types if thats easier) at a certain point
    in time without knowing the number of descendants or how many and
    which kind of event listeners have been registered with each node.
    So apart from writing a unique event removal method for each
    node, and then walking the Display List, calling this method for
    each node, how do I do this? Rasterizing this display object to a
    Bitmap object and then swapping the two in the display list to
    obtain a "static" version with no handlers is a work-around I don't
    really want to do either (sorry).
    any ideas?

    For the mouse events, perhaps a combination of
    DisplayObjectContainer.mouseChildren and
    InteractiveObject.mouseEnabled

  • Loading the Display List partially while runtime

    Happy Christmas!!
    How do I manage that, while the movie starts, some parts of the Display List are "hold in the backhand" and get loaded when I decide that they should.
    Can I only do that via external SWF-Files? Further question: Is it possible to stream the files, by calculating the download speed and starting the movie when I want it to do, or is Flash doing that automatically?
    Thank you very much.

    being a part of the display list me
    rely means they will not be redrawn if htey are not on the list and nor will their events be dispatched up through the display list.
    this does not mean if they are not onthe list they do not load.
    loading a movieClip is something that you must enforce and watch over.
    var ldr:Loader= new Loader()    
         ldr.addEventListner(Event.EVENT_COMPLETE,onComplete)
         ldr.load(new URLRequest('external.swf'))
    function onComplete(event:Event){
    //this fires when your swf has been loaded.  at this point you can add it to the display List
    addChild(event.target)
    event.target.removeEventListener(Event.EVENT_COMPLETE,onComplete)
    this wil add the loaderObject which holds the swf to the stage.
    if you have 10 external movies and want to load all 10 before adding any of them to the displayList you can do something like this
    var arrayOfMovieClipsToDisplay:Array=new Array()
    var counter:int=0
    var totalLoads:int=5
    var swfsToLoadAr:Array=['external1.swf','external2.swf',external3.swf',external4.swf',externa l5.swf']
    for(var i=0;i<totalLoads;i++){
    var ldr:Loader= new Loader()    
         ldr.addEventListner(Event.EVENT_COMPLETE,onComplete)
         ldr.load(new URLRequest(swfsToLoadAr[i]))
    function onComplete(event:Event){
    //this fires when your swf has been loaded.  at this point you can add it to the array
    arrayOfMovieClipsToDisplay.push(event.target)
    checkLoads()
    function checkLoads(){
    if(counter<totalLoads){
    counter++
    }else{
    for each(var ldr:Loader in arrayOfMovieClipsToDisplay){
    addChild(mc)

  • I am using a mini display to hdmi with my macbook and the display works fine. However, the sound will only play iTunes such as music and movies but when i go online to watch movies on youtube it will not play any sound. Please help

    I am using a mini display to hdmi with my macbook and the display works fine. However, the sound will only play iTunes such as music and movies but when i go online to watch movies on youtube it will not play any sound. Please help

    HDCP maybe? Read this http://www.macnn.com/articles/08/11/26/displayport.drm.conflict/

  • Pls its very urgent - i dropped by iphone 3G and the display became very dim soon after and it still remains the same - pls advise what should be done to bring the display back to normal

    Pls its very urgent - i dropped by iphone 3G and the display became very dim soon after and it still remains the same - pls advise what should be done to bring the display back to normal

    sounds like you broke the display when you dropped it.  There's nothing we users here can do for you.
    Since the iPhone warranty does not cover accidental damage, you will have to pay to have your phone repaired or replaced.  You can bring it into Apple for an out of warranty exchange in the country of purchase, or you can find a 3rd party iPhone repair store in your area.

  • My new ipod classic does not work anymore! The music stopped and the display is dead. What now, besides calling support?

    My new ipod classic does not work anymore! The music stopped and the display is dead. What now, besides calling support? Useless to say my PC didn't recognize the Ipod anymore either.

    Anton, I wish I could help. I had an old iPod Classic (60 KB) as a gift but it went dead, I dropped it a few times accidentally, and it sat carefully saved until I had sufficient resources, energy and time to get the matter addressed. In my case, I actually took the thing (after making sure it was charged) to an Apple store and one of the geniuses at the genius bar at the back of the store took it and did a few things (unseen and un-noted) with his fingers and handed it to me with a sly smile. Voila, the thing was functional. I got a re-functionalized iTunes account and store access when I bought my iMac. I did lose a few tunes along the way because it didn't recognize my new iMac as the source (my old dead PC laptop), but I have a more functional memory than the iPod and recovered them all in other ways. The whole thing is humming better than ever. At over 11 gb full, I have 4.2 days worth of portable listening. Be patient; it took me four years to get musical nirvana in a pocket, but you'll get there faster. Call support.

  • I lost my "Now playing screen" How do I get it back? All it shows is the album cover and the song list pages

    How can I get my "Now Playing" screen back? I can't scroll or change screens at all. All I have is the album picture and the song list page. I can toggle between the two but nothing else. It did this all by itself. Now it's stuck.

    what happens when you tap the screen?
    Next try:
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings                 
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                               
    iOS: Back up and restore your iOS device with iCloud or iTunes
    - Restore to factory settings/new iOS device.                       

Maybe you are looking for

  • Programs freezing after 10.5.3 - Force Quit doesn't work anymore.

    Pretty much the topic... After 10.5.3 lots of programs of different kinds are freezing more often. Force quit closes their windows but doesn't actually kill the app. What could I do? Cheers. JP

  • When creating Key figures

    Hi gurus, When creating Key Figures in Adminstration workbench in the tabs <b>AGGREGATION</b> and <b>ADDITIONAL PROPERTIES</b> can somebody kindly explain the below contents and how do they affect and where do they affect, if we select. <b>AGGREGATIO

  • Customer replication (ECC - CRM), masses of Bdocs in error

    Hello I recently got my hands on CRM 5.0 where replication of customers from ECC to CRM should be set up. There is no replication from CRM to anywhere else. Based on my very limited CRM experience, it seems that delta download is running ok. However

  • Every time i update it says there is none this as been going on for over a month

    i have been having problems with security on my macbook pro and my quadcore tower i feel as if someone as broken pass my security and is stealing my info on my laptop ive not had anykind of up date for over a month

  • Oracle APps Printing

    Hi we are getting the below errro while printing from Oracle Apps. Pl help us. ora-00376 file 493 cannot cannot be read at this time