A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Parent-Child movie communication

  1. #1
    Senior Member
    Join Date
    Mar 2003
    Posts
    136

    Parent-Child movie communication

    If you want to have a sprite designed in its own child movie and then communicate between parent /child you need to set the movies as elements in the main javascript area of the parent movie and then its name is the javascript dotted notation

    PARENT MOVIE
    //declare elements in the parent movie
    wall = element("wall")
    text = element("textbox")
    mainrod = element("mainrod")

    // now declare the child movies as elements
    bfist = element("bigfist")
    aspider = element("spider")

    //declare variables in the parent movie
    fist_value1 = 0
    fist_value2 = 0
    count = 0
    edit_17 = 0

    Then set the elements in each child movie

    ASPIDER MOVIE
    thespider = element("thespider")

    BIGFIST MOVIE
    fist = element("fist")
    rod = element("rod")

    fist.position.x = 0
    fist.angular_velocity = 100
    ctr = 0
    ticker = 0


    Then the Parent can change values in the child movies
    bfist.ticker ++
    bfist.rod.position.x = 20 * sin(fist_value1)


    The child can change values in the Parent
    root.fist_value1 = fist.position.x
    root.wall.rotation = ctr

    and even in other child movies
    root.aspider.thespider.rotation = ctr

    Hope this helps anyone wishing to control sprite movies

  2. #2
    Senior Member
    Join Date
    Mar 2003
    Posts
    136

    parent - child zip

    Here is the source code

    By the way, I find the numeric value in the small edit box in the fist movie gets updated during testing within 3dfa designer but sometimes in the browser or swf player it remains unchanged.

    Also I note that the name of the edit-box variable often changes when I add or change other components on the page e.g. editing and saving a text image. I checked the source code here and it has the correct variable name for the edit box edit_18 but it does not work in the player. Is this a known bug in v3.72 ?
    Attached Files Attached Files
    Last edited by carnwath; 04-12-2003 at 07:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center