Solved

set vairables in another loaded movieclip

Posted on 2004-08-22
3
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

623 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