Display list and classes

I have a class called shapeC that only creates a rectangle and then addChild(rectangle);.  That class is instantiated on the main timeline.  Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild(shapeC);.  My question is, is there a way that the shapeC class can add the rectangle to the root stage without requireing the instantiated class to be added to the stage?
Thanks

Yes, you can add directly to another stage, but my question would be "why"?  There are times you want to delegate the logic of controlling what's on stage to another class and can be a responsibility of something commonly refered to as a "controller".  There are times when you want a class to simply create something and return it, known as a "factory".  What you're talking about is both of those things lumped into one.  Unless you really have a reason to have a factory during its creation add it to stage, I'd suggest you do it exactly as you're doing now.  Not to mention the only reference stored of your rectangle will be in your ShapeC class and/or on your main display list.  That can be dangerous and cause all kinds of headaches.  But if you really want to do it, you'd have to pass in a DisplayObjectContainer (i.e. Sprite or MovieClip) as an argument to the constructor (or other method depending on the code path of your class) of the shapeC class.  Once it has created the rectangle add it to the passed in object's display list (passedInObject.addChild(rectangle));  So the code would look something like this.
//From main timeline
var shape:ShapeC = new ShapeC(this);
//ShapeC constructor
public function ShapeC(targetDisplayObject:DisplayObjectContainer)
     var rectangle:Sprite = new Sprite();
     rectangle.graphics.beginFill(0xFF0000);
     rectangle.graphics.drawRect(0, 0, 100, 100);
     targetDisplayObject.addChild(rectangle);
If I were to do something like this, I'd just make ShapeC a static factory class and do something like this:
//From main timeline
ShapeC.createRect(this);
//in ShapeC class
public function createRect(targetDisplayObject:DisplayObjectContainer)
     blah blah blah same as above...
You might also want to pass in screen positions and what not as well.  Hope it helps.

