Solved

set vairables in another loaded movieclip

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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,…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now