question on the scope of the stage object

Hello, all.  I am currently working with containers and I have a question about the stage object.

I have 2 files in my program

(1) app.as

(2) stuff.as

Stuff.As is a library of common user interface that I build.  I'm trying, in this document, follow these steps:

stuff(){

makeUI();

}

makeUI(){

myContainer.setSize(stage.Stagewidth , stage.Stagehight);

}

Flash crash when running, saying that there is a reference not valid for a null object.

If main.as is the file of the application, how can I get the stage object to be valid / available inside my stuff.as file?

-Thanks for your time!

Hey dtater,

I met the same problem too in the past. the only way to have access to the stage is to have the class that never work added to the stage by a parent object that is already on scene. If an object has not yet been added to the stage, his stage value will be null.

the best way to work with this set of return must have an event listener defined in your file stuff.as to listen for Event.ADDED event in your stuff() constructor like this:

this.addEventListener(Event.ADDED, onAdded);

and then in your event handler function onAdded:

private function onAdded(e:Event):void{     // this event gets triggered by other objects, so we check to make sure it the right object     if (e.target == e.currentTarget)      {          makeUI();

     }

}

in this way the makeUI funciton only will be called when it has access to the scene.

Here are more details on the event Event.ADDED:

http://www.Adobe.com/LiveDocs/Flash/9.0/ActionScriptLangRefV3/Flash/events/event.HTML#added

hope that helps. Good luck!

Edit: I also forgot to add that the Event.ADDED event will be called when you addChild (stuff); in your main application.

Tags: BlackBerry Developers

