Groups | Blog | Home
all groups > flash actionscript > june 2006 >

flash actionscript : variable in path


LSNsaltlamp
6/8/2006 9:47:24 PM
How can I use a variable in the path? (I know this is not called the path but I
can't think of what it's called). For instance:

instead of:
this.symbol1.symbol2._height = 800;

I want
var my_var = "this.symbol1.symbol2";
my_var._height = 800;
.:}x-=V!P=-x{:.
6/8/2006 9:57:53 PM
var my_var:MovieClip = this.symbol1.symbol2;
LSNsaltlamp
6/8/2006 10:17:45 PM
What if I need to define a variable in the path also? Such as:

var my_var:MovieClip = "this.symbol1.symbol2" + my_other_var;
.:}x-=V!P=-x{:.
6/8/2006 10:31:18 PM
NSurveyor
6/8/2006 10:37:44 PM
var my_var:MovieClip = this.symbol1.symbol2[my_other_var]
LSNsaltlamp
6/8/2006 10:45:51 PM
Yes I am trying to create a dynamic path to multiple movieclips. I have 120
..swf files that are dynamicly loaded and I need to be able to print the one
that is currently on the screen. I have a variable that keeps track of what
clip is visible for other functions in the movie. This variable coresponds to
the number used in the instance name. For instance when clip 7 is visible the
variable is equal to 07 and the instance name for the clip is "s07". I want one
button that will always print the top clip. I have all the code in place, the
only thing that I'm hung up on is setting with size of the clip to be printed.

I know the error is in var pageL:MovieClip =
(_level0.pages.p1.page.pf.ph.pic.s)+nextpage;



on (release) {
var pageL:MovieClip = (_level0.pages.p1.page.pf.ph.pic.s)+nextpage;
var mag:PrintJob = new PrintJob();
var success = mag.start();
if (success) {
pageL._height = mag.pageHeight;
pageL._width = mag.pageWidth;
mag.addPage(pageL, {xMin:0, xMax:mag.pageWidth, yMin:0,
yMax:mag.pageHeight});
mag.send();
}
}
LSNsaltlamp
6/8/2006 10:50:26 PM
<blockquote>quote:<br><hr><i>Originally posted by: <b><b>NSurveyor</b></b></i>
var my_var:MovieClip = this.symbol1.symbol2[my_other_var]
my_var._height=800<hr></blockquote>

When I do this and trace my_var I get undefined.
.:}x-=V!P=-x{:.
6/8/2006 10:54:39 PM
var pageL:MovieClip = (_level0.pages.p1.page.pf.ph.pic[s+"nextpage"]);
2m
6/8/2006 11:00:28 PM
We used to use the "eval()" function in good old times, nowadays we are
encurage to use the "Array Access Operator" (scary isn't it ?):

var myClipName:String = "superClip_mc";
_level0[myClipName]._height = superHigh;

;-)



AddThis Social Bookmark Button