Similar Messages

  • Simple Web Application - To display list and then details

    Hello All,
    I am trying to build simple classifieds web application using - JSP, MySQL.
    I am little confused how to achieve following using JSP - for example -
    Craigslist can display list of classifieds and when clicked on individual classified - the record is shown as Static HTML file -
    http://newyork.craigslist.org/mnh/cpg/708366015.html
    http://newyork.craigslist.org/mnh/cpg/708343755.html
    How can i achieve the same results dynamically - i mean, how can i create a static HTML page using information in database and put that static HTML file on server so it can be picked up by search engines ...
    I am new to java guys .. so please show me some light or explain me how do i code this using JSP.
    Thank you,
    Jagdish

    How can i achieve the same results dynamically - i mean, how can i create a static HTML page using information in database
    and put that static HTML file on server so it can be picked up by search engines ...By definition a dynamic html page doesn't exist, so how would a search engine find something that doesn't exist?

  • How to display List and Image on Single Screen?

    Hi Friends,
    I wanna display Image and List on single screen.
    Its not possible using Form which will contain both. either I can list or form which contain image as far I know.
    I have seen one J2ME application which contain Image and below that there is list. Can anybody tell me how?
    Thanks,
    Rohan Chandane

    Hi,
    Are you able to put a list and image into a form.
    If so plz let me know the method to do tht.
    thanks.

  • Error list and class hierarchy unexpected refresh

    I'm running LabVIEW 2013 Service Pack 1
    There is an irritating issue that I am sure I have never come across before, in that the Error list, class hierarchy window, VI hierarchy window, and I am sure other UI elements are refreshing themselves every few seconds.
    For example:
    Open the class/VI hierarchy window and browse around. In a couple of seconds the pane will refresh its position to hte top left corner.
    Ensure that the error window has enough errors and warnings (show warnings is reccommended!) that it shows a scrollbar. Scroll down and sellect/highlight an item (this happens naturally if you ctrl-L from a VI). Scroll up/down the list and in a couple of seconds the list focus will move back to the highlighted item.
    This is really, REALLY irritating me with refactoring a large project. Has anyone else seen this, and is it fixable?
    - Cheers, Ed

    That's some pretty strange behaviour, just tried to test it on a machine with 2013 SP1 and another with just 2013; but this behaviour wasn't observed?
    Aside from the standard steps like restarting LabVIEW, or turning your machine on/off; you could try do a repair operation on LabVIEW to correct this?
    Hopefully someoneone else can pitch in who has experienced similar behaviour recently...

  • MY LIST OF 'DEVICES' ON 'FINDER' HAS 'TURNED OFF' ( does not display list and does not show as bright)  AND I CAN'T SEE MY LIST OF DEVICES (TO EJECT A DISK, OR ADD A FILE TO A DISK) ETC)??

    my list of 'devices' on 'FINDER' has 'turned off.  gone to not (bright ) does not display backup disks or I- pad etc.  I can't see my list to eject a disk or copy a file to I-Pad etc???
    Also how would I un-zip a file I have downloaded to "download" and then copy it to a disk??

    Hold down OPTION COMMAND and click S
    Regards,
    Captfred

  • 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:

  • How do I interact between stage and classes?

    Hi,
    I have asked this question before, and all I got is "Go back
    to reading beginner books", so I'm hoping that someone here is
    willing to actually answer my question as opposed to brushing me
    off because they were unwilling to help...
    And yes, I have read books on the topic and gone through tons
    of the documentation and not found the answer to this. I have
    ActionScript 1 and JavaScript experience, so this whole business
    shouldn't be this hard.
    I am using ActionScript 3 in Flash CS3.
    My problem is this:
    I need to find out how to send commands between stuff on the
    stage and stuff that's defined in a class.
    I have had this issue for ages and kept trying to find ways
    around it since so far I haven't been able to find help for it.
    For example:
    When using a document class, how can I access the current
    frame number of the Stage?
    Or using a document class, how can I access any object (like
    a MovieClip with instance name) that was put on the stage using the
    IDE?
    Currently, to be more specific, I am trying to do something
    really simple:
    Make a button work on my stage that is not always visible.
    With AS3 that's not as easy anymore as it used to be.
    So what I did now is create the button in the document class,
    used addChild and set it to alpha = 0.
    Now, when the Stage reaches specific frames (i.e. ones with
    labels, and I got this part figured out), it is supposed to make
    the button visible. Then I can add event listeners and stuff, and I
    can figure that part out myself.
    I don't know how to access the stage frame number from the
    document class, so I put it into a frame script in frame 1, but now
    this script cannot access the button that is defined in the
    document class.
    It's driving me bananas...
    PLEASE, someone here, can someone please explain to me how I
    can make this work?
    I have seen plenty of diagrams of the Display List and the
    Object Hierarchy, but none of that explains how to actually USE any
    of it...
    Thanks so much in advance to anyone who is willing to spend
    some time to answer!

    Well, first of all, I have to say that AS3 has basically been
    designed to be difficult on purpose, in that all this interaction
    between objects is purposefully very strict. For this reason, I
    still use AS2 for all my basic Flash work. AS3 is just a lot more
    involved, a lot more strict, a lot less forgiving... you need a lot
    of experience with it before it starts to make sense.
    Now, I think I might have a few specific answers to your
    questions:
    From any DisplayObject (this includes any Document class,
    which has to extend MovieClip or in some cases Sprite) you can
    access the Stage using the 'stage' property.
    However, stage is probably not exactly what you want, you
    want the main timeline, which is the child of stage. To access the
    main timeline, you can use the 'root' property of any
    DisplayObject.
    However, unless you have strict mode off, Flash won't let you
    just say "root.myMovieClip" because the root property is of the
    type DisplayObject, which is not a dynamic class (meaning you can't
    add properties to it) and it has no built in property "myMovieClip"
    so it thinks you made a mistake. So you have to "cast" the root
    property as a MovieClip, which *is* dynamic so it will let you try
    to reference anything on it (like AS1/2 did for everything.)
    So what all that means is this should work from inside you
    document class:
    (root as MovieClip).myMovieClip
    or
    MovieClip(root).myMovieClip
    Either will successfully reference a MovieClip you had put on
    the main stage in the IDE and named "myMovieClip".
    Rather than setting the alpha to 0, try setting visible to
    false. I think this will disable all interactive events, where
    simply setting alpha to 0 would make it still be interactive.
    HTH

  • Problems with display-lists (Urgent)

    I would like to load 3d polygonal Objects into seperate display lists and deliver them to OGL, which works fine.
    But if I want to clean up my screen with the intention to load some new objects, I have the big problem deleting my old display lists.
    Maybe the problem is caused by other reasons. But finally my Canvas displays everytime the old 3d Object. Here are some essential snippets of my code:
    public class CanvasOGL extends JPanel implements GLEventListener {
    public final static int GL_POLYGON_MODE_LINE = 1;
    public final static int GL_POLYGON_MODE_FILL = 2;
    public final static int GL_POLYGON_MODE_POINT = 3;
    private int iGLPolygonMode = 2;
    private final GLCapabilities caps = new GLCapabilities();
    private final GLJPanel drawable = GLDrawableFactory.getFactory().createGLJPanel(caps);
    private GL gl;
    private GLU glu;
    private float fDistance = -3f;
    private float view_rotx = 0f;
    private float view_roty = 0f;
    private float view_rotz = 0f;
    private int prevMouseX;
    private int prevMouseY;
    private Color bgColor = new Color(255, 255, 255, 0);
    private Color fcolor = new Color(222, 222, 222, 0);
    private String imagePath = "";
    private PgGeometry[] pgGeometries;
    private int lists;
    public CanvasOGL() {
    caps.setAlphaBits(8);
    drawable.setOpaque(false);
    drawable.addGLEventListener(this);
    drawable.addMouseListener(this);
    drawable.addMouseMotionListener(this);
    drawable.addMouseWheelListener(this);
    setLayout(new BorderLayout());
    add(drawable, BorderLayout.CENTER);
    public void setPgGeometries(PgGeometry pgGeometries[]) {
    // delete old lists
    if (gl!=null)
    gl.glDeleteLists(lists,this.pgGeometries.length);
    // create new lists
    this.pgGeometries = pgGeometries;
    createLists();
    drawable.display();
    public void setPgGeometry(PgGeometry pgGeometry) {
    // delete old lists
    if (gl!=null)
    gl.glDeleteLists(lists,pgGeometries.length);
    // create new lists
    pgGeometries = new PgGeometry[1];
    pgGeometries[0] = pgGeometry;
    createLists();
    drawable.display();
    /* GLEventListener Methods */
    public void init(GLDrawable glDrawable) {
    System.out.println("call: init");
    gl = glDrawable.getGL();
    glu = glDrawable.getGLU();
    gl.glClearColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, bgColor.getAlpha() / 255f); //This Will Clear The Background Color To Black
    gl.glClearDepth(1.0);
    gl.glEnable(GL.GL_DEPTH_TEST);
    gl.glDepthFunc(GL.GL_LEQUAL);
    gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
    /* Init Light1 */
    float[] LightAmbient = {0.8f, 0.8f, 0.8f, 1.0f};
    float[] LightDiffuse = {1.0f, 1.0f, 1.0f, 1.0f};
    float[] LightPosition = {2.0f, 0.0f, 2.0f, 1.0f};
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, LightAmbient); // Setup The Ambient Light
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, LightPosition);
    gl.glEnable(GL.GL_LIGHT1);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glEnable(GL.GL_CULL_FACE);
    gl.glBindTexture(GL.GL_TEXTURE_2D, 1);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glEnable(GL.GL_TEXTURE_2D);
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
    createLists();
    public void display(GLDrawable glDrawable) {
    System.out.println("call: display");
    switch (iGLPolygonMode) {
    case GL_POLYGON_MODE_LINE:
    gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
    break;
    case GL_POLYGON_MODE_FILL:
    gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
    break;
    case GL_POLYGON_MODE_POINT:
    gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_POINT);
    gl.glClearColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, bgColor.getAlpha() / 255f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    if (!imagePath.equals("")) {
    RenderedImage image = JAI.create("fileload", imagePath);
    BufferedImage img = ImageUtils.toBufferedImage(image);
    makeRGBTexture(img, GL.GL_TEXTURE_2D, false);
    gl.glLoadIdentity();
    // Position des Auges des Betrachters
    gl.glTranslatef(0, 0, fDistance);
    gl.glPushMatrix();
    gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
    gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
    gl.glColor4f(fcolor.getRed() / 255f, fcolor.getGreen() / 255f, fcolor.getBlue() / 255f, fcolor.getAlpha() / 255f);
    for(int i=lists; i<= pgGeometries.length; i++)
    gl.glCallList(i);
    private void createLists() {
    if (gl == null)
    return;
    System.out.println("call: create");
    int num = pgGeometries.length;
    lists = gl.glGenLists(num);
    for (int i = 0; i < num; i++) {
    PgElementSet pgElementSet = (PgElementSet) pgGeometries;
    PdVector[] bounds = pgElementSet.getBounds();
    PdVector pdVectorDiagonal = PdVector.subNew(bounds[1], bounds[0]);
    double dx = pdVectorDiagonal.getEntry(0);
    double dy = pdVectorDiagonal.getEntry(1);
    double dz = pdVectorDiagonal.getEntry(2);
    double temp;
    if (dx < dy)
    temp = dy;
    else
    temp = dx;
    if (temp < dz)
    temp = dz;
    double dScale = 1 / temp;
    double dMaxx,dMaxy,dMaxz,dMinx,dMiny,dMinz;
    dMaxx = pgElementSet.getVertex(0).getEntry(0);
    dMaxy = pgElementSet.getVertex(0).getEntry(1);
    dMaxz = pgElementSet.getVertex(0).getEntry(2);
    dMinx = pgElementSet.getVertex(0).getEntry(0);
    dMiny = pgElementSet.getVertex(0).getEntry(1);
    dMinz = pgElementSet.getVertex(0).getEntry(2);
    int numV = pgElementSet.getNumVertices();
    for (int j = 1; j < numV; j++) {
    if (dMaxx < pgElementSet.getVertex(i).getEntry(0))
    dMaxx = pgElementSet.getVertex(i).getEntry(0);
    if (dMaxy < pgElementSet.getVertex(i).getEntry(1))
    dMaxy = pgElementSet.getVertex(i).getEntry(1);
    if (dMaxz < pgElementSet.getVertex(i).getEntry(2))
    dMaxz = pgElementSet.getVertex(i).getEntry(2);
    if (dMinx > pgElementSet.getVertex(i).getEntry(0))
    dMinx = pgElementSet.getVertex(i).getEntry(0);
    if (dMiny > pgElementSet.getVertex(i).getEntry(1))
    dMiny = pgElementSet.getVertex(i).getEntry(1);
    if (dMinz > pgElementSet.getVertex(i).getEntry(2))
    dMinz = pgElementSet.getVertex(i).getEntry(2);
    double x;
    double y;
    double z;
    PdVector pdVector;
    gl.glNewList(lists+i, GL.GL_COMPILE);
    for (int j = 0; j < pgElementSet.getNumElements(); j++) {
    gl.glBegin(GL.GL_POLYGON);
    PiVector piVector = pgElementSet.getElement(j);
    for (int k = 0; k < piVector.getSize(); k++) {
    int index = piVector.getEntry(k);
    pdVector = pgElementSet.getVertex(index);
    x = dScale * (pdVector.getEntry(0) - (dMaxx + dMinx) / 2);
    y = dScale * (pdVector.getEntry(1) - (dMaxy + dMiny) / 2);
    z = dScale * (pdVector.getEntry(2) - (dMaxz + dMinz) / 2);
    gl.glTexCoord2d(0.5 + x, 0.5 + y);
    gl.glVertex3d(x, y, z);
    gl.glEnd();
    gl.glEndList();
    I would be pleased about every kind of help. Thanks a lot!
    Kindly regards,
    Eldar

    Use Windows Device Manager to set it back to F:
    These directions are for an ipod but will work for an exHD, too:
    http://support.apple.com/kb/TS1493
    Change the drive letter while itunes is closed. When you reopen itunes all the file paths should be OK.

  • Display Lists in JoGL

    I haven't had a problem getting a single Display List to work. However, when I try to create multiple Display Lists and display them using gl.glCallLists, I only get the first Display List created. Not too surprising: I'm not at all sure what I should be doing with the Buffer. Here's some code:
              listID = gl.glGenLists(2);
              gl.glNewList(listID+0, GL.GL_COMPILE);
              gl.glNewList(listID+1, GL.GL_COMPILE);
              IntBuffer buff = BufferUtil.newIntBuffer(2);
              gl.glListBase(listID);
              gl.glCallLists(2, GL.GL_INT, buff);
    Any help is GREATLY appreciated! :o)

    Maybe you should ask your question again at http://www.javagaming.org/forums/index.php?board=25.0
    (this is the official JOGL-forum), they should be able to help you there.

  • 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?

  • How to get distinct values from a list and display in a ListView webpart.

    Hi,
    I have a requirement in which I need to pull unique/distinct values from a custom list and then display it via a listview webpart. Can any one suggest how this can be done.
    If possible please share the CAMEL query to fetch distinct values from a custom list.
    Thanks,
    Ankit

    Hi Ankit,
    Is there any particular reason that the values need to be shown in a list view web part?  Are you going to use that web part for filtering via web part connections?
    I ask because the enterprise site collection features include the SharePoint List Filter web part, which may accomplish what you're looking for.
    If you just need to display the values in a grid view, you might have more luck with the JavaScript Client Object Model.  Try putting the following in a text file:
    <style>
    .CustomTableClass{display:table;table-layout:fixed}
    .CustomRowClass{display:table-row;}
    </style>
    <div id="distinct_values_div" class="CustomTableClass">
    <img src="/_layouts/loading.gif" />
    </div>
    <script language="JavaScript" type="text/JavaScript">
    var siteUrl = '/sitecollection/web'; //use the actual subsite URL here
    var listName = 'mylist'; // use the actual list name here
    var field = "Title" // use the actual field you want to display here
    var divToUpdate = document.getElementById("distinct_values_div");
    var rowClass = "CustomRowClass";
    ExecuteOrDelayUntilScriptLoaded(function(){
    var clientContext = new SP.ClientContext(siteUrl);
    var web = clientContext.get_web();
    var lists = web.get_lists();
    var list = lists.getByTitle(listName);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query></Query><RowLimit>500</RowLimit></View>');
    this.collListItem = list.getItems(camlQuery);
    clientContext.load(collListItem,"Include ("+field+")");
    clientContext.executeQueryAsync(
    Function.createDelegate(this, this.onQuerySucceeded),
    Function.createDelegate(this, this.onQueryFailed));
    },"sp.js");
    function onQueryFailed(sender, args){
    divToUpdate.innerHTML = 'Unable to retrieve values: '+args.get_message());
    function onQuerySucceeded(sender, args){
    var allValues = [];
    var listItemEnumerator = collListItem.getEnumerator();
    divToUpdate.innerHTML = "";
    while(listItemEnumerator.moveNext()){
    var listItem = listItemEnumerator.get_current();
    if(!containsString(allValues,listItem.get_item(field)){
    var value = listItem.get_item(field);
    allValues.push(value);
    var newDiv = document.createElement("div");
    newDiv.className = rowClass;
    newDiv.innerHTML = value;
    divToUpdate.appendChild(newDiv);
    function containsString(strArray, text){
    var contains = false;
    for (var i=0; i<strArray.length; i++){
    if(strArray[i]==text){contains = true; break;}
    return contains;
    </script>
    Upload the text file to a library on the site, then add a content editor web part to a page where you want the distinct values to appear. In the content editor web part's properties, edit the Content Link so that it links directly to the text file.  This
    will cause the JavaScript to run on the page.

  • 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?

  • Help with taking a pic with Android camera and adding pic to 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/fla sh/media/CameraUI.html
    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,
    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/fla sh/media/CameraUI.html
    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();

  • 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.

  • 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

Maybe you are looking for

  • Long messages problem

    Hi all, When I send a short message (2 to 4 lines) on my iPhone 4S and I press the stand-by button while the message is still being sent, I hear the 'woosh' sound a few seconds later. So no problems for that. But when I send a longer message (10 line

  • Using iPhone as wireless 3g modem ? possible ?

    I have the older iPhone, and am seriously considering a new 3g iPhone. However, I have read in some reviews that the new iPhone 3g canNOT be used as a wireless 3g modem to connect your MacBook Pro to the internet. I would ideally like to wirelessly (

  • Best computer for The Sims 3?

    I'm looking at getting a new computer to use for The Sims 3, and I rally have no idea what to look for. The laptop I've been using (Compaq Presario c700, wasn't intended for Sims when I bought it) is incredibly slow when I try playing. I need to be a

  • Wildo i get charge again if reinstall a purchased app that was deleted bu accident?

    Will i get charge again if i reinstall a purchased app that was deleted by accident?

  • 11g R1 Rac Installation Question

    Hi Experts I hoppe you can help me: I have a production database, the manager ask me to take the test Server to make an Oracle RAC with the Production Server. Can I Install the RAC 11g R1 only in one Server (test server) ? and then include the Second