Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

set vairables in another loaded movieclip

Posted on 2004-08-22
3
Medium Priority
?
178 Views
Last Modified: 2010-04-03
How can i set varabiles which are in a movie clip i loaded from the main clip ?

What i am looking for is something like the following :

loader.loadMovie ("template.swf");
loader.childClip.txtTest          = "abcde";
loader.childClip.btnTest.label = "test";

But these are not working. T_T

Acutally i have trid this :

Main                                                                template.swf      

loader.loadMovie ("template.swf");                     txtTest = _root.loadTxtTest;
_root.loadTxtTest = "abcde";                             btnTest.label = _root.loadBtnTest;
_root.loadBtnTest = "test";

Even if these codes work fine, but i want to code in template.swf as less as possible, and also these codes look so stupid for me T_T. So please help me out.

Thank in advance.
Tee+
0
Comment
Question by:mrvithan
  • 2
3 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 11867827
to access a variable and thus set its value simply locate it using dot syntax to get to it.
0
 
LVL 3

Accepted Solution

by:
chrisevans123 earned 400 total points
ID: 11923729
//begin loading your movie
loader.loadMovie ("template.swf");

//set the method below to be executed every 100ms
var intervalID = setInterval(setVars, 100);

function setVars() {
//check whether the movie has been loaded
if (loader.getBytesLoaded() >= loader.getBytesTotal()) {
//if so set your variables
loader.childClip.txtTest          = "abcde";
loader.childClip.btnTest.label = "test";
//finally clear the interval
clearInterval(intervalID);
}
}

hope this helps.

Chris


0
 
LVL 3

Expert Comment

by:chrisevans123
ID: 11923732
Sorry - this bit was supposed to be first - :)

Hi mrvithan,

There is only one problem with your code - with an additional step it will work.  Your problem is that when you are calling loadmovie you then imediately try to obtain the variable before the movie is actually loaded.  I'm not sure how programming savy you are but think of loadmovie as a new thread.  When you call it, it starts to load the movie at that point (regardless of whether the movie has finished loading or not) the next statement is executed.  What you need to do is to check whether the new movie has loaded completely before trying to obtain the value of the variable.  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question