Similar Questions

  • Inject the stage object when the controller initialization

    Hello

    I'm trying to inject my scenic object in my controller class. I found this solution on StackOverflow and it works. I also re-taken into account my controller class for does not implement does not obsolete Initializable interface.

    The last lines of my start() method are the following:

            Controller ctrl = fxmlLoader.getController();
            ctrl.injectStage(stage);
    
    
    

    I was wondering if I could put my Stage object directly in the initialize() method, because I can not access my scenic object in this method (it does not exist yet) and I can't do links operations.

    Best regards.

    FXMLLoader loader = new FXMLLoader ("whizzbang, fxml");

    loader.setController (new WhizzBangController (stage));

    = (Side) pane loader.load();

    Above is a guess (I have not tried).

    The stage must be set in the constructor of the controller and available when at initialization time when the fxml loader loads the fxml.

  • Question about the persistent object

    Hello

    When I used to store data using persistent object, data also will be deleted after uninstalling the app.

    Is there any data keep possibility even if the app is uninstalled?

    Can anyone give me a suggestion on this?

    Thank you.

    Objects are deleted when no request refers to them.

    So, if you have implemented a custom persistable object, whis would explain the removal.

    Use "Vanilla" persistable objects in the store, such as Hashtable.

  • question about the stages of compilation post patch adadmin

    From the readme file.
    Apply this pack mini...
    Oracle Financials Family Pack G contains a unified patch driver and can contain additional driver files
    be applied with AutoPatch. Please apply the driver file on all nodes of the application-tier server.
    u3653484.drv
    You must perform these steps after execution of build using Administration AD (adadmin) driver:

    1 generate files of messages. (* 1st choice 1.) Generate Applications files menu)?

    2 compile applications or patterns.
    -How to do this? y at - it an option only for applications or simply do all?

    3 compile flexfield given in the tables of AOL.
    (Please note that the Flexfields automatically compile data when using them for the first time, for the execution of this task is not necessary.)

    4 compile the menu information.

    I'm not 100% sure what options I am supposed to provide the 4 steps above. Looks like step 3 is optional based on another post.
    If someone could just give me the right choice? It comes to 11.5.10.

    Hello

    1 generate files of messages. (* 1st choice 1.) Generate Applications files menu)?

    Of adadmin:

    Generate Applications files menu
    Generate files of messages

    2 compile applications or patterns.
    -How to do this? y at - it an option only for applications or simply do all?

    Of adadmin:

    Menu to compile/Reload Applications database entities
    Compile the drawing APPS

    It compiles all invalid objects, so there is no option to select the schema.

    3 compile flexfield given in the tables of AOL.
    (Please note that the Flexfields automatically compile data when using them for the first time, for the execution of this task is not necessary.)

    Of adadmin:

    Menu to compile/Reload Applications database entities
    Compile flexfields

    4 compile the menu information.

    I'm not 100% sure what options I am supposed to provide the 4 steps above. Looks like step 3 is optional based on another post.
    If someone could just give me the right choice? It comes to 11.5.10.

    Of adadmin:

    Menu to compile/Reload Applications database entities
    Compile the menu information

    All the foregoing is documented and explained properly to the "maintenance of Oracle Applications Documentation Set".

    Maintain all Documentation Oracle Applications
    http://download.Oracle.com/docs/CD/B25516_18/current/HTML/docset.html

    Thank you
    Hussein

  • Adding objects to the stage & amp; Properties of the acceessing Stadium - I'm a bit confused...

    Hello

    I'm a bit confused about the programming of the display's two-pronged:

    A. What are the best way to add objects to the stage?
    B. how to access the properties of the step.

    I can make these two when the project is a 'Action Script Project', but I have a problem when it is a "Flex project" (for example a MXML file). See the attached files two questions included in the commentary to see exactly what I mean.


    A. What are the best way to add objects to the stage?
    =====================================

    In a project of action script which extends Sprite I can call him addChild()

    In a project MXML I add objects to the scene first, adding them to a UIComponent, then adding that the step.

    1 - is the best way to do it?

    In this doc: http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html he says this quote from
    :
    Each SWF file has an ActionScript class associated with it, called the main class of the SWF file. When Flash Player opens a SWF file in an HTML page, Flash Player calls the constructor function for that class and the instance that is created (which is always a type of display object) is added as a child of the Stage object. The main class of a SWF file always extends the Sprite class
  • The use of JavaScript in the Flash script and createJS, trouble, referencing the element on the stage

    Hello

    Relatively new to JavaScript, so don't know if it's too complicated to remove in the Flash timeline. I have a question on the stage with the name of the instance "myBox". I'm trying to take it to the coordinate x of a touch on the iPad. The JS looks like this

    / * js

    document.addEventListener ('touchmove', Function {}

    Event.preventDefault ();

    touch var = e.touches [0];

    this.myBox.x = touch.pageX;

    (}, false);

    */

    Is it possible to "myBox" from inside the function of reference? this.myBox does not work when I publish Toolbox for createJS. I am able to get the coordinate x of the key event when I try to alert (touch.pageX);

    Thanks for the help!

    you lose the scope of this function.  Try:

    / * js

    function moveBox (obj) {}

    obj.x = 600;

    }

    moveBox (this.myBox);

    */

    or, more generally, you can pass a reference to "this":

    / * js

    var tl = this;

    function moveBox (obj) {}

    obj.myBox.x = 600;

    }

    moveBox (tl);

    */

    p.s. Please check the useful/correct.

  • Question about the scope of the object and memory.

    I created a class that extends Sprite.

    In this class, I have a private type BitmapData var

    I then add the Sprite as a child to another Sprite on the stage.

    Later, I delete the second Sprite (parent) of the scene and I put the variable referring to it to null.

    After the garbage collection (assuming that it happen correctly) there is no trace of the BitmapData?

    No, unless you did something extra.  If you cannot reference your bitmapdata object (and has no listener), he is eligible for gc.

  • Question on the scope, theoretical

    Hello

    I have a question on the scope. It's something that I'm probably not on Java and OBJECT oriented programming.

    I am writing a program, that can handle several documents (images) of simple image processing. Now I have a DialogNewGUI with an actionPerformed method. In this method, I test for the appropriate action command and if NEW is the action command that I should create a new document (for example, a Document class). What worries me is that if I create an instance of a Document class in the scope of the actionPerformed method, we only see in this method, right? So, how do I access these Document instances newly created throughout the entire application? I think, I need a kind of global variable holding a reference to the Document instance, so I can work on it from anywhere in the code, but I don't think that there is such a thing in Java as global variables. I thought that, maybe, I need to create a class, called Basic, to contain the references in the world, but I don't know if I'm not running in the same issue there either.

    Someone has an idea? Thank you

    PR

    It is not clear what exactly you're trying to do. If you want to keep track of documents (images) which currently manages your image processing system, you will need to add in some kind of a collection - Let's say a card openDocuments, which in turn is handled by another class - let's call it imageProcessingSystem. You should then be able to add and to remove documents from the collection and to keep track of documents course of treatment.

  • Question on the scope and the framework / time line

    Hello!

    I write a little app and have the buttons and sliders on a field 1 of the scene and then a help screen on frame 2 of the scene.

    I have event listeners attached to the objects of the first image.  When I go to the second image and then return to the first image, all event listeners are passed away and no longer work.  (at least that is what I think is happening).

    My question is what is the best way to deal with this.  I think the best way would be to add something like adding Event listeners. ADDED_TO_STAGE for each object and have the listener function add event listeners I want for each item.

    So I will:

    public function Document()

    {

    Super ();

    iSlider.addEventListener (Event.ADDED_TO_STAGE, added);

    iSlider.removeEventListener (Event.REMOVED_FROM_STAGE, withdrawn);

    myButton.addEventListener (Event.ADDED_TO_STAGE, buttonAdded);

    myButton.addEventListener (Event.REMOVED_FROM_STAGE, buttonRemoved);

    }

    In each of the listeners, I would add / remove listeners that respond effectively to the key / slider.

    Is the best way to do it, or I missed something.  Sorry about the silent nature of this question, but I'm gay.  I hope someone less gay can help out me.

    -Thank you

    you are probably missing when you move to the structure 2.  It is a problem when using as3.

    an appeal is to remove your objects in the scene (using code - NOT the timeline) in box 2.  (re) you can add them to the stage in frame 1.

  • Positioning and temporarily hide objects on the stage

    (Flash beginner here - bear with me...)

    I have two graphic objects on the stage that overlap between them. The first, I managed to place limits of the document very well. When you add the second object, however, the first object covers the limits so I can't see to align the second object.

    The question: is it possible to temporarily hide an object on the stage so I can see the limits of the scene to the other position? I don't see any option that will allow me to do.

    THX!

    Good looking! Who did. Thank you!

  • Evaluation period for the stage of field custom object compare?

    I've never used an evaluation period during a stage of field of the custom object to compare on the canvas of the campaign and I want to confirm that she will be as I wait for him.

    We have a campaign that will send an email in nine batches, each a week after previous. I have a custom object with a field that contains the batch number (1-9) and I put nine steps to compare items customized on the canvas. The first checks to see if batch = 1, the second batch = 2, etc. I added a trial period of 7 days for the first eight steps. After I activated the campaign, I would expect all flow into the first stage of the decision and all those whose lot = 1 will immediately proceed to the stage of e-mail and the rest will wait seven days before moving on to the second decision, where everyone with batch = 2 will be moved to the stage left and e-mail everyone will wait for more than seven days, etc.

    I want to just make sure that this will be similar to, say, the Email step click on decision given that the data in the custom object will not change during the evaluation period, as it can to the other stages of decisions. And I don't want to accidentally send all nine lots at a time.

    Thank you.

    Hi Rob,

    This could work, as the Yes path would fire instantly and without the path would check during the evaluation period. Is there a reason to not only use a delay of a week between each stage of the decision well? A little more crowded, but perhaps more clearly during the audit of the canvas to the wire without having to enter each stage?

    See you soon,.

    Phil

  • Best practical Question - update the query (see object) based on the drop-down list selection

    I have a question about the most efficient way to perform the following task:

    I create a page that contains several DVT components to display data based on specific requests.  Top of page I am hoping to have a drop down menu (selectOneChoice) that contains dates different and based on what the user selects (i.e. 2010, 2011, 2012, 2013, etc.), this will update the query in the view object of some (i.s. WHERE Date = '2011', or WHERE Date = 2013"), and then you view the appropriate data in the DVT.  What is the best way to do this - from a point of view bean managed / page, as well as the View object?  Advice/documentation would be appreciated.

    Thank you!

    When you drag the vo executeWithParams one another that will create links for operations such as 'executeWithParams2', 'executeWithParams3 '. On the method that you use to update a view by calling the executeWithParams operation, you call the other operations too.

    Timo

  • Flash CC: access a specific object on the stage

    I'm writing the javaScript code to execute with Flash CC.

    How can I access a specific object on the stage? It has a name (square_sym), but I can not read the code. What should I do?

    TIA

    He needs an instance name.

    If there is not a button or a movieclip, right click on the object > click on convert to symbol > select movieclip > ok > in the properties panel, enter an instance name, for example square_mc.

    then on the timeline that contains the button or movieclip you can use:

    This.square_mc to reference the movieclip.  other chronologies, there are also pointers to reference the movieclip

  • Drag & Drop question (the target object lock)

    Hello

    I worked with an interactive game and I've set up my objects (drag) in a single layer with their target of the object in another. Export Flash 8 AS2 settings (requirement for the site is downloaded to).

    My objects have suddenly to their original position, if they don't land on their target, and I have this job. What I can't get to work is for the object to fit in the box, that I created.

    The object and target have been converted to the clips and the taget received an instance name (targetone) I have used this instance name in the script action that is set on the object. Both target and object have centered their anchor points for X, Y of the purposes.

    Here are my actionscript:

    (press)

    {

    startDrag (this);

    }

    (release)

    {

    stopDrag();

    If (this ._droptarget == "/ targetone")

    {

    This._x=_/targetone._x;

    This._y=_/targetone._y;

    }

    else {}

    This ._x = 319,95;

    This ._y = 138.75;

    }

    }

    He won't just snap into the box. The object is converted into paths (large print) text and the box is also important. I tried to increase it because I thought he might have problems with locking in but nothing works

    Any help would be greatly appreciated!

    Stu

    Thanks for the reply, Ned.

    After a few hours of different script code tests, including your suggestions, I tried to draw an object directly on the stage and it worked.

    I use the boxes which are .ai files and they were imported to the library with layers and effects intact (as separate components). I discovered that the boxes that I designed in Illustrator are too complicated to assign a code to-I guess it's because it has layers.

    I've got around it by drawing a simple box in Flash, by positioning on versions of illustrator and in making it invisible. Problem solved!

    Detective Conan

  • How to make a row of 5 objects in the center of the stage

    Im trying to add 5 objects in the scene and the entire line of 5 items to be centered on the stage. The objects will be with the same position of Y and a gap of 10px between them.

    the object have a Center, enrollment Center poin

    Follow it so far, I have this, but it makes the 1st element go in the Center and the rest

    for(var k:uint=0;k<5;k++){
                                            var gap = 10
                                    var box:Box= new Box()
                                    addChild(box);
                                    box.x=stage.stageWidth/2 +  ( k*(gap+box.width));
    }
    
    
    

    the simplest without prior knowledge of widths of the objects is to reposition after initial positioning.  that could require a loop in all objects again, but it is easier to simply add objects to a parent and focus the parent:


    var p:Sprite = new Sprite();

    var distance = 10;

    for (var k: uint = 0; k<>

    box: box var = new Box();

    p.addChild (box);

    Box.x = k *(gap+box.width);

    }

    p.x =(stage.stageWidth-p.Width) /2+box.width/2;

Maybe you are looking for