Parenting and child control with AS3

Hi,
I'm new to AS3 and although I can see some good practice and functionality I'm constantly getting stucked and can't yet make things that I would do so easily with AS2 - I almost need to relearn it from scratch!. Still I would appreciate some help and guidance on this...
I made a class that creates a "kind" of menu with data from a XML file and basically what it does when it is called is create a emptyMC (a container), add a childMC (a square) and add another child (a text label). When I create the container I'm trying to add a MouseEvent that can act on each the container instances but all I can get is a MouseEvent on object containing all the added MCs. The code follows.
Can anyone enlight me with this issue or explain what am I doing wrong.
I can't understand well the dynamic parenting with AS3 and the lack of using instance names and dot parenting doesn't help.
Thanks in advance.
Note to Adobe: Previous versions of Flash Help Files and AS reference were by far more helpful than in CS4!
In the timeline:
import assets.myDynMenu;
var theMenu:myDynMenu = new myDynMenu("menu.xml");
stage.addChild(theMenu)
stop();
In the class:
package assets
     import flash.display.*;
     import flash.events.Event;
     import flash.events.MouseEvent;
     import flash.text.TextField;
     import flash.net.*;
     public class myDynMenu extends Sprite {
          // INIT EXTERNAL DATA LOAD
          public function myDynMenu(theData) {
               // LOADS THE MENU DATA FROM PREFORMATTED XML
               var loader:URLLoader = new URLLoader();
               var url:URLRequest = new URLRequest(theData);
               loader.addEventListener(Event.COMPLETE, buildTheMenu);
               loader.load(url);
          // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
          public function buildTheMenu(event:Event):void {
               var xml:XML = new XML(event.target.data);
               for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                    // ADDS A CONTAINER
                    var itemContainer:MovieClip = new MovieClip();
                    itemContainer.name = "menu" + i;
                    // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                    // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                    itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                    itemContainer.x = 100 * i;
                    itemContainer.y = 0;
                    itemContainer.mouseEnabled = true;
                    itemContainer.mouseChildren = false;
                    addChild(itemContainer);
                    // ADDS A CHILD TO CONTAINER (a square)
                    var itemBase:MovieClip = new MovieClip();
                    itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                    itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mConfig.mainIt emH);
                    itemBase.graphics.endFill();
                    itemBase.name = "base" + i;
                    itemBase.mouseEnabled = false;
                    itemBase.mouseChildren = false;
                    itemContainer.addChild(itemBase);
                    // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                    var theLabel:TextField = new TextField();
                    theLabel.x = 5;
                    theLabel.y = 5;
                    theLabel.selectable = false;
                    theLabel.mouseEnabled = false;
                    theLabel.border = true;
                    theLabel.text = xml.menuData.menuItem[i].mName;
                    itemContainer.addChild(theLabel);
          // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
          private function onMouseOver(event:MouseEvent):void {
               event.stopPropagation();
               trace("You are over " + this.name );

use:
package assets
     import flash.display.*;
     import flash.events.Event;
     import flash.events.MouseEvent;
     import flash.text.TextField;
     import flash.net.*;
     public class myDynMenu extends Sprite {
          // INIT EXTERNAL DATA LOAD
          public function myDynMenu(theData) {
               // LOADS THE MENU DATA FROM PREFORMATTED XML
               var loader:URLLoader = new URLLoader();
               var url:URLRequest = new URLRequest(theData);
               loader.addEventListener(Event.COMPLETE, buildTheMenu);
               loader.load(url);
          // XML MENU DATA LOAD CHECK - ON COMPLETE BUILD OBJECT AND CHILDREN
          public function buildTheMenu(event:Event):void {
               var xml:XML = new XML(event.target.data);
               for (var i=0; i<xml.menuData.menuItem.length(); i++) {
                    // ADDS A CONTAINER
                    var itemContainer:MovieClip = new MovieClip();
                    itemContainer.name = "menu" + i;
                    // THE NEXT LINE DOESN'T ACT AS I WISHED?!
                    // IN THE FUNCTION CALLED I NEED TO CONTROL THIS ITEM AND ITS CHILDREN
                    itemContainer.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
                    itemContainer.x = 100 * i;
                    itemContainer.y = 0;
                    itemContainer.mouseEnabled = true;
                    itemContainer.mouseChildren = false;
                    addChild(itemContainer);
                    // ADDS A CHILD TO CONTAINER (a square)
                    var itemBase:MovieClip = new MovieClip();
                    itemBase.graphics.beginFill(xml.menuData.mConfig.mainItemColor);
                    itemBase.graphics.drawRect(0,0,xml.menuData.mConfig.mainItemW,xml.menuData.mCon fig.mainItemH);
                    itemBase.graphics.endFill();
                    itemBase.name = "base" + i;
                    itemBase.mouseEnabled = false;
                    itemBase.mouseChildren = false;
                    itemContainer.addChild(itemBase);
                    // ADDS ANOTHER CHILD TO CONTAINER (a text label)
                    var theLabel:TextField = new TextField();
                    theLabel.x = 5;
                    theLabel.y = 5;
                    theLabel.selectable = false;
                    theLabel.mouseEnabled = false;
                    theLabel.border = true;
                    theLabel.text = xml.menuData.menuItem[i].mName;
                    itemContainer.addChild(theLabel);
          // THIS IS THE MOUSE OVER THAT I NEED TO ACT ON EACH itemContainer (AND CHILDREN)
          private function onMouseOver(event:MouseEvent):void {
               event.stopPropagation();
               trace("You are over " + event.currentTarget.name );

Similar Messages

  • How to list selected parent and child rows with values from ADF TreeTable

    I created one tree table having three levels using DepartmentsVO, EmployeesVO and
    JobHistoryVO where these tables contains parent and child relationship on database.
    Then i added one more column to the tree table which displays selectBooleanCheckBox. This
    check box is available for parent and child rows in that column.
    My first concern is i
    want to list out all the parentids and its child ids from three levels where the check
    box is selected.
    second concern is
    if i select the check box for a parent row, then the remaining check boxes for child rows also select automatically which are comes under the parent row.
    Thanks in advance.
    jk

    hi Frank,
    Thanks for the quick reply...
    As I mentioned before I am able to get the children using JUCtrlHierNodeBinding. but wanted to change the value of child row which have specific data.
    Is it possible through JUCtrlHierNodeBinding to update data of child and parent?? If so then can you please post the code snippet for the same???
    Viral

  • Data transfer B/W parent windonw and child window with out java script

    hi ,
    i am using h:outputLink Tag to open child window , i am unable to pass parent window text box value to child window with out java script , Here i am using two different backing beans for parent and child windows . Plz help me .

    Hi -- I pass details between pages regularly. The following has worked for me:
    ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    ValueBinding binding = factory.getApplication().createValueBinding("#{beanName}");
    BeanName beanProperty = (BeanName) binding.getValue(FacesContext.getCurrentInstance());
    ... then set the you can set the values. Can't recall if I need to use SaveStates for the items. Probably if you use request scope beans.

  • 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

  • Need help with arranging Parent and Child item accordingly

    Hi Experts,
    I have a sales BOM in SBO, here we need to show both the Parent and child items. but we do not have to show the Sr.no and Qty for the child items.
    Kindly help me out how I can do it.
    Below pasted is the image of my sales order,
    Also i have attached the report with it.
    Requesting you to kindly help..
    thanks and regards,
    Nandish.

    The Sales BOM helps in identifying that. The product in Red is the Parent Item and the product in Grey are Child items.  The paretn item is the table OITT.Code and child items are in ITT1.code.
    Let me now if you require more information.
    Also how can I send you the layout here for your reference?
    thanks in advance,
    Nandish.

  • Check for same parent and child combination

    hi all i am using oracle 10g. can you please help me in this issue.
    how do i know if the same combination of parent and child present in the table
    key value and value are the values given by user.
    if the user try to create a same profile with same set of key_value and value then that should be avoided
    so how to achieve that.
    example profile already in the table
    -- PROFILE_ID,DETAIL_ID,PARENT_DETAIL_ID,KEY_VALUE, VALUE, LAST_IND
    100,               1,               NULL,                      1,              CDE,     N
    100,               2,              1,                            2,              XXX,     N
    100,               3,              1,                            2,              YYY,    N
    100,               4,              1,                            4,              NEW,    Ynew profile by user -- it should throw an error saying that same profile already present
    -- PROFILE_ID,DETAIL_ID,PARENT_DETAIL_ID,KEY_VALUE,VALUE,LAST_IND
    101,               5,               NULL,                      1,              CDE,    N
    101,               6,              5,                            2,              XXX,    N
    101,               7,              5,                            2,              YYY,    N
    101,               8,              5,                            4,              NEW,    YEdited by: DeepakDevarapalli on Dec 9, 2009 9:48 AM
    Edited by: DeepakDevarapalli on Dec 9, 2009 9:59 AM

    sir i have used your logic, each query works fine and displays the correct results below are the results.
    SELECT   SUBSTR (t.ptxt, 2, LENGTH (ptxt)) profile_values
        FROM (SELECT     SYS_CONNECT_BY_PATH (rtxt, ',') AS ptxt
                    FROM (SELECT key_value || '/' || VALUE AS rtxt,
                                 ROW_NUMBER () OVER (PARTITION BY profile_id ORDER BY key_value,
                                  VALUE) AS rnum
                            FROM sp_profile_detail
                           WHERE profile_id IN (100, 101))
                   WHERE CONNECT_BY_ISLEAF = 1
              START WITH rnum = 1
              CONNECT BY rnum = PRIOR rnum + 1) t
    GROUP BY ptxtresults from query 1
    profile_values
    1/CDE,2/XXX,2/YYY,4/111
    1/CDE,2/XXX,2/YYY,4/222
    SELECT   SUBSTR (s.ptxt, 2, LENGTH (ptxt)) profile_values
        FROM (SELECT     SYS_CONNECT_BY_PATH (rtxt, ',') AS ptxt
                    FROM (SELECT key_value || '/' || VALUE AS rtxt,
                                 ROW_NUMBER () OVER (ORDER BY key_value,
                                  VALUE) AS rnum
                            FROM sp_profile_detail1)
                   WHERE CONNECT_BY_ISLEAF = 1
              START WITH rnum = 1
              CONNECT BY rnum = PRIOR rnum + 1) s
    GROUP BY ptxtresults from query 2
    profile_values
    1/CDE,2/XXX,2/YYY,4/111
    but when i tried to combine both and do a minus it throws me an error .
    ORA-00600: internal error code, arguments: [expcmo_strdef1], [27], [27], [], [], [], [], []
    -- target
    SELECT   SUBSTR (t.ptxt, 2, LENGTH (ptxt)) profile_values
        FROM (SELECT     SYS_CONNECT_BY_PATH (rtxt, ',') AS ptxt
                    FROM (SELECT key_value || '/' || VALUE AS rtxt,
                                 ROW_NUMBER () OVER (PARTITION BY profile_id ORDER BY key_value,
                                  VALUE) AS rnum
                            FROM sp_profile_detail
                           WHERE profile_id IN (100, 101))
                   WHERE CONNECT_BY_ISLEAF = 1
              START WITH rnum = 1
              CONNECT BY rnum = PRIOR rnum + 1) t
    GROUP BY ptxt
    MINUS
    -- staging
    SELECT   SUBSTR (s.ptxt, 2, LENGTH (ptxt)) profile_values
        FROM (SELECT     SYS_CONNECT_BY_PATH (rtxt, ',') AS ptxt
                    FROM (SELECT key_value || '/' || VALUE AS rtxt,
                                 ROW_NUMBER () OVER (ORDER BY key_value,
                                  VALUE) AS rnum
                            FROM sp_profile_detail1)
                   WHERE CONNECT_BY_ISLEAF = 1
              START WITH rnum = 1
              CONNECT BY rnum = PRIOR rnum + 1) s
    GROUP BY ptxt

  • How to get the parent and child relation of the group (______________)

    Please teach the method of acquiring the parent and child relation of the group with EDK5.2.
    EDK5.2____________________,_________o

    Hello.
    Java________,_______________...
    Class________o
    com.plumtree.remote.auth.ChildGroupList
    ...o(^^;)
    Best Regards,
    --------- Hiroko Iida_______ (05/10/28 18:27) -------
    Please teach the method of acquiring the parent and child relation of the group with EDK5.2.
    EDK5.2____________________,_________o

  • Insert data Flatfile table to Parent and child tables

    Hi All,
        I have Flatfile table which is we getting from daily txt files and i want to populate flatfile data to parent as well as child tables. parent table has primary key as ID. This ID is foreign key of child tables. 
    Here i have mentioned our process.
    1. Flatfile duplicates has to remove with condition of daily date.
    2. Before Insert parent table have to check duplicate(we have Unique key of 4 columns in parent) if duplicate is there we have to delete duplicate then Insert into parent table unique records(Primary key is ID).(here why we are delete duplicate record meaning
    we getting daily files so if any records updated in future that record should be insert to parent and child table so only we delete old records and insert new records).
    3.After insert parent we have to populate child tables from Flatfile table as well as we have to insert parent table primary key as foreign key of child tables.
    4. if any truncation error occurs that errors should go to error log table.
    Right now we are using cursor for this concept and cursor has performance issue. so we are trying to optimize other way to populate parent and child table to increase performance to populate.
    Please help us to which way to do this process increase of performance .
    Please  can any one reply.

    Hi RajVasu,
    Since this issue is related to Transact-SQL, I will move this thread to Transact-SQL forum. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 
    Thank you for your understanding and support.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • OIM API - How to get the values in the process form (both parent and child)

    Hi,
    I created an RO with a Process form (both Parent and Child).I created a unconditional process task which takes in the processinstance key and tried to retrieve the process form datas.When i tried to provison the resource,the process task is getting triggered and I could able to get the parent form data but not the child form data.
    Any idea why is this happening?.Is it mandatory to have the "Triggers" ON to get the Child Form data.?
    Thanks,

    try this
    tcResultSet childResults = formOper.getChildFormDefinition(
                             formOper.getProcessFormDefinitionKey(procInstanceKey),
                             formOper.getProcessFormVersion(procInstanceKey));
    This should work,
    Regards,
    Raghav

  • How to update parent and child tables while updating parent table

    I have a parent table EMPLOYEE which includes columns (sysid, serviceno,employeename...) sysid is Primary key, serviceno is Unique key and I have child table DEPENDENT includes columns (sysid,employee_sysid,name,dob...) here again SYSID is primary key for DEPENDENTS table, employee_sysid is Foreign key of EMPLOYEE table.
    Now I want to change SYSID (using sequence) in EMPLOYEE table which need to be update in DEPENDENTS table as well
    Note: I have 10000 records in EMPLOYEE table as well as I have 5 more child tables which need to update new SYSID.
    please help me

    first disable the FOREIGN KEY Constraints.
    you can update Parent as well as Child record also with help of trigger.
    here i am giving you one examlpe..it may help u.
    create table parent(id number primary key,name varchar2(100))
    create table child_1(id number primary key,p_id number,dob date,
    CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
    create table child_2(id number primary key,p_id2 number,addr varchar2(1000),
    CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
    insert some test data to parent and child tables.
    alter table child_2 disable constraint FK_id2
    alter table child_1 disable constraint FK_id2
    CREATE OR REPLACE TRIGGER delete_child
    BEFORE UPDATE ON parent
    FOR EACH ROW
    BEGIN
    UPDATE CHILD_1
    SET P_ID=:NEW.ID
    WHERE P_ID=:OLD.ID;
    UPDATE CHILD_2
    SET P_ID2 =:NEW.ID
    WHERE P_ID2=:OLD.ID;
    END;
    then Upadte parent table primary key col and check the child tables.
    then enable the constraints...

  • Create Individual Idocs Based on Parent and Child Segment type

    Hi Experts,
    I have a scenario IDOC to FILE ,  Split Single IDOC into Multiple IDOC's based on parent and child Segment Type
    For example If 3 child segments are same and 1 segment is different under parent segment then 3 same child segments are clubbed and create single idoc under parent segments and 1 different child should create in individual idoc under parent segment.
    Note : Same logic should work for N number of Parent Segments and Child Segments.
    Outbound:
    ZIdocName
    Control Record
    Data Record
    Parent Segment A
       Child Segment 1
       Child Segment 1
       Child Segment 1
       Child Segment 2
    Parent segment  B
       Child Segment 3
    Status Record
    I should get output like below
    Inbound:
    ZIdocName
    Control Record
    Data Record
    Parent segment A
      Child Segment 1
      Child Segment 1
      Child Segment 1
    Status Record
    ZIdocName
    Control Record
    Data Record
    Parent segment A
      Child Segment 2
    Status Record
    ZIdocName
    Control Record
    Data Record
    Parent Segment B
      Child Segment 3
    Status Record
    Please suggest me step by step process to achieve this task.
    Thanks.
    Ram

    Hello,
    Segment won't hold any value, so filter criteria should be there on some field wich exist in Parent node and chile node?
    Paste ur XML?
    Try this(Assuming u have some fields in parent/child segment on which u want to define filter criteria):
    Parent Field--UseOneAsMany----RC----
                                      ------------------Concat ----splitbyvalue(value change)--collapse context --- ZIdoc
    Child field-- RC----------
    Child field--RC--splitbyvalue(valuechange)--CC -Splitbyvalue(each value) -- ParentSegment
    Child field--RC--splitbyvalue(valuechange)--- ChildSegment
    RC -> Remove Context
    CC - Collapse Context
    Note - i haven't tested ur mapping, so make sure to adjust context in mapping
    Thanks
    Amit Srivastava
    Message was edited by: Amit Srivastava

  • %variance between parent and child hierarchy

    Experts,
          How to calculate a percentage variance between parent and child hierarchy.
    Ex: parent is 80 and child is 20 so I need a %variance between 80 and 20.
    Thanks in advance.

    Hi Nikki
    Create structure and restrict parent hierarchy with one node and child hierarchy with another node and create formula node to calculate the percentage variance between two nodes.assign points if helpfful.
    Regards
    Murali.

  • Help Displaying Parent and child relationship on one page

    Hello,
    I have 2 tables, lets say Parent and Child, that I want to display both tables on the same page. Basically I'm looking at trying to split the page in half, the top being the Parent table and the bottom being the Child table. When the user selects a parent, I want the Child table to display that parent's child/children. I don't know if this is possible though JDeveloper but I would appreciate all the help I can get
    Thanks,
    Matt

    This is a trivial master detail task for ADF.
    Basically, in the data control palette - stand on the child node that is inside the parent node - drag it over to your page and drop it as a master detail - this will get you what you want.
    More information is in the ADF Tutorial:
    http://www.oracle.com/technology/obe/ADFBC_tutorial_1013/10131/index.htm

  • Delivery document how to print the BOM Parent and Child items

    Hi,
    I have a production BOM. In Delivery document how to print the Parent and Child items Item Code and Qty.At the time
    of add a delivery document Inventory stock redused only in Parent Item not child item because child item stock already reduced in issue for production.

    If you need to print both the BOM Parent and Child items, you have to create your own report. BOM is only for production if it is not Sales type.
    Thanks,
    Gordon

  • How to link parent and child relation in Metapedia

    How to link parent and child relation in Metapedia

    Vamsi,
    Did you every determine how to do what you were asking about? Where you thinking of how to link a parent term to a child term (i.e. like a related term) or was this about linking a term to a different metadata object (e.g. table or report) ?

Maybe you are looking for

  • Does anyone have an email address for someone who cares at Verizon Wireless?

    I have had enough with Verizon Wireless and their lack of service and NO WAY to contact tech support. Which of you brave people will speak up and answer this question? Any way to get answers on ANYTHING to do with lack of phone service, no connection

  • Validator not firing?

    I have an input text with a validator like validator="#{MyBean.validate}", but I put some logging in that method and it looks like it's not being called. What are the possible reasons I should check out? Not sure if relevant, but I copied the bean fr

  • Encryp and sign the SOAP Body in 8.1 SP2

    Hi, I have deployed a web service with security enabled for encrypting, signing and requires username token.I have written a client for the service and it works fine with 8.1 SP3. when i build the same app with 8.1 SP2 and deploy it gets deployed and

  • Error-u201CNo customer master record exists with sold to partyu201D. from Webshop

    Hi, We are trying to create an order from webshop calling BAPI_SALESORDER_CREATEFROMDAT2, while saving the order we are getting an error that "No customer master record exists with sold to party". When we try to execute the same with stanalone progra

  • Unable to write a formula in query designer

    Hi Experts, while writing a formula in query designer in development system there is an error. Formula is: Grand total =1 when i write in the rows it is throwing the sytax error like " General syntax error in formula" But the same formula has been wr