Adding objects to the stage & acceessing stage properties - I'm a bit confused..

Hi,
I'm a little confused on two fronts regarding display
programming:
A. What the best way to add objects to the stage?
B. How to access stage properties.
I can do both of these when the project is an 'Action Script
Project', but I'm having trouble when it is a 'Flex Project' (e.g.
an MXML file). See the two attached files with questions included
in the comment to see exactly what I mean.
A. What the best way to add objects to the stage?
=====================================
In an action script project that extends Sprite I can just
call addChild()
In an MXML project I can add objects to the stage by first
adding them to a UIComponent, then adding that to the stage.
1. Is that the best way to do it?
In this doc:
http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html
it says that
quote:
Each SWF file has an associated ActionScript class, known as
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
2. why cant I just add a sprite object direct to the stage
without the UIComponent?
3. What is the 'main class', and how can i get access to it?
B. How to access stage properties.
=========================
In an action script project that extends Sprite I can just
call trace(stage.framerate)
But in an MXML file I cannot figure out how to access the
stage properties.
See the attached code for the things that I tried, but which
didnt work.
In the page:
http://www.actionscript.org/forums/showthread.php3?t=140655
It says
quote:
For stage access you have a couple of rules:
* natively, only display objects have inherent access to
stage
* display objects only have a valid reference to stage if
they're within the stage's display list (on the screen, after added
to it with addChild)
* The only display objects which immediately have access to
the stage before the use of addChild (in their constructor) are the
document/application class instance (root) and any instance from
the library placed on the timeline (not created with AS).
* Non-display object classes have to be passed or assigned a
reference to the stage from another object which already has access
to it - they cannot access it otherwise.
4. How do I access the stage properties in the MXML project?
5. I suspect this is related to the "main class", which I
dont yet understand - is it?
Sorry for the long post.
cheers
tom

"tom saffell" <[email protected]> wrote in
message
news:gd7cm9$d1v$[email protected]..
> Thanks Luigi - that helps a lot.
> I hadnt seen the Flex 3 Developer Guide before - it's
very useful.
>
> I now see that I can access properties of the
application object directly
> with
> this.<property>.
> However, the framerate property cannot be set by
actionscript, only in
> MXML (I
> can set it in the <mx:application> tag). But I
need to be able to set it
> programatically, dependent on user input.
>
> 5. Is there a way around this?
> 6. Can I set the stage's framerate to achieve the same
outcome?
>
> I still dont understand why I cannot access the stage
object. When I call
> either
this.stage or
uic.stage * then I get
quote:
Cannot access
> a
> property or method of a null object reference.
My understanding is
> that I
> can access the stage object via any display object on
the display list.
> I'm
> confused about this bit..
>
> * - uic is a UIComponent that has been added to the
display list (i think)
> by
> calling addChild(uic) from the AS3 within the
application
>
> 7. How do I access stage properties in AS3 in an MXML
project?
http://www.adobe.com/livedocs/flex/3/html/help.html?content=05_Display_Programming_10.html
It seems like possibly your real problem is that you're
having trouble
searching the Help effectively:
http://flexdiary.blogspot.com/2008/07/getting-help-in-flex-builder.html

