Solved

set vairables in another loaded movieclip

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCCM 2012 - Deploy Flash 16 6,937
Embedded Video Download (Flash) 3 1,157
Begin mp4 video on first frame 6 171
embedding a media live encoder stream 3 132
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…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

813 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

16 Experts available now in Live!

Get 1:1 Help Now