Parent calling child function

Hi,
May i know how to call child function(layer 2) in parent(layer 1)?
Layer 1 (Parent)
function changeAction():void{
     changeColor();
This method will give me the error -> Call to a possibly undefined method changeColor.
Layer 2 (Child)
function changeColor():void{
     trace("success");
Thanks.

You will need to assign an instance name to the child or have some reference to it for targeting it.  If you named the child "child1", then the parent function would be more like...
function changeAction():void{
    child1.changeColor();

Similar Messages

  • Is it possible to call a function in a parent component from a child component in Flex 3?

    This is probably a very basic question but have been wondering this for a while.
    I need to call a function located in a parent component and make the call from its child component in Flex 3. Is there a way to access functions in a parent component from the child component? I know I can dispatch an event in the child and add a listener in the parent to call the function, but just wanted to know if could also directly call a parent function from a child (similar to how you can call a function in the main mxml file using Application.application). Thanks

    There are no performance issues, but it is ok if you are using the child component in only one class. Suppose if you want to use the same component as a child to some bunch of parents then i would do like the following
    public interface IParentImplementation{
         function callParentMethod();
    and the parent class should implement this 'IParentImplementation'
    usually like the following line
    public class parentClass extends Canvas implements IParentImplementation{
              public function callParentMethod():void{
         //code
    in the child  you should do something like this.
    (this.parent as IParentImplementation).callParentMethod();
    Here using the Interfaces, we re decoupling the parent and the child
    If this post answers your question or helps, please mark it as such.

  • Calling a Function in the Parent Window from the Child Window

    QUESTION: How do I call a function resident in the parent
    window from a child window?
    BACKGROUND
    I have a JavaScript function resident in the parent window
    that reformats information obtained from the Date object and writes
    the result to the parent window using the document.write( ) method.
    I would like to call this function from the child window and have
    it write to the child window instead. Is this possible? If not,
    must I rewrite the entire function and nest it in the below code?
    If so, what is the proper form of nesting?
    CODE: The code that creates and fills the child window is
    provided below. The highlighted area indicates where I would like
    to enter the information from the function resident in the parent
    window. I have tried every imaginable permutation of code that I
    can imagine and nearly destroyed my parent document in the process.
    I am very happy that I had a back-up copy!
    function openCitationWindow() {
    ciDow = window.open("", "", "width=450, height=175, top=300,
    left=300");
    ciDow.document.write("A proper way to cite a passage of text
    on this page:<br /><br />Stegemann, R. A. 2000.
    <cite>Imagine: Bridging a Historical Gap</cite>. " +
    document.title + ". [<a href='" + location.href + "'
    target='_blank'>online book</a>] &lt;" + location.href
    + "&gt; (");
    MISSING CODE;
    ciDow.document.write(").<br /><br /><input
    type='button' value='Close Window' onclick='window.close()'>");
    ciDow.focus();

    Never mind - I was doing something very stupid and wasn't
    calling the function as a method of a movie clip. I was simply
    calling checkTarget(event) rather than
    event.currentTarget.checkTarget(event); which seems to work.

  • Calling a function in child window from parent window

    Hi,
    How can I call a method in child window from parent window in adobe air using javascript. In the following example I need to call mytest() function in
    child.html from parent.html file.
    Thanks,
    ASM
    //parent.html
    <HTML><HEAD>
    <script>
    var initOptions = new air.NativeWindowInitOptions();
    initOptions.type = air.NativeWindowType.NORMAL;
    initOptions.systemChrome = air.NativeWindowSystemChrome.STANDARD;
    var bounds = new air.Rectangle(300, 300, 600, 500);
    var html2 = air.HTMLLoader.createRootWindow(false, initOptions, false, bounds);
    var urlReq2 = new air.URLRequest("child.html");
    html2.load(urlReq2);
    html2.stage.nativeWindow.activate();
    html2.window.mytest();       //NOT WORKING
    </script>
    </HEAD><body></body></HTML> 
    // child.html
    <HTML><HEAD>
    <script>
    function mytest()
      air.trace("in child window");
    </script>
    </HEAD> <body></body></HTML>

    I suspect your problem is that the child window hasn't been created by the time you call the function in the parent.Loading the content is an asynchronous processes -- AIR doesn't stop executing your code until the window has finished loading child.html. So, you will need to add an eventlistener to html2 and call the function from there:
    html2.addEventListener( "complete", onChildLoaded );
    function onChildLoaded( event )
         html2.window.mytest();

  • Problem:  Unable to call a function in parent swf from the child swf.

    I am working on a site right now that has a parent loader
    (all it contains are the menu bar [which is as3 tweened] and the
    functions for calling all of the other pages.) The problem that I
    am having right now, are some of the internal or child pages, need
    to call functions that are in the parent loader. For what ever
    reason, I am unable to do any of that.
    I have attached the code so you can look at that.
    Let me see if I can explain it any better.
    The code I just posted is for the Main Stage swf called
    loader.swf. It has the menu, and all the functions that control the
    menu's movement and when to load all the other swfs. The easiest
    way for me to ask this, is to show you.
    click
    http://dev.locallinux.com/mystictan/layout2.html
    When you get there, you will see the menu bar, and it is
    loading home.swf onto the stage behind the menu.
    Mouse over "The Perfect Tan" and click on "1: Base"
    You will notice it just loaded a new swf called ptbase.swf.
    Well in that swf is a button for "Products" That button
    basically needs to take you to "Products > 1: Base" on the menu
    (not working yet, I know. But theres no point in me making that,
    until I could get this working"
    What I would like is when you click on "Products" in
    ptbase.swf, it calls the function clickedProductsBase(), which does
    its thing. But that function is back in the loader.swf. Does that
    make sence?
    What am I missing here?

    RyanORo, thank you very much for your response.
    I try that, and I get this sort of error when I click on it:
    TypeError: Error #1006: fwd is not a function.
    at ptbase_fla::MainTimeline/testing()
    I know all that code that I posted was a bith much, but here
    is the movie loading part:
    function loadComplete(event:Event):void
    loaderbar.visible = false;
    mainbody.removeChild(thisMC);
    thisMC = MovieClip(myloader.content);
    myloader.unload();
    mainbody.addChild(thisMC);
    thisMC.gotoAndStop(1);
    TransitionManager.start(thisMC, {type:Fade,
    direction:Transition.IN, duration:5, easing:Strong.easeOut});
    mainbody is an empty mc under the menu, so that the loaded
    swf file appears under the menu.
    You know what, scratch all that . *MOOWHA* I could KISS you
    right now. "(parent as MovieClip).clickedProductsBase()" did not
    work because it was calling it out of the wrong parent. Just did
    "(this.parent.parent as MovieClip).clickedProductsBase()" and that
    did the magic I needed. Thanks...

  • Parent function calling a child function with arguments

    Can anyone give examples of a parent function which has at least 1 parameter, and is invoked from the Form Behavior, which in turn , depending on data, invokes 2 or more child functions passing to these functions the same parameter that was passed in to it.
    I am getting 'Object required' and do not know what I am doing wrong. Please let me know if you've done it, and how you've referenced it , if they are BOTH functions. Thank you!

    The best way to do this is probably using delegates, but to do it directly you have to solve the circular dependency problem (as you have discovered). See
    http://en.wikipedia.org/wiki/Circular_dependency
    In case it is not clear to you how the Wikipedia article relates to your case, your files should look something like this:
    // Form1.h
    #include "Watch.h"
    ref class Form1: public Form
    public:
    void SomeMethod()
    // implementation
    private:
    void SomeHandler()
    Watch watchForm(this);
    watchForm.ShowDialog();
    // Watch.h
    ref class Form1; // declaration only
    ref class Watch: public Form
    public:
    Watch(Form1^ f1);
    private:
    Form1^ form1;
    void SomeMethod();
    // Watch.cpp
    #include "Watch.h"
    #include "Form1.h"
    Watch::Watch(Form1^ f1)
    form1 = f1;
    void Watch::SomeMethod()
    form1->SomeMethod();
    David Wilkinson | Visual C++ MVP

  • Can a loaded SWF call a function that lives in the parent?

    I'm building a pretty simple Flash site in AS3. There is a
    main movie (main.swf) that simply loads different swfs via buttons
    on a main nav bar. The user clicks on a MC in "main.swf" and a
    function is called, loadMyContent("section1.swf"), is called and it
    animates in nicely. Other buttons use the same function, loading
    section2.swf, section3.swf, etc.
    I've defined how "loadMyContent()" works in the the main
    movie's document class file. It's all working fine when I just need
    to load content from a user action from the buttons that live in
    "main.swf". I want to call that same "loadContent" function from
    within "section1.swf" and have "main.swf" run it's "loadContent"
    fuction, but I can't seem to figure out how to make a child call a
    function that lives in the parent.
    Is there any way of having my child do this?
    I have a suspicion I may have to define that "loadContent"
    somewhere else, but I'm a little stumped now. I'm not really
    familiar with design patterns yet, although I want to get an
    understanding of them sometime soon. Can anyone offer some help
    with my immediate need or suggest a route to a solution?
    Thanks.

    kglad,
    Thank you very much! That worked perfectly. My section1 FLA
    is now compiling it's SWF without complaint.
    In case someone else is following this, the exact code I
    ended up using to cast "this.parent.parent" as a MovieClip is:
    MovieClip(this.parent.parent).loadMyContent("section2.swf");
    The discussion I think kglad is referencing is
    this
    discussion. If that's not it, just let me know. Again, kglad,
    thank you!

  • Inheritance problem with parent class calling child class

    I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
    public abstract class A {
        protected void function1 ( ) { }
        protected void function2 () {
             //calls function1();
             function1();
    public abstract class B extends A {
        protected void function1 ()  {
             // do stuff
    public class C extends B {
        protected void function1 ()  {
            // do stuff
            super.function1 ();
    }I have an object instance of class C created and its function2() is invoked.
    My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
    Edited by: crono77 on Jan 10, 2008 8:13 PM

    Nevermind, i found my error :)

  • A swf in an iFrame calling javascript function on Parent page

    I have a .swf that has to load in a iFrame and needs to call a browser cookie javascript function that lives on the parent page that loads the iFrame.
    I'm using this:
    ExternalInterface.call("javascriptFunction");
    but of course this call is not making it to the Parent page javascript function.  Is this possible to do?
    Thanks!

    The parent page has the javascript function, and has a iFrame that loads the swf.  The swf needs to call the javascript function that lives in the parent page.
    Thanks!

  • How can a custom class call a function in "parent" class?

    Say I have an application (ultrasimplified):
    public class myApp {
    myClass mc;
    boolean foo=false;
    public static void main(String[] args) {
    mc = new myClass();
    public static void myFunc(boolean blah) {
    foo=blah;
    in a separate .java file where my questions lie:
    public class myClass {
    boolean bar=true;
    public void myClass() {
    // this is wrong, but how would I do this:
    foo = bar; // foo in myApp set to true
    // or how would I call "myFunc()" in myApp from this class:
    myFunc(bar);
    my problem is that I've created a new class that I share between two applications so I could share the code. However, I want this class I created to call a function in the application class that instanciated it. Or alternatively, I would like to set a variable in the class that instanciated myClass.
    How would go about this? I've used the "this" parameter in applets to pass the parent class to an inner class, but main() in applications doesn't allow the non-static "this":
    myClass my = new myClass(this);
    Is there something similar I can do?

    You can let MyApp implement an interface and refer to that object in MyClass:
    class MyApp implements Something {
    main() {
    MyApp app = new MyApp();
    MyClass mc = new MyClass(app);
    public void foo() { }
    class MyClass {
    Something app;
    MyClass(Something app) {
    this.app = app;
    app.foo();
    interface Something {
    public void foo();
    Better yet, you can let MyApp extend an abstract class that defines foo(). Then MyApp can override the foo() method. If later on, the abstract class needs to add a bar() method then default implementation can be done in the abstract class. If you make it an interface then all implementing classes will have to be updated to implement the new method.

  • How to differentiate between Parent and Child in IBASE?

    Hi. I am working on enhancing a BAPI :BAPI_GOODSMVT_CREATE by calling the following function module IBPP_CREATE_IBASE at its exit.
    The BAPI is being called from an SAP ME system and will be passing MATNR and Serial Number of Parent and Child materials to create the IBASE in ECC system. I am confused as to how to differentiate between whether a object is Parent or a Child when the BAPI: BAPI_GOODSMVT_CREATE is called.

    if you have NULL valued fields. If
    you do a compare and one or both are NULL, then the result is always NULL,
    never true or false. Even comparing two fields which are both NULL will
    give NULL as result, not true! Or if you have something like "select
    sum(field) from ..." and one or more are NULL, then the result will be
    NULL. Use always "if field is NULL ..." for NULL checking and for safety
    maybe something like "select sum( IsNull(field,0) ) from ...". Check the
    function ISNULL() in the manual.

  • Type conflict when calling a function module (field length)

    Dear All,
                I am getting this following error while executing:  Type conflict when calling a function module (field length)
    This is piece of coding i have writern in my action button.
    method SEARCH_MATERIAL .
      data:
            node_mat_input TYPE REF TO  if_wd_context_node,
            node_mat_output TYPE REF TO if_wd_context_node,
            material TYPE BAPIMATDET-MATERIAL,
            itab TYPE TABLE OF BAPIMATDOA.
      node_mat_input = wd_context->get_child_node( 'NODE_MAT_INPUT' ).
      node_mat_output = wd_context->get_child_node( 'NODE_MAT_OUTPUT' ).
      node_mat_input->get_attribute( EXPORTING name = 'MATERIAL'
                                     IMPORTING value = material ).
      CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
        EXPORTING
          material                    = material
        PLANT                       = plant
        VALUATIONAREA               =
        VALUATIONTYPE               =
        MATERIAL_EVG                =
       IMPORTING
         MATERIAL_GENERAL_DATA       = itab
        RETURN                      =
        MATERIALPLANTDATA           =
        MATERIALVALUATIONDATA       =
      node_mat_output->bind_table( itab ).
    endmethod.
    Attributes are:
    Node name = INPUT its structure is BAPIMATDET
    INPUT attributes = MATERIAL of type BAPIMATDET-MATERIAL
    Thanks,
    Gopi.

    Hi Amit,
               I have used service call to fetch records from that bapi..
    The following is the code generated by service call:-
    METHOD execute_bapi_material_get_deta .
    declarations for context navigation
      DATA:
        node_bapi_material_get_de   TYPE REF TO if_wd_context_node,
         node_exporting   TYPE REF TO if_wd_context_node,
         node_material_general_dat   TYPE REF TO if_wd_context_node,
         node_importing   TYPE REF TO if_wd_context_node,
          lri_element    TYPE REF TO if_wd_context_element.
    declarations for fuba parameters
      data:
        stru_c_material_general_dat    TYPE if_componentcontroller=>element_material_general_dat.
      DATA:
        attr_material    TYPE bapimatdet-material,
        attr_plant    TYPE bapimatall-plant.
    get all involved child nodes
      node_bapi_material_get_de = wd_context->get_child_node( `BAPI_MATERIAL_GET_DE` ).
      node_exporting = node_bapi_material_get_de->get_child_node( `EXPORTING` ).
      node_material_general_dat = node_exporting->get_child_node( `MATERIAL_GENERAL_DAT` ).
      node_importing = node_bapi_material_get_de->get_child_node( `IMPORTING` ).
    get input from context
      node_importing->get_attribute(    EXPORTING      name = `MATERIAL`
                                                         IMPORTING      value = attr_material ).
      node_importing->get_attribute(  EXPORTING       name = `PLANT`
                                                              IMPORTING       value = attr_plant ).
    the invocation - errors are always fatal !!!
      CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
        EXPORTING
          material =                        attr_material
          plant =                           attr_plant
    "      valuationarea =                   wd_This->Valuationarea
    "      valuationtype =                   wd_This->Valuationtype
    "      material_Evg =                    wd_This->Material_Evg
        IMPORTING
          material_general_data =           stru_c_material_general_dat
    "      return =                          wd_This->Return
    "      materialplantdata =               wd_This->Materialplantdata
    "      materialvaluationdata =           wd_This->Materialvaluationdat
      node_material_general_dat->bind_structure( stru_c_material_general_dat[] ).
    ENDMETHOD.
                                 but the problem is I  am getting the following error while compiling...
    " stru_c_materialplantdata " is not an internal table - the " OCCOURS n"  specification is missing.
    Thanks,
    Gopi.
    Edited by: Yegalaivan on Nov 18, 2009 8:30 AM

  • Re: Procurement of Parent item & Child item

    Dear Friends,
    I have a scenario, for Parent item & child item
    client is procuring a parent  material as Set, this comprises of child materials
    we have maintained material codes for Parent material and Child material
    For ex:
         Parent Material : XYZ
    Child MateriaL 1    : X
    Child MateriaL 2    : Y
    Child MateriaL 3    : Z
    maintained MAP in parent material as well as child material as below
    Child MateriaL 1    : X   100 Rs
    Child MateriaL 2    : Y   150 Rs
    Child MateriaL 3    : Z    200 Rs
    Total                              450
    Parent Material : XYZ = 450 ( the total of child materials is equal to Parent material)
    here is my query
    I raise PO for main material and GRN will done for material, and deplete the stock of main material through 201 and update the child materil through 202 mov type. so that stock will update accordingly
    but  when i Procures for main material for market price 600 Rs, it has to distribute apportionately to the child components but here the child material value updates based on the Old map but not updated MAP,
    Please guide how can i achieve this functionality in MM
    thanks in advance

    Hi,
    In your case of doing 201 to deplete the parent material and then doing the 202 to increase the stock of child materials, there is no linking between the two. So there will not be any change in the MAP of child material. It will always take the MAP while increasing the stock.
    The business requirement need come redefining. Do your client buy the Parent material as a set and dismantle it to individual child items?
    If that is the case, the best method to achieve this is through a production BOM. You have to create a BOM and routing and create a production order with negative qty for child items and once you confirm this order, the parent item will be consumed and child item will be increased in stock.
    Search the forum for more details about this.

  • Session expiration issue with parent and child window

    Hi,
    We have two applications (App1 - Implemented using JSF, Spring and Hibernate and App2 -Implemented using Spring MVC, Spring JDBC).
    I have implemented 'Test Access Content' functionality in App1.
    First admin user (Role- Manager) needs to login to App1
    As part of 'Test Access Content' functionality, he enters URL with encrypted key and click 'Test Access' button.
    It opens new window (implemented using java script - window.open) and hits spring controller of App2.
    In spring controller of App2, I am decrypting the key to get user details. After that i am setting user details in session, constructing final URL to display actual content.
    Problem is parent window maintains session till child window renders response. Once child window renders response, parent window loosing session.
    So, if i click any button in parent window after child window renders response, it displays login page as there is no session for parent window.
    Please note that App1 and App2 are sharing same domain. only context paths are different for both apps (app1 and app2).
    Any suggestions on this issue are much appreciated. Please let us know if you have any questions.

    Hi,
    When you open a child window from parent window then you can access child data in the parent window through javascript.
    We have a main web page. There are quite many links on it from which >user can open new web pages but the data is saved when the submit >button on the main page is clicked. Also data that user entered on the >other sub pages is not displayed in the main window.
    1 is this a case of parent and child window.case 1 When you are submitting the main page you need to run javascript function and get data from child windows and save that to database or session. next time when you are displaying the main window you need to query session or database to display the child window data in the main window.
    Case 2> closing child window and you need data in the parent. This can be done in two ways.
    1> When you are closing the child window populate some variables of the main window using javasript.
    2> Save the values in the database or session and refresh the main window and extract data from database or session
    Where should the data be saved that user enetered on the sub pages as the data is not shown in the main page - should it be stored in the session?It is design decision. You can store data in either session or database when you are closing the child window. But ifyou are saving the data on the main page then you can populate main page with child windows data using javascript. Save the data t database when main window data is saved. Depends on business requirements.
    In short if you are saving child windows data in session or database then you need to refresh main screen to pull that data otherwise populate main screen using javascript.
    I hope i answered your questions :) best of luck

  • Modal popup window refresh the parent (calling) window/view

    I have a modal popup window that is adding detail records.  When this window is closed via the Hide method in my controller I would like to refresh the parent (calling) window/view.
    What is the best way to do this?
    Regards,
    Diane

    Here's my process.....
    2-windows & 3 views
    Window 1 - Selection View and Detail View
    Window 2 - Add View (used as a modal popup window called by a button click on the detail view)
    Selection View has all the options for obtaining a list of data for the detail view.  The detail view has an Add button.  Component controller has the hide method and access to the other components that do the update/query methods. On the detail view the user can click Add and a popup modal window shows.  User enters data and clicks either the add or cancel button.  The Detail view needs to refresh to show the additional data that has been added by the modal window.  There are calcuated values in the detail view from a supply function.  This function is not running and the values are not changed.
    What should be put in the hide method that will cause the detail view to obtain new data and supply the calculated values?  If I was using the Add view as part of the same window as the detail/selection views I'd just put in a navigation link between the detail and add views and fire the plug.  I like the idea of the popup window so I'd like to get this to work.
    I put the wdContext.initialize() in the hide method - which yes - caused the detail view to run - however the context lost all the key values so I received a data not found.  I then tried to initialize those nodes that did not contain the key values but the detail view did not display new values.
    Thanks for any ideas.....Diane
    Edited by: Diane Fuller on Jan 8, 2009 6:48 AM

Maybe you are looking for

  • ITunes not working since upgrading to iOS5

    My upgrade to iOS5 seemed pretty seemless over the weekend - that is until I went to play iTunes on my iPhone 4 (AT&T version.)  iTunes opens and displays the music but just won't play anything.  The scrub bar doesn't move and the play indicator indi

  • Battery % display is inaccurate on my iPad since IOS6.0.1, when will this be fixed?

    I find that the battery % display is inaccurate on my iPad since ios6.0.1. Same is happening on my iPod touch. Today my battery was showing as 93%, I stopped the apps, did a power off and on again and the battery went back up to 98%. Maybe this is wh

  • Does Aperture have a salt and pepper filter

    I have scanned around 3000 photos and imported into iPhoto.  On enlargement many have dozens of small white spot and tiny hair imperfections.  In iPhoto these can be deleted individually by using the retouch tool.  Does Aperture (or hidden in iPhoto)

  • DevicePatc​hVFSCacheD​B--same problem as PMTraceDat​abase

    Tons of messages here about PMTraceDatabase, and I've already posted on this too, but I also have the exact problem on my TX with DevicePatchVFSCacheDB. The behavior is exactly the same, it fails with the 4004 error, I uncheck the backup box with Fil

  • Entire result set built?

    Given a table with 500,000 rows, if the following sequence occurs: 1. a cursor is opened which does a table scan (just a simple select, no sorting) 2. one row is fetched 3. the cursor is left open without fetching any more rows Is the entire result s