Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : External.as file (like #include)


silvernapalm
6/8/2004 7:47:15 PM
External.as file (like #include) that is not published with the movie at export.

i.e.
I have an array of slides that load external images, but I need to be able to
update the slide length and pass that to the already published swf file.
i.e.
this would be in the slide.as file.
slides = new Array(["welcome to the fun.", "0.jpg"], ["room 1", "1.jpg"],
["lets have fun", "2.jpg"]);

I want to update it
slides = new Array(["welcome to the fun.", "0.jpg"], ["room 1", "1.jpg"],
["lets have fun", "2.jpg"], ["NEW PHOTO", "3.jpg");

Question:
Is there a way to update an external file, such as slide.as, that will pass
the variables to a published swf file?

I need to be able to have someone maintain the site without calling me
everytime they adjust the pictures. I tried the #include only to realize that
it is used at publish time.

would something like System.allow.Domain ... ugg...help please.
JPI
6/8/2004 7:56:05 PM
Sounds like you could use some server side scripting to get that job done. PHP, or the like would probably do the job.
silvernapalm
6/8/2004 8:15:38 PM
Thanx for the reply, I am not versed in PHP. Also, I am required to make the updating as easy as possible.

Jack.
6/8/2004 9:21:23 PM
for easy updating, make a text file containing your data,
use delimeters ("::" and "|") to separate, and load to Flash.
When loaded, split the data to an array,

in the text file
&slides=welcome to the fun.::0.jpg|room 1::1.jpg|lets have fun::2.jpg|NEW
PHOTO::3.jpg&

in Flash
lv = new LoadVars();

lv.onLoad = function(){
slides = lv.slides.split("|");
for(var iv=0; iv<slides.length; iv++){
slides[iv] = slides[iv].split("::");
trace(slides[iv][0]+" -- "+slides[iv][1]);
}
};

lv.load("the.txt");

this will give you - _level0.slides
0:
0:"welcome to the fun.",
1:"0.jpg"

1:
0:"room 1",
1:"1.jpg"

2:
0:"lets have fun",
1:"2.jpg"

3:
0:"NEW PHOTO",
1:"3.jpg"

hth
silvernapalm
6/9/2004 2:11:21 PM
THANK YOU SO MUCH JACK!
last question. when the slides load the first picture doesn't show unless i go
forward then back. any ideas

lv = new LoadVars();

lv.onLoad = function(){
slides = lv.slides.split("|");
for(var i=0; i<slides.length; i++){
slides = slides.split("::");
//trace(slides[0]+" -- "+slides[1]);
}
}

lv.load("slide.txt", placeholder);

function changeSlide(number){
if (number >= 0 && number < slides.length){
currentSlide = number;
title.text = slides[number][0];
loadMovie (slides[number][1], "placeholder");
}
}
changeSlide(0);
Jack.
6/9/2004 4:09:05 PM
call your changeSlide function inside the loadVars.onLoad
you are then certain to have the array filled and ready for use,

lv = new LoadVars();

lv.onLoad = function(){
slides = lv.slides.split("|");
for(var i=0; i<slides.length; i++){
slides[ i ] = slides[ i ].split("::");
}
changeSlide(0);
};

lv.load("slide.txt"); // no need for placeholder here

function changeSlide(number){
if (number >= 0 && number < slides.length){
currentSlide = number;
title.text = slides[number][0];
loadMovie (slides[number][1], "placeholder");
}
};

hth

silvernapalm
6/9/2004 4:15:19 PM
Thank you again Jack.
Jack.
6/9/2004 4:21:50 PM
[quoted text, click to view]

totally agree ;)
most of what i've learnt is by "trail and error"
hardly the fast-track on a steep learning curve,
silvernapalm
6/9/2004 4:31:03 PM
I hear you. I was not familiar with the load only command. and the documentaion
leaves alot to be desired.

now all i have to do is play with the slides and have them revolve around each
other..so when i get to the last slide and when i clik next it will go to the
first slide.

Thank you again.
JPI
6/9/2004 4:36:22 PM
AddThis Social Bookmark Button