Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-05-2008, 10:04 PM   #1
super8mm
Registered User
 
Join Date: Dec 2008
Posts: 2
Default Modifing variable values of another movieclip

I have 3 movieclips on the stage

The movieclip "brain" is where I put all the variable calculations.

The movieclip "earth" moves on a simple tween the third movieclip "moon" is nested in the movieclip "earth" moving in its tween.

In the timeline of movieclip "earth" I put this on frame 1:

var pnt:Object = {x:moon._x, y:moon._y}
moon.localToGlobal(pnt);
Trace( pnt.x);
Trace( pnt.y);

Frame 2 is gotoAndPlay (1)

This works great! [correction edit] It doesn't work great, it returns the wrong coordinates. It actually gives the distance to twice as far from center point of the movieclip "earth"

So to get the right coordinates I made this calculation adjustment removing half the distance:
_x=pnt.x + ( (xx-pnt.x) /2 );
_y=pnt.y + ( (yy-pnt.y) /2 );

xx and yy are the center coordinates of the movieclip "earth" by putting a dummy movieclip at the 0,0 location.

var pnt:Object = {x:dummy._x, y:dummy._y}
dummy.localToGlobal(pnt);
xx=pnt.x;
yy=pnt.y;


Question: How do I send the values pnt.x and pnt.y to the clip "brain" ?

It would be great if I could do that differently than how I'm doing it now. For now I use an invisible movieclip named "pin01" It is used as the clip both can read and affect as the movieclip "moon" is not visible to the movieclip "brain"

I replace:

Trace( pnt.x);
Trace( pnt.y);

and place instead:

with (_root.pin01) {
_x=pnt.x;
_y=pnt.y;
}


in the movieclip "brain":

with (_root.pin01) {
xxx=_x; yyy=_y:
}
trace ("moon x=" + xxx + " moon y=" + yyy);


I get what I want but there must be a better way?

Last edited by super8mm; 12-06-2008 at 03:23 AM.
super8mm is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with String Variable to target a MovieClip... dvalle ActionScript 3.0 2 08-07-2008 10:32 PM
Passing variable values between MCs Superbird77 ActionScript 2.0 2 07-11-2006 03:05 PM
apply variable values to variable names? Digression ActionScript 2.0 11 07-10-2006 01:21 PM
multiple variable values in external txt file? delhan ActionScript 1.0 (and below) 4 12-07-2004 07:33 PM
[Q] How to Set the variable in _root from the movieclip? CyanBlue ActionScript 1.0 (and below) 3 03-20-2002 08:42 AM


All times are GMT. The time now is 06:50 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.