;

PDA

Click to See Complete Forum and Search --> : Parent-Child movie communication


carnwath
04-12-2003, 07:32 PM
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

carnwath
04-12-2003, 07:36 PM
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 ?