PDA

View Full Version : xml or levels ??


peter pan
04-01-2003, 07:13 PM
hi..

i have 2 swf files:

1- button.swf
2-ca.swf

on the button.swf i put a button and an empty mc to load the ca.swf file inside it.

the ca.swf call an xml file ( cal.xml ).

the problem is that when i click on the button all the ca.swf is loaded except the xml file which contains the data.



i don't understand why the data inside the xml doesn't load with the cal.swf


i test it with a sound file insted of the xml - it works- the button.swf file loaded the ca.swf + the sound file.





i don't know ? is it a problem of levels or some thing else ?

thankx

tg
04-01-2003, 08:34 PM
your gonna need to show us some script for us to help you.

peter pan
04-01-2003, 09:26 PM
My file is too big to upload .. but you can download this calendar from this URL :


Calendar.zip

i use one like this calendar and i want to load it to my main movie clip using this script :


on(release)
{

_root.createEmptyMovieClip("container",0);
_level0.container.loadMovie("ca.swf"); // i use ca.swf for the calendar file //

_level0.container._x = 50;
_level0.container._y =160;
}



i put this script on a button on the main stage.





so here the script and the source of the calendar >


waiting for replay :rolleyes:

tg
04-01-2003, 10:02 PM
so... when you test the ca.swf file, by itself, it loads the xml ok?

peter pan
04-02-2003, 07:43 AM
Yes..


The problem is not the ca.swf as i said.

The problem is how to upload the xml file to a second level up.


Try the code ii wrote on the button and you will understand what i mean .

tg
04-02-2003, 02:31 PM
i can't download your zip file.

peter pan
04-02-2003, 06:06 PM
Hi

I checked the link .. it works very good..

Would you please try again :)

tg
04-02-2003, 06:41 PM
this is the message i get:

Forbidden
You don't have permission to access /downloads/movies/zip/7645/Calendar Cum Diary.zip on this server.

peter pan
04-03-2003, 01:01 PM
My last shot that i will send you a PM with the URL of the page from which you can download directly.


i hope after all that you can help me .

i++
04-03-2003, 04:51 PM
hi peter,

are both swf files located in the same directory?
if not, it could be a path problem.
the second swf will search from that directory where the main swf is located.

i++

peter pan
04-03-2003, 05:08 PM
Hi i++


the 3 files are in the same directory :the main and the container and the calendar file.

And if i analyze it will be like that :


1- calendar.swf - the calendar.


2- cal.swf - which contains an empty mc - i use this script one of the frames :

//

createEmptyMovieClip("containera", 0);
containera.loadMovie("calendar.swf");
containera._x = 100;
containera._y = 150;

//


3- the main movie - main.swf contains on one of the buttons this script :

//
on (release) {
_root.createEmptyMovieClip("container2", 0);
_level0.container2.loadMovie("cal.swf");
_level0.container2._x = 100;
_level0.container2._y = 100;

}

//


So - for the second and the third level the buttons show up but their color didn't change - i mean the xml is not loaded i guess.

try to download the calendar.zip file and test it by your self.

i++
04-03-2003, 06:43 PM
namaste peter,

i had a look onto your calendar file. looks nice, btw.

your problem is not the xml (it is loaded correctly), but many of your scripts are refering to _root. but _root is the timeline of main swf and not necessarily the timeline of the swf where the script is located. therefore the calendar works if its played alone, but not when it is loaded by another swf.

i would recommend to place this into the first frame of your calendar.fla:


_root.calendarTL = this; // calendarTimeLine


and than comes the hard part. you have to go through all your scripts (in the calendar.fla) and replace each '_root' with '_root.calendarTL' (unfortunately there is no global serch&replace function in flash).

after that your calendar will work, no matter in which level it is loaded.

i++

peter pan
04-03-2003, 08:15 PM
:D :D :D :D :)
OOOOOOOh yyyessssssssss


It works at last.

Dear I++ gob bless you , your recommendation for me like finding an oasis in the middle of desert.

But I need to understand these steps so if I meet a similar situation I can handle it .

I will tell you what these steps mean and if it is wrong please tell me.

We convert all the calendar objects inside a unique level which is calendar TL -

On which refer all the levels in the calendar flash file . in another way it becomes
the global level for all levels.


So when we call the calendar.swf from anywhere ; we are calling the calendarTl in which contains the rest of levels .


I hope that I’ve got the idea , and if not please tell me.


God bless you again.


Many thanks.

i++
04-04-2003, 08:07 AM
hi peter,

i will try to explain it.

_root refers to the main timeline of the swf that is loaded first ('main.swf') and that loads the other swfs ('child.swf').

if you define some variables ('exampleVar') in a frame script of a child.swf they are attached to the current timeline (timeline of child.swf).

when you call '_root.exampleVar' from the 'child.swf', flash will search for the variable in the timeline of the 'main.swf' - and will not find it, because the variable is in the timeline of the 'child.swf'.

now
_root.calendarTL = this;
does the following thing.
it puts a reference to the 'child.swf' timeline into a variable on the root/'main.swf' timeline.
now if you call '_root.calendarTL.exampleVar', flash looks for the 'calendarTL' variable in the timeline of the 'main.swf' and because calendarTL contains a reference back to the timeline of the 'child.swf', it will search in the 'child-timeline' for the exampleVar.

i hope my explanation is good enough to make it a little bit clearer (my english is not good enough to do a better one :()


i++