Solved

set vairables in another loaded movieclip

Posted on 2004-08-22
3
166 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Does Flash have a Firefox problem? 5 331
flash cs6 4 355
Converting an Adobe Flash file from Actionscript 2.0 to Actionscript 3.0 in Adobe Flash CC 3 1,024
Crash with shockwave flash 8 259
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

751 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