Instantiating MXML class in AS3

I have a simple MXML component:
-- code -- 'MyClass'
<mx:Canvas ... creationPolicy="none" ... >
  <mx:HBox id="innerPanel" >
    <mx:Canvas ... />
  </mx:HBox>
</mx:Canvas>
-- /code --
I'm trying to instantiate this in AS3 as so:
-- code --
var myClass:MyClass = new myClass();
myClass.createComponentsFromDescriptors(true);
-- /code --
myClass is created, but no children.  myClass.childDescriptors is empty.
What am I doing wrong?
thanx,
rickb

Unfortunatelly nothing of the above works when you have a chain of MXML's and AS's that are instantiating eachother. Not even the combination of all of the techniques mentioned earlier.
I tried all of the above on the entire chain, and even placed callLater in the main canvas container but still creationComplete in MyMXML happens after callLater.
I tried to be creative with the bellow pseudo pseudo code, I hope you get the idea.
<MyMainCanvas>
<script>
onCreationComplete
var myClass = new MyClass();
addChild(myClass)
callLater(doSomething)
doSomething()
// does nothing as none of the properties are available from MyMXML
</script>
</MyMainCanvas>
MyClass extends Canvas
function MyClass()
  var myMXML = new MyMXML();
  addChild(myMXML);
<MyMXML>
<script>
onCreationComplete
   // this gets called after callLater in MyMainCanvas
</script>
</MyMXML>

