Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-11-2009, 01:33 PM   PM User | #1
Lleoun
New Coder

 
Join Date: Feb 2008
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Lleoun is an unknown quantity at this point
Loading movieclip depending on txt file info

Hi all,

I have a txt file with variables equalling numbers.
In the first frame in the Action Layer of my main movie clip I have
Code:
function updateResuls()
{
    loadVariables("INFO.TXT", _root);
}
System.useCodepage = true;
updateResuls();
A few frames after I have also in the Action Layer:
Code:
variable1 =  _root.firstvariable;
INFO.txt contains _root.firstvariable=5
Back to my main movie clip I add a layer. In this layer I write some text and I name the "Var" field in the text properties "variable1"
This prints the 5 from the txt file when publishing the movie without problems.

Now imagine that instead of a number from the txt file I want to load a movie or a movieclip .. how should I do it??
I was working in something like:

Code:
if (_root.firstvariable==5){
variable1  = function () {
this.createEmptyMovieClip("container",1);
container._x =0;
container._y =0;
container.loadMovie("loaded.swf");
}}
In the code above:
Code:
this.createEmptyMovieClip("container",1);
container._x =0;
container._y =0;
container.loadMovie("loaded.swf");
works by its own but not the part where it is attached and equalled to variable1 ... should I create a new movie clip instead of a text field and load it inside of it?? if so, how can I do that??

NOTE: I'm using AS2

Thanks a ton in advance !!
Lleoun is offline   Reply With Quote
Old 03-12-2009, 11:20 AM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You can only import as a string like that, so you cannot load a function through a file. This is a security precaution. So you can load a string to the swf you wish to load, and have a function ready in the flash file to accept it.
Also I don't think you can put a function inside of an if statement. variable1 isn't a variable in this situation, its the name of a function which has to be called for the code to execute.

Code:
makeNew = function () {
this.createEmptyMovieClip("container",1);
container._x =0;
container._y =0;
container.loadMovie("loaded.swf");
}

if (_root.firstvariable==5){
makeNew();
}
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:54 PM.


Advertisement
Log in to turn off these ads.