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

Similar Messages

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

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

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

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

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

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

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

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

  • I've a new account on iMac.  When composing an email the contact list does not show up on the bar.  WWhen I start keying in a name, it comes up with the address.  How do I engage the  contact list from the email?

    I've a new account on iMac.  When composing an email the contact list does not show up on the bar, which would allow me to select the persons I want to include on the distribution of the email.  When I start keying in a name in the email, it comes up with the person's address, which shows it is synced.  How do I engage the contact list from the email like I do on my old account (where a contact list icon shows up, along with the "attach" and other icons) ?

    With the New Message window open, go to the View menu and select "Customize Toolbar...".
    In the screen that opens, drag the item labelled "Address" into the Toolbar area of the New Message window, then click the "Done" button.
    That item should be then added to the Toolbar for the New Message window.
    Note that the main Mail window and the New Message window (as well as the separate message window if you open a message that way) use different toolbars - the settings/inclusions for one do not carry over to another.

  • Problem  in Printing the ALV list

    Hi,
       I have one problem with printing the ALV list. While printing the ALV list(thro Print Icon on application Tool bar) ,Fist page of my print out contains some other inforamtion.
      inforamtions included two tables
      first table  contains Sort Criteria, Ascdg, Descnd, Subtotal  columns.
      And second table contains Data statistics , number of
    columns.
    But from Second page onwards , my alv list printed correctly .
      How can i avoid the First page inforamtion and
          what is the Reason of coming like this?
    Thanks,
    Neptune.M

    I assume you are using function module Reuse_alv_grid_display or reuse_alv_list_display for ALV.
    If this is the case, there is a parameter called IS_PRINT that you need to supply while calling the function module.
    you can for exapmle declare
    data:
    printstruc type SLIS_PRINT_ALV.
    printstruc-NO_PRINT_LISTINFOS = 'X'.
    call function 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    IS_PRINT = printstruc
    There are many other flags in is_print structures that you can use to manipulate the printing.
    Cheers!

  • Any idea when GTX 970's will be added to the supported list in the latest version of premiere? id like my cuda.

    Any idea when GTX 970's will be added to the supported list in the latest version of premiere? id like my cuda.

    I Too would like to know. I've finally finished upgrading my rig with a 970, and as far as I know, there's been some good things and not so good things. (I'm on CC 2014.1 with Windows 8.1 Pro) I'll post screenshots when I get back to my computer.
    FIrst things first: Make sure to install the CUDA specific to the 970/980. They have their own toolkit, that I believe people miss. I installed this, and then manually added my card to te supported cards file in the Premiere, AE, and Speedgrade files. When I opened Premiere, it's automatically set to use CUDA acceleration, so I believe it's supported there. I wasn't able to test this, unfortunately. I will confirm this soon.
    Second, when I open After Effects, the Previews preference pane states my card is supported, and all the info below it seems correct, like the shader model. The only thing that seems off is the OpenGL, which is set to 2.1.2 NVIDIA or something of the like instead of 4.x, but I believe its an NVIDIA optimized driver, so I'm not too concerned. The big thing for me is the error message that I recieve when I try to enable Ray-traced 3D. I recieve a compilation error, followed by another message, and I have no clue what to do with them.
    I'm really hoping Adobe releases an updates that bring full native support for these cards, as I'm running an class at my high school where I need to build three machines, all of which will have a 970 inside, and if Adbe doesn't support these cards, I'm kind of screwed as the pipeline is based completely in Adobe with its Dynamic Link and CUDA acceleration. Come on Todd, we believe in you!
    TL;DR     Yes, CUDA acceleration should work within Premiere Pro CC 2014.1, but make sure to install the correct CUDA drivers from NVIDIA (they should be in the yellow boxed text on the downloads page)

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

  • Help!!! My husband by accident synced his account under my account and has merged all of our contacts.  In the process of fixing the mixup has deleted contacts on both phones.  How do I restore the contact list from the original contact list.

    Help!!! My husband by accident synced his account under my account and has merged all of our contacts.  In the process of fixing the mixup has deleted contacts on both phones.  How do I restore the contact list from the original contact list.

    I hope that you aren't complaining about dropped calls INSIDE your condo because no amount of switching or upgrading devices will solve that.
    VZW will not guarantee service inside of any structure. There are just too many factors. If the problem is inside then you might want to look at one of the following:
    1.) Network Extender (may cause issues for others in a condo or apartment style setting)
    2.) A Google Voice Number (Free with a Gmail email address), downloading Google Hangouts Dialer and forwarding your calls to the GVN so that you can make and receive calls over Wi-Fi.

  • Problem in getting the database connection from a connection pool

    Hai All,
    I am facing a problem in getting the database connection from a connection pool created on weblogic server 8.1.
    I am using the Oracle database 8.1.7.
    I have configured my connection pool, datasource and JNDI in weblogic.
    In my java program i have the following code to retrieve the connection.
    import java.sql.*;    
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    class jdbcshp1 {
        public static void main(String[] args) {
         Connection connection = null;
         try {
               Hashtable ht = new Hashtable();
               ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");  // Wanna get rid of this.
               ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); // wanna get rid of this.
               // Get a context for the JNDI look up
               Context ctx = new InitialContext(ht);
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myjndi1");
              //Create a connection object
              connection = ds.getConnection();
         The above code is working fine but, the two ht.put statements are creating problem.
    The problem is, after converting the application into WAR file it can be deployed
    on any machine or different port on same machine. My application fails if its deployed on
    weglogicserver which is at different port.
    Is there any way that i can get rid of those ht.put statements or any other way to solve the problem.
    any help is appreciated.
    Thanks in advance
    Pooja.

    Hai All,
    Firstly, thanks for ur reply.
    Even i have seen some code which uses context constructor with out any parameter and works fine.
    i dont understand why its not working for my code.
    When i remove those ht.put code and use context constructor with out any parameter, it giving an error.
    Context ctx = new InitialContext();
    javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("ocjndi");
    connection = ds.getConnection();The error is as follows:
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    the above error is forcing me to include those code but if the port number is changed the code will not work. Plz let meknow if some setting have to be made.
    I appreciate all ur valuable help.
    Thanks once again.
    Pooja.

  • 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();

Maybe you are looking for

  • N97 mini annoying me! can anyone help?

    Hi, my n97 mini is getting on my nerves...... when it decides it will show me the name of who is txing me, then on the next it will just display the number???? only had it a cple of weeks does it need repairing? thanks, Dawn Message Edited by dawn020

  • Problems trying to use built-in OWB 11.2 on Oracle RDBMS 11.2 (64 bit)

    I recently installed Oracle Enterprise RDBMS 11.2.0.1.0 (64 bit) on my 64-bit Windows 7 machine. I'm now trying to get the built-in OWB 11.2 installation working as well. I managed to create a repository on my database using the Repository Assistant.

  • Questions Regarding Zen Mi

    I've a few questions, hopefully someone is able to answer them? 0. I saw my friend's iPod whenever he connects his device to his computer, there will be a small icon on the lower right corner of the system tray indicating the device is plugged in, an

  • HT6154 How do I get rid of an app that"s non responsive, just says "waiting" and won't delete?

    How do I delete an app that has stopped responding and just says "waiting"?

  • Delete query names from roles and favorites

    I deleted some of the queries in production using RSZDELETE but didn't delete those objects from roles and favorites. As the delete option is disabled in query dsigner and bex analyzer, I m looking for other ways to delete the query names from roles