Uncaught TypeError: Cannot call method 'renderStoreProperty' of undefined

Hi,
I'm using CQ5.5 with SP2.
I am going through the tutorial on how to create and register a new xtype.
I have followed the steps, and am getting the following error when I try to view the page:
Uncaught TypeError: Cannot call method 'renderStoreProperty' of undefined
I have added the following:
/apps/training/widgets ( jcr:primaryType(Name)=cq:ClientLibraryFolder, categories(String[])=training.widgets, dependencies(String[])=cq.widgets, sling:resourceType(String[])=widgets/clientlib )
/apps/training/widgets/files (jcr:primaryType(Name)=nt:folder)
/apps/training/widgets/files/training.js (content below)
/apps/training/widgets/js.txt
#base=files
training.js
training.js
// Create the namespace
Training = {};
// Create a new class based on existing CompositeField
Training.Selection = CQ.Ext.extend(CQ.form.CompositeField, {
    text: "default text",
    constructor : function(config){
        if (config.text != null) this.text = config.text;
        var defaults = {
                height: "auto",
                border: false,
                style: "padding:0;margin-bottom:0;",
                layoutConfig: {
                    labelSeparator: CQ.themes.Dialog.LABEL_SEPARATOR
                defaults: {
                    msgTarget: CQ.themes.Dialog.MSG_TARGET
        CQ.Util.applyDefaults(config, defaults);
        Training.Selection.superclass.constructor.call(this, config);
        this.selectionForm = new CQ.Ext.form.TimeField({
            name: this.name,
            hideLabel: true,
            anchor: "100%",
            minValue: '8:00am',
            maxValue: '6:00pm',
            intDate: new Date(),
            validateValue: function(value) {return true}
        this.add(this.selectionForm);
    processRecord: function(record, path){
        this.selectionForm.setValue(record.get(this.getName()));
CQ.Ext.reg("trainingSelection", Training.Selection);
I have included headlibs.jsp for an extension of page as per the tutorial, contianing:
<cq:includeClientLib js="training.widgets"/>
When debugging the /etc/clientlibs/foundation/librarymanager/CQClientLibraryManager.js file, the path seems to be correct, pointing to:
/apps/training/widgets.js
unfortunately, when I try to hit
http://localhost:4502/apps/training/widgets.js, I get a 404 No resource found error.
This leads me to believe that I have something wrong with the /apps/training/widgets node, as it is not rendering the .js includes.
Any help would be greatly appreciated.

OK, found the problem.
The clue was that it couldn't find the relevant js files.
The tutorial tells us to add:
<cq:inclueClientLib js="training.widgets" />
Just above they have the line:
<cq:inclueClientLib categories="cq.foundation-main"/>
as we have set the property categories(String[])=training.widgets, if we change js to categories as such:
<cq:inclueClientLib categories="training.widgets" />
It fixes the issue.

Similar Messages

  • Edge Proyect TypeError: Cannot call method 'appendChild' of undefined"  version 2014.1.1

    Hi there, any help with this error?
    this is the log:
    [0123/100157:ERROR:renderer_main.cc(226)] Running without renderer sandbox
    [0123/100157:ERROR:renderer_main.cc(226)] Running without renderer sandbox
    [0123/100157:ERROR:renderer_main.cc(226)] Running without renderer sandbox
    [0123/100159:INFO:CONSOLE(1)] "Uncaught TypeError: Cannot call method 'appendChild' of undefined", source: v8/appCss (1)
    [0123/100159:INFO:CONSOLE(0)] "event.returnValue is deprecated. Please use the standard event.preventDefault() instead.", source:  (0)

    Hi, here the proyect http://macheteapps.com/aure/edge/test_font_error.zip , the error is when I add a new custom font.
    <link href='http://fonts.googleapis.com/css?family=Roboto:900,400&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
    Roboto, sans-serif

  • Share blueprint - TypeError: Cannot call method "OutEdges" of undefined'

    Hello,
    I made a BPMN-model in the BPA-suite and want to share the blueprint with IT. The firsttime I succeeded. But when I change the model and want to share the blueprint with IT, I get the following error:
    internal error: TypeError: Cannot call method “OutEdges” of undefined’.
    I am working on a windows2003 platform, the version of the BPA-suite is 10.1.3.4 and the database is a Oracle 10g express edition.
    Does anyone recognise the problem and know the solution?
    Best,
    Jan Tammenga

    Hi Danilo,
    In what cases can appear that error? I have the same error and I can't share blueprint because of that.
    What is it talking about?
    And by the way: is there any document in which errors generated by BPA are described? I would by thankful, if you could give me any links... :)
    Bye,
    Pawel

  • Parsing failed: TypeError: Cannot call method "replace"

    Hi,
    when i troubleshooting my collector, sentinel GUI message prompt
    following:
    Parsing failed: TypeError: Cannot call method "replace" of undefined;
    input:
    my release.js is following:
    Collector.prototype.initialize = function() {
    this.PARSER.getOffsetData = function(input) {
    if (typeof input.RXMap != "undefined") {
    return input.RXMap.REQUEST_TM;
    conn.addParser(this.PARSER.getOffsetData);
    return true;
    Collector.prototype.cleanup = function() {
    return true;
    Connector.prototype.sendQuery = function() {
    return true;
    Record.prototype.preParse = function(e) {
    if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined")
    { return false; }
    if (this.CONNECTION_METHOD == "DATABASE") {
    for (var field in this.RXMap) {
    this[field] = this.RXMap[field];
    return true;
    Record.prototype.parse = function(e) {
    var detstring =
    this.RXMap.REQUEST_TM.replace(/(\d+)\/(\d+)\/(\d{4})\s(\S+)/g, '$1/$2/$3
    $4 GMT');
    var dt = new Date(detstring);
    e.ObserverEventTime(dt);
    return true;
    Record.prototype.normalize = function(e) {
    instance.SEND_EVENT =true;
    return true;
    Record.prototype.postParse = function(e) {
    return true;
    Record.prototype.reply = function(e) {
    return true;
    my sqlquery.base is following:
    SELECT TOP 100 * FROM TS_QUERYBILLSIGNED_LOG WHERE REQUEST_TM > %s
    My table sample is following:
    CUSTCODE,BEGIN_TM,END_TM,PAGEINDEX,QUERYTYPE,SYSTE MNAME,SIGNEDTYPE,CLIENTIP,CLIENTMAC,CLIENTNAME,MET HODNAME,REQUEST_TM,ANSWER_TM,ANSWER_TOTAL,ANSWER_C URRENTCOUNT,LOG_ID,WAYBILL_NOS
    8710294837,12/30/2013,1/2/2014
    23:59,0,0,CSS-CLIENT,0,221.213.26.241,6C-F0-49-CD-2C-CD,a0af75ce888346e,waybillSingedTotal,1/3/2014
    14:50,1/3/2014 14:50,28,4,433676211,
    My table Schema is following:
    USE [sfere]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[ts_querybillsigned_log](
    [CUSTCODE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [BEGIN_TM] [datetime] NULL,
    [END_TM] [datetime] NULL,
    [PAGEINDEX] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [QUERYTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [SYSTEMNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [SIGNEDTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [CLIENTIP] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [CLIENTMAC] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [CLIENTNAME] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [METHODNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [REQUEST_TM] [datetime] NULL,
    [ANSWER_TM] [datetime] NULL,
    [ANSWER_TOTAL] [numeric](20, 0) NULL,
    [ANSWER_CURRENTCOUNT] [numeric](20, 0) NULL,
    [LOG_ID] [numeric](30, 0) NOT NULL,
    [WAYBILL_NOS] [varchar](400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    Thanks
    Best Regards!
    Steve zeng
    steve_zeng
    steve_zeng's Profile: https://forums.netiq.com/member.php?userid=3875
    View this thread: https://forums.netiq.com/showthread.php?t=50290

    steve_zeng;242145 Wrote:
    > Hi,
    >
    > when i troubleshooting my collector, sentinel GUI message prompt
    > following:
    >
    >
    > Parsing failed: TypeError: Cannot call method "replace" of undefined;
    > input:
    >
    > my release.js is following:
    > ----------------------------------------------------------------------
    > Collector.prototype.initialize = function() {
    > this.PARSER.getOffsetData = function(input) {
    > if (typeof input.RXMap != "undefined") {
    > return input.RXMap.REQUEST_TM;
    > }
    > };
    > conn.addParser(this.PARSER.getOffsetData);
    > return true;
    > };
    >
    > Collector.prototype.cleanup = function() {
    > return true;
    > };
    >
    >
    > Connector.prototype.sendQuery = function() {
    > return true;
    > };
    >
    >
    > Record.prototype.preParse = function(e) {
    > if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined")
    > { return false; }
    >
    > if (this.CONNECTION_METHOD == "DATABASE") {
    >
    > for (var field in this.RXMap) {
    > this[field] = this.RXMap[field];
    > }
    > }
    >
    > return true;
    > };
    >
    > Record.prototype.parse = function(e) {
    >
    > var detstring =
    > this.RXMap.REQUEST_TM.replace(/(\d+)\/(\d+)\/(\d{4})\s(\S+)/g, '$1/$2/$3
    > $4 GMT');
    > var dt = new Date(detstring);
    > e.ObserverEventTime(dt);
    > return true;
    > };
    >
    >
    > Record.prototype.normalize = function(e) {
    > instance.SEND_EVENT =true;
    > return true;
    > };
    >
    > Record.prototype.postParse = function(e) {
    > return true;
    > };
    >
    >
    > Record.prototype.reply = function(e) {
    > return true;
    >
    > ----------------------------------------------------------------------------
    > my sqlquery.base is following:
    >
    > SELECT TOP 100 * FROM TS_QUERYBILLSIGNED_LOG WHERE REQUEST_TM > %s
    >
    >
    > My table sample is following:
    > ----------------------------------------------------------------------------------
    >
    > CUSTCODE,BEGIN_TM,END_TM,PAGEINDEX,QUERYTYPE,SYSTE MNAME,SIGNEDTYPE,CLIENTIP,CLIENTMAC,CLIENTNAME,MET HODNAME,REQUEST_TM,ANSWER_TM,ANSWER_TOTAL,ANSWER_C URRENTCOUNT,LOG_ID,WAYBILL_NOS
    > 8710294837,12/30/2013,1/2/2014
    > 23:59,0,0,CSS-CLIENT,0,221.213.26.241,6C-F0-49-CD-2C-CD,a0af75ce888346e,waybillSingedTotal,1/3/2014
    > 14:50,1/3/2014 14:50,28,4,433676211,
    >
    > -----------------------------------------------------------------------------------------
    > My table Schema is following:
    >
    > USE [sfere]
    > GO
    >
    > SET ANSI_NULLS ON
    > GO
    > SET QUOTED_IDENTIFIER ON
    > GO
    > SET ANSI_PADDING ON
    > GO
    > CREATE TABLE [dbo].[ts_querybillsigned_log](
    > [CUSTCODE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [BEGIN_TM] [datetime] NULL,
    > [END_TM] [datetime] NULL,
    > [PAGEINDEX] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [QUERYTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [SYSTEMNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [SIGNEDTYPE] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [CLIENTIP] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [CLIENTMAC] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [CLIENTNAME] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [METHODNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    > [REQUEST_TM] [datetime] NULL,
    > [ANSWER_TM] [datetime] NULL,
    > [ANSWER_TOTAL] [numeric](20, 0) NULL,
    > [ANSWER_CURRENTCOUNT] [numeric](20, 0) NULL,
    > [LOG_ID] [numeric](30, 0) NOT NULL,
    > [WAYBILL_NOS] [varchar](400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    > ) ON [PRIMARY]
    >
    > GO
    > SET ANSI_PADDING OFF
    >
    > Thanks
    > Best Regards!
    > Steve zeng
    It's throwing an exception because at some point, you are not checking
    your string for nulls before calling replace. My guess is that
    this.RXMap.REQUEST_TM is sometimes empty/null and when you call replace,
    it then excepts. Always ensure that your string value is
    non-null/defined before calling a function against it.
    brandon.langley
    brandon.langley's Profile: https://forums.netiq.com/member.php?userid=350
    View this thread: https://forums.netiq.com/showthread.php?t=50290

  • Uncaught TypeError: Cannot read property 'getIconURI' of undefined

    Hi,
    I am getting error "uncaught TypeError: Cannot read property 'getIconURI' of undefined" at statement
    icon: sap.ui.core.IconPool.getIconURI('begin')
    In spite of loading required libraries (data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table").
    In the console I can check that sap.ui.core.Icon is loaded but not sap.ui.core.IconPool.
    What is going wrong here.
    Regards,
    Chidan

    Hi  Aditya,
    Tried $.sap.require('sap.ui.core.IconPool'); now I am not getting the error message but the icon is not getting loaded, meaning I am not getting the URI when I call methd sap.ui.core.IconPool.getIconURI('begin').
    For now I am using workaround of directly entering the URI - but I am afraid what other modules have not been loaded.
    Regards,
    Chidan

  • Uncaught TypeError: Cannot read property 'touches' of undefined. (js-error)

    Hi, I'm trying to make a kind of interactive graphic novel, but keep getting this error when trying to bind swipe left: Uncaught TypeError: Cannot read property 'touches' of undefined. (js-error)

    Hi  Aditya,
    Tried $.sap.require('sap.ui.core.IconPool'); now I am not getting the error message but the icon is not getting loaded, meaning I am not getting the URI when I call methd sap.ui.core.IconPool.getIconURI('begin').
    For now I am using workaround of directly entering the URI - but I am afraid what other modules have not been loaded.
    Regards,
    Chidan

  • MuseJSAssert: ... TypeError: Cannot call method 'getElementsByTagName' of null

    This is the error that I get when I open our site.
    MuseJSAssert: Error calling selector function:TypeError: Cannot call method 'getElementsByTagName' of null
    Can someone take a look at this?
    I tried uploading from scratch on to a new bc test site:
    expertly.businesscatalyst.com
    Dont worry about the Edge videos that works fine.
    When you click on Online or Offline (on the left hand side) this error shows up.
    And then the accordian wigs out.
    Any help would be appreciated. Thanks.

    There seems to be a Javascript error with the "ss-form" HTML that has been inserted. Specifically, this part:
    var divs = document.getElementById('ss-form').
    getElementsByTagName('div');
    I believe (though I'm not sure), that changing it to
    var divs = document.getElementById('ss-form').getElementsByTagName('div');
    All on one line will solve the problem. Unfortunately this is beyond the scope of Muse, as it is code that has been inserted. You made need to check with the source you found the inserted code from.
    Thanks,
    Colby

  • Uncaught TypeError: Cannot read property 'Button' of undefined

    Hello,
    I'm trying to build "Hello world" app using the following tutorial:
    SAP HANA Cloud Platform
    When I try to run this app on the local server, I get this error:
    I did everything strictly as the tutorial says.
    Can someone help me out with this issue?
    Thanks,
    Yuri.

    I have found the root of the problem. When I created the project, I've selected sap.m library instead of sap.ui.commons. I created new project, selected the required library and that solved my problem.

  • Calendar invitation errors: cannot call method 'index of' of undefined

    I added an event to iCal and it sent out some email invitaions. When people click "Accept" in their emails, they get this eror "an error has occurred which prevents application from running: cannot call method 'indexOf' of undefined". Anyone know what's going on here?

    Roginator,
    I too have been experiencing this in the past couple of days.  We have two iPhones (4s), and my wife and I add each other to our schedules.  We have tried at least 5 tests recently, and only 1 worked.  The error occurs in Safari on the iphone and also in my web browsers -Chrome, IE, and Firefox.
    Can we get someone from Apple, on the iCloud side involved with this ASAP.  I am sure many others are experiencing this.
    Thanks.

  • MuseJSAssert: Error calling selector function:TypeError: Cannot read property 'msie' of undefined. Please help me in this.

    MuseJSAssert: Error calling selector function:TypeError: Cannot read property 'msie' of undefined. Please help me in this.

    Hi
    Please check the following thread,
    Re: MuseJSAssert: Error Calling Selector Function:[Object Error]
    Do let me know if you have any question.

  • Apply template but it show "cannot call method 'getAttribute' of null"

    i created a shared template first.
    my steps:
    1. created a datamodel as 'sales'
    2. created a report using 'sale' datamodel
    3. created a new layout ,put my data into the page, and saved the new layout as 'my layout 1'.
    4. saved the report as 'Boilerplates' and placed it undel /my folders.
    (i want to use the layout 'my layout 1' as shared templates)
    now i create another datamodel as 'teu',
    and then create another report using 'teu' datamodel,
    i can see 'my layout 1' layout in the new report, but when i apply 'my layout 1',
    the alert "cannot call method 'getAttribute' of null" display.
    can anyone help me?
    thanks,
    newkoa

    The Code tool is realy useful for putting the script in a readable format.
    This isnt' a great location for generic, non SharePoint, PowerShell questions. A lot of us know it back to front but the hey Scripting guy forum is much faster than we are here.
    That error message is actually very descriptive. It's saying there is no invoke method on a null object, or in other words there isn't an object to operate on. Or to finally put it in English: There is no '$shellApplication' object that PowerShell knows
    of.
    At the moment I've no idea what you intended to do with the $zipPackage object but since it's not being used now i'd just comment that line out

  • Upgrade v5.0 Error: Cannot read property 'timeline' of undefined

    Hi, I have this Error Uncaught TypeError: Cannot read property 'timeline' of undefined after upgrade to version 5.0 the older version of project works fine, any idea how to fix it?

    The new runtime has an internal variable called 'data' in the Symbol class. The code in this composition is also using .data to store some user values which is modifying the internal state of the symbol in runtime and is resulting into js errors. If you change the variable name from data to say _data, this should work. I have already done that in the actions.js file and am attaching the updated copy here. Please do a double check once, as it is used in many places and I might have missed something as I do not understand the domain logic in this code much.
    -Dharmendra

  • Calling methods from inside a tag using jsp 2.0

    My searching has led me to believe that you cannot call methods from in the jsp 2.0 tags. Is this correct? Here is what I am trying to do.
    I have an object that keeps track of various ui information (i.e. tab order, whether or not to stripe the current row and stuff like that). I am trying out the new (to me) jsp tag libraries like so:
    jsp page:
    <jsp:useBean id="rowState" class="com.mypackage.beans.RowState" />
    <ivrow:string rowState="${rowState}" />my string tag:
    <%@ attribute type="com.mypackage.beans.RowState" name="rowState" required="true" %>
    <c:choose>
         <c:when test="${rowState.stripeToggle}">
              <tr class="ivstripe">
         </c:when>
         <c:otherwise>
              <tr>
         </c:otherwise>
    </c:choose>I can access the getter method jst fine. It tells me wether or not to have a white row or a gray row. Now I want to toggle the state of my object but I get the following errors when I try this ${rowState.toggle()}:
    org.apache.jasper.JasperException: /WEB-INF/tags/ivrow/string.tag(81,2) The function toggle must be used with a prefix when a default namespace is not specified
    Question 1:
    Searching on this I found some sites that seemed to say you can't call methods inside tag files...is this true?...how should I do this then? I tried pulling the object out of the pageContext like this:
    <%@ page import="com.xactsites.iv.beans.*" %>
    <%
    RowState rowState = (RowState)pageContext.getAttribute("rowState");
    %>I get the following error for this:
    Generated servlet error:
    RowState cannot be resolved to a type
    Question 2:
    How come java can't find RowState. I seem to recall in my searching reading that page directives aren't allowed in tag files...is this true? How do I import files then?
    I realized that these are probably newbie questions so please be kind, I am new to this and still learning. Any responses are welcome...including links to good resources for learning more.

    You are correct in that JSTL can only call getter/setter methods, and can call methods outside of those. In particular no methods with parameters.
    You could do a couple of things though some of them might be against the "rules"
    1 - Whenever you call isStripeToggle() you could "toggle" it as a side effect. Not really a "clean" solution, but if documented that you call it only once for each iteration would work quite nicely I think.
    2 - Write the "toggle" method following the getter/setter pattern so that you could invoke it from JSTL.
    ie public String getToggle(){
        toggle = !toggle;
        return "";
      }Again its a bit of a hack, but you wouldn't be reusing the isStriptToggle() method in this way
    The way I normally approach this is using a counter for the loop I am in.
    Mostly when you are iterating on a JSP page you are using a <c:forEach> tag or similar which has a varStatus attribute.
    <table>
    <c:forEach var="row" items="${listOfThings}" varStatus="status">
      <tr class="${status.index % 2 == 0 ? 'evenRow' : 'oddRow'}">
        <td>${status.index}></td>
        <td>${row.name}</td>
      </tr>
    </c:forEach>

  • Call to a possibly undefined method setPropertyIsEnumerable?

    Hi,
      I am trying to accomplish using doubleClick events on dateChoosers. Below is the code that is working:
         <mx:VBox>
                  <mx:Label text="Simple DateChooser control."/>
                  <mx:DateChooser id="dateChooser1" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
                  <mx:Label id="selection"  color="blue" text="Date selected:"/>
              </mx:VBox>
      I tried putting in doubleClickEnabled as true in Actionscript, and then call the event, and this is the syntax I used:
         //enable the double Click Enabled Property
                        dch.setPropertyIsEnumerable("doubleClickEnabled",true);
                       dch.addEventListener("doubleClick", useDate2);
      This did not work, and I got this error instead: 1061: Call to a possibly undefined method setPropertyIsEnumerable through a reference with static type mx.controls:DateChooser.   
      I tried to find a suitable import statement to insert in my code, but I am not sure what to put there. Could anyone please give me a hint what to do here to get my code to accept the method?
    Thanks in advance.
    Alice

    Hi, Ryan:
      Thanks, I got that to work, but it seems like the doubleClick does not allow me to use it on the dateChooser. Here is the code:
        The MXML:
               <mx:VBox id="box2">
                <mx:DateChooser id="dch" doubleClickEnabled="true"
                      doubleClick="displayDate2()"
                      change="displayDate(DateChooser(event.target).selectedDate)"/>
             </mx:VBox>
        The same thing in Actionscript, but not working:
         dch = new DateChooser();
         dch.addEventListener("change", displayDate);
         dch.doubleClickEnabled = true;
        dch.addEventListener("doubleClick",displayDate2);
      //Got an error saying TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@20112769 to     
      //mx.events.CalendarLayoutChangeEvent.
         box2.addChild(dch);
       Could you give me some pointers on what I have wrong here?
    Thanks for your help.
    Alice

  • ActionScript 3 Noob Help - 1180: Call to a possibly undefined method addChild.

    Hey everyone, i'm in the process of learning ActionScript 3. I'm woking on my first OOP game with a class other than the document class.
    Right now, my game has a preloader library symbol called PreLoader and one called MainMenu (they have been exported for actionscript). All other objects are subobjects of these Movie Clips. My code si split into three actionscript files called Main.as (the document class. I had planned this to load and unload the preloader, mainmenu, and game itself) MainMenu.as (meant to controll the main menu's buttons and listeners) and PreLoader.as (which has the pre-Loader code in it.) I was having a lot of trouble with unloading the main menu and preloader after I was finished with them, so I let the document class handle them, which led to a series of errors as follows:
    C:\Users\...\hamletgame\Main.as, Line 19    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 20    1180: Call to a possibly undefined method addChild.
    C:\Users\...\hamletgame\Main.as, Line 20    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 21    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 21    1120: Access of undefined property preLoader.
    C:\Users\...\hamletgame\Main.as, Line 25    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 25    1120: Access of undefined property mainMenu.
    Thank you all very much in advance. I'm sure its something simple i've missed. My code is posted below.
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
            static public function loadMainMenu():void
                mainMenu = new MainMenu();
                addChild(mainMenu);
                removeChild(preLoader);
            static public function loadGame():void
                removeChild(mainMenu);
    PreLoader.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class PreLoader extends MovieClip
            //Declare Variables Here
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            private function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                    playButton.addEventListener(MouseEvent.CLICK, startMovie)
            private function startMovie (event:MouseEvent):void
                removeEventListener(MouseEvent.CLICK, startMovie);
                Main.loadMainMenu();
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
            public function MainMenu()
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
            //Other Functions
            private function onFrameEnter(event:Event):void
                if(currentFrame==30)
                    stop();
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            private function onPlayGameButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                Main.loadGame();
            private function onInstructionsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            private function onCreditsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);

    I'm not sure why I'm not able to use all 3 of your classes as intended.  I read that you cannot access the Document Class from other classes directly.  So This is what I have:
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
                                  trace("Main");
            public function loadGame():void
                                  trace("loadGame start");
                //removeChild(mainMenu);
                                  trace("loadGame finish");
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
            public function MainMenu()
                                  trace("MainMenu");
    PreLoader.as  (this is where the heart of your app is)
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
              import flash.display.Loader;
              import flash.display.LoaderInfo;
        public class PreLoader extends MovieClip
            //Declare Variables Here
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
            var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var loadingBar:LoadingBar;
                        var playsButton;
                        var container_mc:MovieClip;
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            public function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                                  loadingBar=new LoadingBar();
                                  addChild(loadingBar);
                                  loadingBar.x=50;
                                  loadingBar.y=50;
                                  var playsButton=new PlaysButton();
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                                            removeChild(loadingBar);
                                            //stop();
                                            trace("loaded equals total");
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                                            addChild(playsButton);
                                            playsButton.x=50;
                                            playsButton.y=250;
                    playsButton.addEventListener(MouseEvent.CLICK, startMovie);
            public function startMovie(event:MouseEvent):void
                //removeEventListener(MouseEvent.CLICK, startMovie);
                                  trace("startMovie");
                                  loadMainMenu();
                         public function loadMainMenu():void
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
                                  trace(currentFrame+"cf");
                                  trace("loadMainMenu start");
                                  container1_mc= new MovieClip();
                                  addChild(container1_mc);
                                  playGameButton=new PlayGameButton();
                                  trace("1");
                                  instructionsButton= new InstructionsButton();
                                  creditsButton = new CreditsButton();
                                  playGameButton.x=100;
                                            playGameButton.y=100;
                                            instructionsButton.x=200;
                                            instructionsButton.y=100;
                                            creditsButton.x=300;
                                            creditsButton.y=100;
                                            trace(creditsButton.name);
                                            trace(creditsButton.x);
                                            trace(creditsButton.y);
                                            trace(container1_mc.x);
                                            trace(container1_mc.y);
                                  addChild(playGameButton);
                                  playGameButton.name="playGameButton";
                                  instructionsButton.name="instructionsButton";
                                  creditsButton.name="creditsButton";
                                  trace(creditsButton.name);
                                  trace("2");
                                            addChild(instructionsButton);
                                            addChild(creditsButton);
                                  trace("loadMainMenu finish");
                                  MainMenus();
                        public function MainMenus():void
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
                                  trace("MainMenus");
                                  //loadMainMenu();
            public function onFrameEnter(event:Event):void
                                  trace("AA");
                if(currentFrame==0)
                                            if(creditsButton.name=="creditsButton"){
                    stop();
                                            trace("frame 30");
                                            trace(currentFrame);
                                            trace(creditsButton.name);
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            public function onPlayGameButtonClick(event:MouseEvent):void
                                  trace("A");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                //main.loadGame();
            public function onInstructionsButtonClick(event:MouseEvent):void
                                  trace("B");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            public function onCreditsButtonClick(event:MouseEvent):void
                                  trace("C");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
    I've exported each button and movie clip which resides on the stage in the Library.  I've removed them from the stage/Timeline and just have the Exports in ActionScript on Frame 1.  I also noticed I couldn't access frame 30 and had to change the code to "if(currentFrame==0)....."
    I hope this gets you started in the right direction though I'm not sure what I've done is what you're looking for.

Maybe you are looking for

  • "Selection markers" not visible in Quicktime Pro 7 just purchased

    I just bought Quicktime Pro, registered, and it seems everything is fine (all the "PRO" features are now activated. BUT I cannot seem to figure out how to do this one simple thing: I'm trying to edit my video, and want to delete a short section of it

  • Using Netgear Access Point with Business Hub

    Dear all, I am trying to set up a wireless network and am using a BT Business Hub 3.0 as the router + wireless transmitter in one area and a Netgear WG602 v.4 Access Point in another area of my home. The Business Hub and the Netgear are connected via

  • Oracle 10g Backupset Query..

    Hi Team, I am working Backup & Restore on Oracle 10g (10.2.0.1.0). For the backup I am using the following Script. run CONFIGURE BACKUP OPTIMIZATION OFF; CONFIGURE CONTROLFILE AUTOBACKUP OFF; CONFIGURE DEVICE TYPE DISK PARALLELISM 1; CONFIGURE MAXSET

  • MRP exception message 10

    Hello Experts, Could you give me a hint about following problem. I have two purchased materials with the same MM settings (mrp group, planned delivery time, MRP type, Lot size, planning time fence, GR processing time). We have the same settings in Sc

  • Breakout box not working

    b? Hi. I have both a li've platinum and an audigy platinum. The card bit works fine, but no matter which one I use in my PC, I cant get the front box to work. I think I've forgotten to connect something important. There's an IDE style cable running f