Similar Messages

  • Actionscript clas to MXML class error!

    Thank you for your help.  This problem has plagued me for hours.  I have an Actionscript class which I receive data from an SQLite database.  When I receive the data I call a method from my custom MXML s:BorderContainer class.  The MXML class is supposed to take the data and place markers on a Google Map.
         When I try to call any of my components (Buttons, Map, anything not written inside the fx:script of the MXML class it throws the one of two errors or alters nothing on the screen.  I understand this means I'm trying to play with the component before a certain process has completed (I'm a bit shaky at what point the MXML class needs to be in order for the components to be usable, if thats after initialization, creationComplete or if I need to use addChild or addElement somewhere per component for them to be usable).
         I've tried in the Actionscript class to create a new instance of the MXML class then call the method.  Inside the MXML class when I try to access a button component it throws the Error #1009: Cannot access a property or method of a null object reference.  Inside Actionscript after the new instance I used the .initialize() call to try and fix this and although it seemed to stop the null error, then I noticed it would do one of two things, it would either throw an Object not initialized error with some playing around (addElement calls, creationComplete call) or it simply would not display anything on screen.  If the code all worked I made sure it had made it to the method of the MXML class just fine and all the code had been used, however, no changes or new creations were shown on screen.
         I placed some simple code below to give a better visual of what I'm describing.  Any and all help is appreciated and thanks again.
    // The Actionscript class is named ConnectDatabase
    private var test2:MainContainer;
    test2 = new MainContainer();
    test2.initialize();
    // After the data is received from the SQLite database I call the MXML class (MainContainer) function with the following:
    test2.connectionReadyMethod();
    // Inside the MXML class named MainContainer
    - I've tried different addElement statements, but I'm open to any advice as I'm problem doing them wrong.
    - This is where I receive the nothing, the Error #1009: Cannot access a property or method of a null object reference, or the Object not Initialized errors.

    A couple of things come to mind.
    The first is where is the MXML component and when is it instantiated? If it is in the 2nd, 3rd, etc. view of a navigator container, and creationPolicy for the container is not set to "all" (and it should not be set to "all" in some cases), then this error can occur.
    If the MXML component is created based on the data returned, is it being created either in the data service result handler or at least in a method called from the result handler? Flex data calls are in general asynchronous, so you can't issue a data call send() and assume the data has been received and execute something after the send() that depends on the data.
    Not sure if this helps, but this is what comes to mind.
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.chikaradev.com
    Adobe Flex Development and Support Services

  • Reg: help on instantiation of class in workflow task

    Hi Geeks,
               I am trying to use class for Purchase order though standard workflow is available with BO. As per the requirement the triggering event is same as in the standard workflow with BO. Once the workfow is triggered ,The data is pulled to class from BO and custom release step is defined for release in class .
                  I face problem with the instantiation of class in workflow task while passed the po value and defined binding for the same after  reading  the document posted by jocelyn dart regarding this as follows :[www. wiki.sdn.sap.com/.../UsingABAPOOmethodsinWorkflowTasks |www. wiki.sdn.sap.com/.../UsingABAPOOmethodsinWorkflowTasks ]
    I am getting error as " Formal parameter " po number  " not defined.Please Advice.
    Regards,
    Kumar.

    Hi,
    I checked the same still no luck. I checked approx all combination.
    First I created a SOA-SAR file(jar file) , I extracted it and checked all jar files were there. orabpel.jar and bpm-services.jar and log4j jar. when i deployed that jar file. but it was not working
    then I put this in weblogic sever lib. it not worked.
    please tell me some points

  • Errors with CF 8.0.1 hotfix 3 and hotfix 4, "Object Instantiation Exception.Class not found"

    We need to get our servers up to date with the latest ColdFusion hotfixes in order to pass our security scans and policies. We have been following the Adobe instructions for installing the hotfixes, but we’re getting the same errors each time. The CF 8 hotfix 2 works fine, but once we install hotfix 3 and/or hotfix 4, we get the following errors:
    "Object Instantiation Exception.Class not found: coldfusion.security.ESAPIUtils The specific sequence of files included or processed is: C:\ColdFusion\wwwroot\WEB-INF\exception\java\lang\Exception.cfm, line: 12 "
    coldfusion.runtime.java.JavaObjectClassNotFoundException:
    We have dozens of servers running Windows XP, Netscape Enterprise Server 6.1 (I  know, don’t laugh), ColdFusion 8,0,1,195765, and Java Version 1.6.0_04. Just about  the only good thing about running XP on our servers is that it matches  our development boxes, so we have almost mirrored environments for dev,  test, and production. We do NOT have the CF install with the J2EE configuration.
    The crazy thing is, on tech note 51180 (http://kb2.adobe.com/cps/511/cpsid_51180.html), it says that the fix for bug # 71787 (Fix for "Object Instantiation Exception" thrown when calling a Java object constructor or method with a null argument under JDK 1.6.) was added in cumulative hotfix 2. However we don’t see this problem until we go to hotfix 3 (or 4).
    I’ve also been reading that other people had this same problem, and that the CF 8 hotfix 3 was not compatible with certain versions of JDK, then when you read the Adobe site for CF 8.0.1 hotfix 3, it says “Added the updated cumulative hotfix to make it compatible with jdk 1.4.x, 1.5.x and 1.6.x.”, so that makes me think that Adobe was supposed to have fixed this CF 8.0.1 hotfix 3 JDK incompatability issue - but unfortunately it's still not working for us. We have followed the instructions for removing the jar files and starting/restarting the CF server as directed, we’ve tried this 5-6 times, and still no luck.
    Recommendations? Seems like this is a ColdFusion bug to me – one that says is fixed on the Adobe site, but is not fixed in our environment. Please advise, thanks.

    For what it's worth, we had an MXUnit user describe a similar, though not identical, problem after installing the latest hotfixes. In his case, he's getting "NoSuchMethodExceptions".

  • How to set the scope for Mxml classes?

    Hi,
    i want to create the mxml class but with internal (package)
    scope (for example).
    Is it possible? (for AS classes yes)

    Don't think you can control scope like this in MXML.

  • [svn] 3570: Fix for SDK-17109 - Incorrect deprecation text when generating ASDoc for a deprecated AS or MXML class .

    Revision: 3570
    Author: [email protected]
    Date: 2008-10-10 10:08:53 -0700 (Fri, 10 Oct 2008)
    Log Message:
    Fix for SDK-17109 - Incorrect deprecation text when generating ASDoc for a deprecated AS or MXML class.
    QA: Yes
    Doc:
    Reviewed By: Paul
    Tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17109
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/ClassTable.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/DocComment.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelGenerator.java

    shadowlurker wrote:
    It's problem in pam configuration files. You need to create files useradd, userdel, groupadd and groupdel in /etc/pam.d/ directory with following content:
    auth sufficient pam_rootok.so
    auth required pam_unix.so
    account required pam_unix.so
    session required pam_unix.so
    password required pam_permit.so
    You da man! I also had to add grpconv and chage to get filesystem working but all seems well now thanks!
    Doug piston had me try something that I think will help anyone else who has this problem.  Try re-installing pambase and shadow.  It generated back most of any I was missing.
    Last edited by shauder (2012-11-03 00:55:19)

  • Listening CustomEvents (Generated by Actionsctip Class) in MXML Classes

    Hello Guys
    I have some custom events, When i dispatch them from mxml classes (visually included in application), i can listen them.
    But when i dispatch them some actionscript classes, i cant listen them, Any help?
    Actually i have a custom class which loads the xml and after loading dispatch an event like "loading complete"
    Any help?
    Thanks

    have you specified in the AS file that it dispatches your event???
    [Event(name="loadingComplete", type="com.your.package.LoadingCompleteEvent")]

  • Instantiating a class within itself ?!

    Hi guys,I just started playing around with Java, trying to understand the core base of this language.
    I have created a simple class and just-for-try I instantiated this class from inside itself.
    public class PrivAndPublic{
    PrivAndPublic o = new PrivAndPublic();
    }//end of class
    It doesn't give me any compiling error!
    Doesn't it sound strange?!
    I cannot understand how is it possible and it really seems a bug to me.
    Thanks for any help!

    What Darcia wrote make me suppose that a class is totally created with the first line of a java file (i.e. public class PrivAndPublic{ )and initialized by the constructor (which, if omitted, comes by default with no arguments)...after all this, the class can be instantiated many times I want from inside the class itself.
    (I was thinking the class needed to reach the matching close curly brace to be possible to instantiate it)
    But as phyzome said I have to be careful to do not make the object call the method which I put the object in, otherwise I will cause an infinite loop...as I did try ;)
    Thanx guys, see you.

  • Why we can't instantiated System class.

    Hi All,
    I can't undersatnd what type of class is "System". We can't instantiated system class but we can use it like a Static class.

    There are number of classes like that. You don't
    instantiate them because you don't need to.Objects
    have state and behavior. State is captured inmember
    variables. None of the functionality the Systemclass
    provides requires an object to be instantiated and
    maintain state in member variables. It's pure
    behavior.I beg to differ. Given he fact that it has attributes
    (e.g. in, out and err), it does have a state...They're static attributes, so no instance (if one existed) would have its own state that would potentially distinguish it from other instances. That's what I was talking about.
    I, personally, think that static classes are rather
    bad OO (it's objects doing the work, not classes),
    but singletons are too burdensome to create.You mean uninstantiable classes with only static methods? (System is not a static class. Only nested classes can be static.)
    If your goal is to write pure OO, then, yeah, they might be bad. But then I don't think "perfect OO" is a particularly important or useful goal. Tool for the job and all that.

  • Error when using instantiated mxml component in popupmanager

    Hi,
    Im getting the following error when trying to create a popup:
    Error #1007: Instantiation attempted on a non-constructor
    The code looks as follows
    var browserPop:CustomBrowser = new CustomBrowser();
    browserPop.targetType = "file";
    browserPop.fileType = "jpg";
    var pop:TitleWindow =
    PopUpManager.createPopUp(this,browserPop as Class, true) as
    TitleWindow;
    Where CustomBrowser is an MXML component extending
    TitleWindow.
    If i use:
    var pop:TitleWindow =
    PopUpManager.createPopUp(this,CustomBrowser, true) as TitleWindow;
    it works fine but i need to be able to set some public
    properties and therefore instantiate it first. Any help would be
    appreaciated.
    Thanks in advance
    Eric

    Create you component using the popupmanager, then cast it to
    the
    specific type to access it's public methods and/or variables.
    Like so for mxml component ExceptionPopup:
    var popup:IFlexDisplayObject;
    popup =
    PopUpManager.createPopUp(_parentPanel,ExceptionPopUp,true,null);
    (popup as ExceptionPopUp).addRecords(ev.errorMessage);
    (popup as ExceptionPopUp).title = "title";
    (popup as ExceptionPopUp).userText.text = "some user text"
    PopUpManager.centerPopUp(popup);

  • Creating Flex applications without MXML but with AS3

    To me it seems logical that if I want to build an application
    I should use AS3 to create reusable components, classes, the
    layout, etc.
    .. however, searching around on the web I exclusively find
    Flex tutorials and examples using MXML. This is also true for the
    books (e.g. Adobe Flex 2 - Training from the source") -- why is
    this?
    Is it wrong of me to think it'd be best to create everything
    in AS3? Do anyone have links to tutorials etc. where they use AS3
    to build Flex applications?

    Although I have not seen tutorials about this I did create a
    test app using the following approach:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:lib="components"
    width="100%"
    height="100%"
    creationComplete="initGrid()"
    scroll="false"
    >
    <mx:Script>
    <![CDATA[
    ..... AS 3 code here to create/populate app - datagrid in my
    case
    ]]>
    </mx:Script>
    <mx:VBox id="_box" width="100%">
    <mx:Button id="hideShowCols" label="Hide Empty Columns"
    click="doColumnAction();"/>
    <mx:DataGrid id="delinquenciesGrid"
    alternatingItemColors="[#cce6ff, #e8ffff]"
    alpha="0.5"
    lockedColumnCount="3"
    allowMultipleSelection="true"
    rowCount="20"
    headerColors="[#cccccc]"
    fontFamily="Arial"
    visible="false"
    preinitialize="detectClick();"
    >
    </mx:DataGrid>
    </mx:VBox>
    </mx:Canvas>
    Even the data grid does not need to be "declared" in MXML, it
    was just a faster way to do it for me - you could do
    canvas_id.addChild(...) any element/item that you create in
    AS3.... or in my case i was doing _box.addChild(newGrid)

  • Classes in as3

    i use AS2 and wish to start using AS3, however i fid it confusied with CLASSES.
    is it possible to learn and use AS3 without classes?

    Yes, you can learn AS3 to a useable extent without learning how to create classes. Though you won't get far in any version of Actionscript without knowing how to use classes.  Even with AS2 you have likely been using classes all along without realizing it.  A MovieClip is a class, a Button is a class, a TextField is a class, and on and on...

  • Instantiating member classes using reflection

    I have checked through this forum but if the answer to this question is here I missed it.
    I am trying to find out how to invoke the appropriate instantiation / constructor call to create an instance of a member class.
    The following works finepublic class Succeeds {
      public abstract static class AbstractMember {
      Succeeds(final AbstractMember am) {
      public static void main(final String[] args) {
        Succeeds a = new Succeeds (new Succeeds.AbstractMember () {
    }However I want to make the AbstractMember a real member class not a nested inner class and I want to instantiate the concrete subclass of AbstractMember in the constructor of Succeeds rather than outside the class. I tried the following:public class Fails {
      public abstract class AbstractMember {
        public class ConcreteMember extends AbstractMember {
      Fails(final Class<? extends AbstractMember> c)
        throws InstantiationException, IllegalAccessException {
        AbstractMember am = c.newInstance() ;
      public static void main(final String[] args)
        throws InstantiationException, IllegalAccessException {
        Fails a = new Fails (Fails.AbstractMember.ConcreteMember.class) ;
    }(Please forgive the appling treatment of exceptions, I wanted to make a small example). This compiles fine but fails at runtime with an InstantiationException I assume because the nullary constructor doesn't exist for a member class because of the need to make the connection to the containing object.
    So the question is is there a bit of reflection that allows me to achieve what I want?
    I cannot be the first person to try doing this. I am hoping it is doable otherwise I am going to have to make the design a bit yukky.
    Thanks.

    import java.lang.reflect.*;
    public class Fixed
        public abstract class AbstractMember
        public class ConcreteMember extends AbstractMember
        <T extends AbstractMember> Fixed(final Class<T> c) throws Exception
            Constructor<T> ctor = c.getConstructor(new Class[]{getClass()});
            AbstractMember am = ctor.newInstance(new Object[]{this});
        public static void main(final String[] args) throws Exception
            new Fixed(ConcreteMember.class);
    }My exception handling is even more lax than yours. Why isn't there a class ReflectionException? I moved ConcreteMember out of AbstractMember to keep things simple. It's not entirely necessary, but I didn't want to construct an AbstractMember first.

  • Instantiating Java class while WAS is starting

    Is there a possibility to register Java classes within the SAP WAS which will be instantiated while the server starts up?

    Hi,
    to be honest, I have only a rough idea - may be you can emulate this behaviour  by  a web application, where in the deployment descriptor the load-on-startup flag is set ?
    Barbara

  • Instantiating a class by file - possible?

    Hi all!
    Is it possible to instantiate a class similar to Class.forName() when I only have the .class file?
    Any ideas?

    take a look at the newInstance() method in Class:
    "Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized."
    http://java.sun.com/j2se/1.4/docs/api/java/lang/Class.html#newInstance()

Maybe you are looking for

  • Office 2013 Packager failed: Office (32-bit) not packaging because of Office (64-bit)

    Hello, I used ODT to download Office 2013 Pro 32-bit and now I am trying to create a package from those files. I use the command line: Setup.exe /packager configuration.xml "E:\Office 2013 Pro App-v" When I try to run this, I immidiatly get the follo

  • Order Settlement/S_ALR_87012993 - Orders: Actual/Plan/Variance

    in the above report, is it proper to say, initially all costs are mentioned, and in the second level all setlled costs are mentioned. The costs are in possitive figures and the settled costs are in negative figures. is this a correct satement. What i

  • MRS 610 and Org Unit Access

    Does anyone knows how security work for MRS 610 ? Is the PD profile require for all users who wants to access Planning board with MRS 610?

  • Knowledge warehouse content

    Hi all,         I had installed KW7.0.When i logged into Knowledge workbench,i am able to find all the folders and infoobjects(Power Point Presentation). When i am trying to view the data in that info object,i am getting an error- An unexpected error

  • Oracle Business Intelligence, Sieble Analytics

    Hi, I have tried to work on Sieble Analytics, though did work successfully but did found relax with out any documentation of it. Any idea from where can i find documentations for OBI Sieble Analytics. Will appreciate your help Regards Majid.