Similar Messages

  • I created a vector and added objects, but the vector is empty

    I created an object called a facility, it accepts 2 strings in the creator but stores the data as a string and a float. as you can see from the code below, i have tried to create a vector object to contain facilitys and named it entries. when i add objects to this vector, the vectors size does not change, and i cannot access elements of it via their index. but when i print the vector out i can see the elements? what is going on here. i am very confused. ps, if it helps i havent worked with vectors much before.
    FacilitysTest.java
    import java.util.*;
    public class FacilitysTest {
         public static void main (String [] args) {
         Facilitys entries = new Facilitys();
         entries.add("Stage","3.56");
         entries.add("kitchen","5.00");
         entries.add("heating","2");
    //     System.out.println(entries.firstElement() );
         System.out.println("printing out entries");
         System.out.println(entries);
         System.out.println();
         System.out.println("There are "+entries.size()+" entries");
         System.out.println();
         System.out.println("modifying entry 2");
         entries.setElementAt(new Facility("lighting","1.34"), 2);
         System.out.println(entries);
         System.out.println();
         System.out.println("deleting entry 1");
         entries.remove(1);
         System.out.println(entries);
    }the following is what happens when i run this code.
    the number (0,1,2) is taken from a unique number assigned to the facility and is not anything to do with the facilitys position in the vector.
    printing out entries
    Facility number: 0, Name: Stage , Cost/Hour: 3.56
    Facility number: 1, Name: kitchen , Cost/Hour: 5.0
    Facility number: 2, Name: heating , Cost/Hour: 2.0
    There are 0 entries
    modifying entry 2
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 >= 0
    at java.util.Vector.setElementAt(Vector.java:489)
    at FacilitysTest.main(FacilitysTest.java:17)
    Press any key to continue . . .
    Facilitys.java
    import java.util.*;
    public class Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
        public void add( String name, String price ) {
             entries.add((new Facility( name, price) ));
        public Facility get(int index) {
              return ((Facility)entries.get(index));
         public float total() {
              float total = 0;
              for (int i = 0; i<entries.size();i++) {
                   total = total + ( (Facility)entries.get(i) ).getPricePerHour();
              return total;
        public String toString( ) {
            StringBuffer temp = new StringBuffer();
            for (int i = 0; i < entries.size(); ++i) {
                temp.append( entries.get(i).toString() + "\n" );
            return temp.toString();
    }

    are you reffering to where i have public class
    Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
    That's correct. That's your problem.
    i added the extends Vector, because without it i got
    the following errors
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:14: cannot find symbol
    symbol : method size()
    location: class Facilitys
    System.out.println("There are "+entries.size()+"
    " entries");That's because you haven't implemented a size method in your class.
    ^
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:17: cannot find symbol
    symbol : method setElementAt(Facility,int)
    location: class Facilitys
    entries.setElementAt(new
    w Facility("lighting","1.34"), 2);That's because you haven't implemented setElementAt in your class.
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:21: cannot find symbol
    symbol : method remove(int)
    location: class Facilitys
         entries.remove(1);
    ^That's because you haven't implemented remove in your class.
    /Kaj

  • Adding objects to the scenegraph

    Hi,
    I am tryin to add a simple sphere primitive to my program. If i call the method createASphere (see below)in the createScenegraph method, the sphere is added with no problems. However, when i comment out createASphere(), and try calling the method from my Java Swing GUI it causes an error:
    javax.media.j3d.CapabilityNotSetException: Group: no capability to append children
    I have tried using all of the possible capabilties for BranchGroup, but nothing seems to work. Does anyone have any ideas? thanks very much.
    This is just a small code extract
        public BranchGroup createSceneGraph(SimpleUniverse su)
             // Create the root of the branch graph
            BranchGroup objRoot = new BranchGroup();
            createASphere();   // this is the method which creates a simple sphere primitive,
                                              // however, i need it to work from my GUI, not from the createSceneGraph method!
            // Let Java 3D perform optimizations on this scene graph.
            objRoot.compile();
            return objRoot;

    you know something?...I HAD ALREADY GOT THAT, but it was on the wrong BranchGroup! DOH!! :-/
    thanks very much neways! ;-)
    -Ricky

  • DropTarget check against all objects on the stage

    Hey all,
    Not sure the best way to do this.  I have a class we will call DropActivity, here is the code
    package com.activitycontrol
              import com.activitycontrol.DropCheck;
              public class DropActivity
                   // Constants:
                   // Public Properties:
                   // Private Properties:
                   private var _selectedClip:Object;
                        // Initialization:
                        public function DropActivity(/*selectedClip:Object*/)
                        // Public Methods:
                        public function set selectedClip(selectedClip:Object):void
                                  _selectedClip = selectedClip;
                        public function stopDraggingMe():void
                                       var dropCheck:DropCheck = new DropCheck();
                                       //dropCheck.checkAgainst = dropTarget.name; ///***********
                                       if (dropCheck.canBeDropped == true)
                                            _selectedClip.stopDrag();     
                        // Protected Methods:
    when the stopDraggingMe() method is called from another object (code shown below) I need to see all the objects on the stage to see what objects on the stage my currently selected movie clip is over and assign it to the dropCheck.checkAgainst method (that will be checked against an array to see if it can in fact be dropped, if so set the canBeDropped value to true and therefor run the .stopDrag() ).  I have read using root is not a good coding practice in AS 3.
    call to the stopDraggingme() mehod.
    private function setDown(event:MouseEvent):void
                             var droppedItem:DropActivity = new DropActivity();
                             droppedItem.selectedClip = this;
                             droppedItem.stopDraggingMe();

    No, I think I can use drop target, I just need to use it from the DropActivity class and not a document class. I just don't know how to use it from a non-document class.
    "and you need to loop through all displayobjects to see which have a positive hitTest with your dropped object, correct?"
    I am trying to say..... ok, what movie clip is currently under the one I have selected,  the drop activity class knows what object I have selcted as it is in the selectedClip variable.  so I need to find out what clip is under it ......... the light just came on!
    answer duh......dropCheck.checkAgainst = _selectedClip.dropTarget.parent.name;
    thanks a bunch kglad you have helped me out once again, you are the man. I might just have to buy you a beer one of these days.

  • Positioning and temporarily hiding objects on the stage

    (Flash newbie here - bear with me...)
    I have two graphic objects on the stage overlapping each
    other. The first I was able to position to the document boundaries
    just fine. When adding the second object, however, the first object
    covers the boundaries so I cannot see them to align the second
    object.
    The question: Is it possible to temporarily hide an object on
    the stage so I can see the stage boundaries to position another? I
    don't see any options that will allow me to do this.
    Thx!

    there is a little colored square on each layer, to the right
    of the layer name, click that square on the layer that the first
    object resides, it will then just show an outline. click it again
    to bring it back. You can also click the first 'dot' next to the
    layer name, it will completely hide the contents of that
    layer.

  • Can't edit objects on the stage

    Hi,
    I'm stumped helping my colleague on the issue below so I'm logging this question.
    Issue: My colleague is trying to edit a slide but can't edit any of the objects on the stage. However, it works fine when I open the same project on my machine. Is there a setting on her machine that's causing the issue?
    In the screenshot below, check out Slide 2 (selected) notice how:
    in the thumbnail there are multiple objects (white image on the left, blue text caption in the center) on the slide.
    in the timeline multiple objects are available and selectable. All are set to be visible (the little "eye" isn't switched to off).
    when you look at the stage, the only things that we see are the background and a single button.
    The objects also appear fine in Preview.
    On the stage, can "phatomly" select objects, but she can't change the characteristics of them (e.g., change text in a text caption, resize object, move object).
    Screenshot:
    OS: Windows 7
    Captivate: v5.5 (running as Administrator)
    Background info:
    This project was initially created in an older Captivate version (4.0 or 5.0) and is now being edited/updated.
    Last week, my colleague was trying to edit the same project (using v5.0). When she clicked play on the timeline, her audio wouldn't play. When she watched the Preview or tried to edit the audio, the audio would play just fine. Also, on my machine (running v5.5) it worked fine. This prompted me to suggest that she update to v5.5. Alas, it seems this fixed the audio issue, only to create this video issue.
    Thanks,
    - Dino

    Here's a bigger/better quality image. I hope it helps.
    Notice how the Text Caption is selected in the timeline and it's properties are visible on the right. Yet the item itself is nowhere to be seen on the stage. Also, now it seems to have disappeared from the thumbnail.

  • Deleting objects from the stage

    Hi all,
    I've got some items on my stage that I'm removing with
    RemoveChild(). The items no longer show, however, as stated in
    LiveDocs, the item is not actually destroyed. This means any
    bindings/listeners created by that object are still in existence
    and are creating errors (Specifically, I'm getting "The supplied
    DisplayObject must be a child of the
    caller").
    LiveDocs mentions that if I want to actually delete an object
    from the stage entirely, I should use the "delete operator", but
    for the life of me, I can not find any documentation on the
    existence of such an operator. Any advice would be much
    appreciated.
    -Hob

    It IS ridiculously hard to find. Searcing Live Docs for
    delete oprator will turn up a slew of hits, but which is the right
    one?
    This is from old docs, but it is still valid:
    http://livedocs.adobe.com/flash/8/main/00001865.html
    Tracy

  • Duplicating the motion of an object across the stage

    Suppose I have a single moving object on the stage is it possible to replicate the object at regular intervals across the stage WITH the motion?

    Is this motion achieved through actionscript or is it a tween on the stage? If this is a tween on the main timeline on the stage, then you could make that animation a movieClip and play the movieClip at an interval, maybe using a timer. If the animation is achieved using actionscript then write the animation as a function and call the function at an interval, again, possibly using a timer.

  • Hide objects outside the stage

    Hi there!
    I have recently downloaded a sample FLA file and I see the stage is FIXED on top-left side of the flash screen and objects outside the stage does not appear on screen (Like a mask, but there is no mask layer).
    And when I create a new file the stage appears in middle of the screen and objects outside the stage are not masked.
    Would you please help me what should I do in this case?
    (I always use a very big White layer in top of all other layers, to cover out of stage, OR use a mask layer)
    Regards,
       Ali

    Hi!
    Sorry if my question was not clear. here is the link (adobe TV):
    http://downloads.tv.adobe.com/2012-00-24/WebChallenge_FL_3.zip
    I have uploaded that single FLA file to the address below :
    http://www.howallah.com/Mobile.fla
    To simplify my question, each flash scene is indeed divided into 3 sections based on colors (white, light grey, dark grey) as marked below :
    (the Zoom is 20% to cover them all).
    Section 1.  is called Stage (I know)
    Section 2.  it expands automatically as you move an object outside the stage (image, movieclip etc.) and it works like a mask (I dont know the name of this section)
    Section 3.   is something like "out of Scene" (I don't know the name of this section as well)
    What I want to do is sort of FITTING Section 1 (Stage) to Section 2.
    Exactly like the FLA sample file above.
    What is that good for?? to help me only see the stuff INSIDE the stage, without any need to make a mask layer or a LARGE white layer above all layers etc.!
    Anybody knows what I am talking about and having a clue please?
    Regards,
       Ali

  • Adding images to the stage

    Hello,
    I am currently working on a photo gallery which reads an XML file and load all picture from it. I am doing all by AS3 by adding bitmapdata to the container by loader object. What I want to do is when I add these images they behave like a button, by enabling hand cursor and pointing to a specific frame or an URL when I click on it. How should I proceed with the script to do so ? (Create a button or a movieclip which can be clicked and all this on a dynamic way)
    Thank you all guys !

    Hey kglad,
    Thank you...that helped !

  • What are the appropriate document/stage dimensions in Flash for tablet optimized apps?

    What are the appropriate document/stage dimensions in Flash (width x height in pixels) for tablet optimized apps?
    (Dec. 2013)
    Using Flash and AIR for Android/iOS I would like to develop a educational interactive title optimized for tablet PCs, hopefully both the Android but finally also the iOS platforms. With so many tablets on the market today and with different resolutions (and even aspect ratios) I have difficulty deciding what document/stage size to set for my project/app. I have been experimenting with an Android Google Nexus 7 and Samsung Note 10 tablets and discovered that Android automatically resizes the app's stage to fully fit the screen of the tablet BUT this creates the following two issues for me:
    if the stage/document size in Flash is too small and I include bitmaps when the app's stage is enlarged to fit the tablet screen the bitmaps look pixelated.
    If I make the stage dimensions too big so that there is no bitmap pixelation because the bitmaps will be shrank instead of enlarged, I am afraid that on some older tablets with slower processors the app may be too slow to run (but I have to say that I did not experiment with very large stage dimensions yet).
    Until today I had looked at some of the most commonly used tablets on the market and their resolutions Google Nexus 7, Samsung Note, iPads etc and was inclined towards using a stage size of approximately 1280 x 720 pixels which I considered a medium solution, but now the new generation tablets came out (Nexus 7 gen 2, iPad Mini with Retina, iPad AIR etc) with much higher resolutions so I don't know what size to use now. Anybody has any suggestions?
    I would appreciate any ideas and suggestions on this matter.

    You explained your problem well enough that looking at the picture won't matter.  It looks like you found out too late that one of the first things you should do when you create a Flash file is set the movie properties, which include the dimensions and other things like background color, frame rate, publish settings, etc.  While the string that I just listed can pretty much be revised anytime, the dimensions should really be done before anything else, when possible.
    One way to go about resizing is to leave the file as is and specify the larger dimensions in the html page code.  This could end up reducing the quality of any bitmaps you might have in the file(s) since you would essentially be enlarging them, but any Flash drawn elements will resize cleanly.
    If you resize the stage, then you don't have much choice but to resize and relocate everything in it keyframe by keyframe.

  • [OIM] GTC (DB App Tables) doen't refresh the OIM User Stages

    The scenario is as follows: I have one table as a trusted source. I mapped it to the OIM User using the stages screen (the OIM User plus some UDF Fields) and everything works fine.
    The problem arised when I need to add more UDF fields. The stages screen doens't show them, neither if I press the refresh button on the OIM User stage. The weird thing is that, for example if I make a Create User, all fields are shown and more weird, if I go directly to the provisioning process of the GTC connector, in the recon mapping these new fields appears and let me make the mappings. The strange thing is that I save this, and when I go to the GTC stages screen, the new UDF still doen's appear, neither the mappings I made in the design console.
    Have this happened to anyone? I don't want to mix GTC management touching directly the Design Console, I am trying to let it clean so I can make a clean export when it happen to put the connector in other environment.
    Thanks!

    Hi,
    I got the same problem... I added two UDF after I'had created the GTC and it didn't read them up, so I added the lines below in the xml schema in the database. After that, I could map the UDFs to the Reconciliation Staging fields.
    <Field default=" " keyfield="false" type="String " required="false" size="60 " encrypted="false" order="0 " name="USR_UDF_SAMPLE1" password="false">
    </Field>
    <Field default=" " keyfield="false" type="String " required="false" size="15 " encrypted="false" order="0 " name="USR_UDF_SAMPLE2" password="false">
    </Field>
    <Field default=" " keyfield="false" type="String " required="false" size="30 " encrypted="false" order="0 " name="USR_UDF_SAMPLE3" password="false">
    </Field>
    I think that would exist a button to refresh OIM User Schema used by the adapter, so the UDFs can be updated.
    tks.
    Renato.

  • Center the down-level stage

    How do you center the down-level stage, or add any css properties to it? I have the following code in composition ready but it does not center the down-level stage:
    sym.$("Down-level").css({"margin-left":"auto","margin-right":"auto","margin-top":"20px","b order":"1px solid black"});
    My regular composition is centered so I need the down-level stage to be centered as well. Thanks.

    Hi there, not sure how to center the down-level stage from within Edge, but have you tried centering the div that holds your Edge project, using regular CSS outside of Edge?

  • I have an iPhone 4 and my lock button is jammed and I also can not touch anything on the left side of my screen well as any pop ups from the phone itself, so i can not get past the set up stage in reset process...how can i fix it/can it be fixed?

    I have an iPhone 4 and my lock button is jammed and I also can not touch anything on the left side of my screen well as any pop ups from the phone itself, so i can not get past the set up stage in reset process...how can i fix it/can it be fixed?

    Make an appointment at the genius bar and get the phone replaced.

  • HT5927 im trying to update my iphone 4 and in order to complete the restore backup from itunes i need to turn off the find my iphone on the iphone but i cant get passed the restore backup stage - what should i do?

    I'm trying to update my iphone 4 and in order to compelte the restore backup from itunes i need to turn off the 'find my iphone' but i cant get passed the restore backup stage - what should i do?

    Hi beckiewinter!
    I have some information for you that may help you understand your iPhone's Activation Lock more thoroughly:
    iCloud: Find My iPhone Activation Lock in iOS 7
    http://support.apple.com/kb/HT5818
    So in order to update your iPhone, you may need to turn off Find My iPhone. This can be done through the iCloud settings, and more information on those settings can be found right here:
    iCloud - iPhone User Guide
    http://help.apple.com/iphone/7/#/iph3c79652c
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

Maybe you are looking for

  • Error while creating a process order

    Dear Guru's While creating a process order ,i am facing an error. "Unable to create batch. Storage location BPSS is invalid for material 112100050 Message no. 40116". How to assign specific storage loaction to that particular material.I have assigned

  • Stored procedure for creating tables

    Is it possible to create a stored procedure which only contains create tables? I prepare everything on an environment and want to transfer everything, except the data, on anothe environment. Therfore I thought of an stored procedure which does everyt

  • No of Decimal Places in Write Back

    Hi All, We are using ERPi/FDMEE writeback option to write data back to Oracle EBS12. Everything is working correctly, but while extracting data from Hyperion FDMEE is taking data in 7-8 decimal places. Is there any way to round this to 2 decimal plac

  • Budget Upload in kp06

    Dear Friends,                      We have differrent Currency in our company that is Company Code Currency in EUR and Controlling Area Currency is INR Please suggest can i upload in Company Code Currency EUR while upload plan budget in KP06 .... Reg

  • VDPAU only working as root (Nvidia)

    Just installed a fresh install of Arch on my thinkpad and was having some weird VDPAU issues. Flash crashes (firefox and chromium) mplayer (mpv) spits this out: Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such f