PDA

View Full Version : Setting a variable?


deefadog
06-26-2003, 11:07 AM
Hi I have a movie clip (clip) which another movie clip within it (contents) which has this script within it:

loadVariables ("links/links1.1.txt", this);


I would like substitute the "links/link1.1,txt" by setting a script on the main movie clip. i.e if I had something like this

loadVariables ("variable", this);


And on the main movie put this : variable=link to a file

Would I then get this:

loadVariables ("link to a file", this);


I need this as there will be many instances of the movie clip.

Thanks

Deef

freddycodes
06-26-2003, 11:19 AM
loadVariables (_root.myVar, this);


On the maintimeline

_root.myVar = "links/links1.1.txt";

deefadog
06-26-2003, 06:20 PM
Hi freddycodes, thanks for helping me out, but I can not get the code to work. I am using flash5 if that makes a difference!

The root to the script is - _root.main.one.clip.content.myVar

The whole point of this is that I have 40 instances of a movie clip "clip" which within that is a movie clip called "content" this is where the variable is.

I need to load a different variable to each of the 40 movie clips, so i can load in different content! Is this the right way to do it? I don't want to have 40 dupliacte's of the same movie!

Thanks

Deef

deefadog
06-29-2003, 05:41 PM
Hi, Can someone help me with the above problem, i have tried everything and am out of ideas!

Thanks

Deef

Sualdam
06-29-2003, 07:36 PM
All that should work.

Can you post a FLA - sounds like the implementation is at fault.

deefadog
06-29-2003, 08:18 PM
Thanks for the replay Sualdam, I'll have to pull my .fla apart and post a slim version of it! I'll post it tomorrow.

Thanks

Deef

deefadog
07-01-2003, 07:30 AM
Hi Sualdam, here is the zip file! (Flash 5)

When you open up the movie, go to the libary and open up the "- Main Interface" folder and double click on the graphic "1"

You will then see two copies of the "ScrollBarClip". I want to add the: loadVariables (_root.myVar, this);
on each of these.

If you double click one, then double click on the "content" clip and go to the first frame script this is where the loadvariable script is!

Hope you can make sense of this.

Thanks for your help

Deef

Sualdam
07-01-2003, 09:41 AM
Unless anyone else fixes it I'll look when I get home tonight (don't have Flash access at work),

deefadog
07-01-2003, 09:44 AM
Thanks Sualdam, much appreciated, should be like you said, a simple implimentation problem, but I can't get it

Thanks

Deef

btw - If you can get this working, I can put your banner on the site the the script is being used for!

Sualdam
07-01-2003, 11:47 PM
I left this a bit late to get started...

Can I just clarify a few things?

You want to pass a variable to the component that contains the string corresponding to the file to open, yes?

In other words, if myVar = "links1.1.txt" you want to say 'open myVar' and have links1.1.txt open?

This is what I understand from your original post.

In graphic '1' you have two of these components and on the first one you have some onLoad code that includes:content.myVar = "links/links1.1.txt";Before I go too deeply into this, is there some documentation for the component or did you write it yourself? Reason I ask is that the 'content' object isn't in that timeline as far as I can see - so I wondered if this was the format for using the component you had downlaoded/created.

deefadog
07-02-2003, 07:29 AM
Hi, Sualdam. you asked -

"You want to pass a variable to the component that contains the string corresponding to the file to open, yes?

In other words, if myVar = "links1.1.txt" you want to say 'open myVar' and have links1.1.txt open?"

Yes that is correct. The ScrollBarClip movie clip is the clip i want to add to the stage around 40 times, I want to pass a different variable (text file) to each one through this method, so I dont have to have 40 seperate movie clips, which will kill the project on file size!

You asked "Before I go too deeply into this, is there some documentation for the component or did you write it yourself? Reason I ask is that the 'content' object isn't in that timeline as far as I can see - so I wondered if this was the format for using the component you had downlaoded/created."

This movie clip was just made up by myself, so there is no special parameters etc. Yes the "content" is another movie clip with the first, but this is the only way I can get this all to work!

So to recap,on each instance of the movie clip "ScrollBarClip" that is on the stage (just two in this example) I want to send a different variable the the "content" movie clip within it!

Hope that makes sense!

Thanks

Deef

Sualdam
07-02-2003, 09:50 AM
OK

I promise I'll do it early when I get in this evening.

deefadog
07-02-2003, 11:50 AM
Ok, Thankyou Sualdam.

Take care

deef

Sualdam
07-02-2003, 07:24 PM
OK, deefadog, I have some information on this.

I should point out I swore a lot while I was doing it - you haven't half gone for a complicated structure :)

And because I don't fully understand exactly what your movie will do when it is finished I haven't got a neat packaged solution, but an explanation of the various problems.

Step 1 - I went back to basics. I took a copy of your scroller and put it in a blank movie. I set myVar to equal the text string we need and tested it. It didn't work.

The important thing is, it SHOULD work - the fact that it doesn't means there something wrong with the scroller itself. But what?

in frame 1 of your links.1 movie clip (inside the component) you have this code:loadVariables("content.myVar", this);
if (finished == "okay") {
gotoAndStop(10);
}That's wrong. You should be using:loadVariablesNum(<path>.myVar,0); This worked for the test file when I used:loadVariablesNum(_root.myVar, 0);

What I did with your file was go back to the root and give the instance of 'main interface' a clipname (mi). Inside that, I changed the behaviour of the graphic '1' to 'movie clip' and gave it an instance name (gphic1). Then , I opened up the instance of the scrollbar component called 'clip' and in the instance of links1.1 (clip) I changed the first frame code fromloadVariables("content.myVar", this);
if (finished == "okay") {
gotoAndStop(10);
}to:loadVariablesNum(_root.mi.gphic1.clip.myVar, 0);
if (finished == "okay") {
gotoAndStop(10);
}If you test that, it loads the text file properly.

I must say that it doesn't appear to do anything else because there is obviously a bit more debugging to do - but the text file is definitely opened if you ctrl+alt+v to list the variables and then stop the movie to examine the window (you have a bunch of traces filling it up).

I couldn't do anything else because, like I say, I have no idea what you are going to do from here with your movie.

If I were you I'd try to simplify this - it's horrendously complicated.

However, if you can now get it to do what you want then it's your call, of course. :)

I hope this helps. It was a real dog to sort, though.

deefadog
07-02-2003, 08:17 PM
Thanks Sualdam, sorry it was a pain, i know it's a bit of complicate mess, but it does work for me :)

I can't seem to replicate what you have done, could you send me the file?

The end result of it all is that, each 'ScrollBarClip' will load in a different .txt file, the contens of the .txt file are names of sites, with a click count for each! Flash displays these and is update via .php every time a link is clicked. It will be a designers resource in the end.

I'll post you link when/if I get it working so you can see the end result! Maybe then you could suggest an easier way of doing all of this.

The ironic thing is, is that if I had MX, I have been told the scrollbar component can all this in one simple, clean clip :), But I want to get this done and then maybe thing about getting MX!

Thanks again for your help

Deef

Sualdam
07-02-2003, 08:33 PM
The attached file DEFINITELY opens the text file.

I saved in Flash 5 so you should eb able to open it.

deefadog
07-02-2003, 09:04 PM
Hi, well i opened it ok, but I could see the contents of the .txt file appear?

If you look at the example I have included you will see what I am trying to acheive.

Ideally I would like to set the variable on the movie clip labelled 'clip'

Please ignore that the example flashes once (a little bug)

Thanks

Deef

Sualdam
07-02-2003, 09:10 PM
I told you - if you ctrl-alt-v in Flash test mode you can see the text file has loaded.

It HAS loaded, I assure you.

I said that the movie itself doesn't do anything different because it must have other bugs that need resolving.

I haven't a clue what the rest of your movie does - but you do ;)

The variables are loaded into level 0. All you have to do is point to them whenever you use them (get the path right) and that part of the problem is solved.

Test it. Use ctrl-alt-v and prove to yourself that they are loaded. Once you see that they are, you will then be able to sort out why they aren't displayed properly (it has lots to do with that horrendous nesting you have ;) )

deefadog
07-02-2003, 09:56 PM
Yes, I see they are loaded in, but I can't figure out what's happening, If I change the code slightly and replace th '0' with 'this' - loadVariables (_root.mi.gphic1.clip.myVar, this);
if (finished == "okay") {
gotoAndStop (10);
}


The links are loaded in and appear for a few seconds and the they disappear, also If I add a different var to the second instance of the clip, it changes the first instant as-well.
once the .txt appears, this means that flash has sorted out all the variables from the .txt file and has organized them as i wanted! But then the movie clip seems to reload all the time even with the stop command? weired, maybe it's a bug in flash, I don't know?

O well :) I might just duplicate the links.1.1 movie clip and the Scroll clip and have 40 different clips placed in my main movie and add each .txt link to each one, I have tested this and it does work, just means a little bit of hard work!

I'll try more tomorrow, as my brain is scrambled! if you have any ideas, I would appreciate it very much!

Thanks again

Deef

deefadog
07-03-2003, 08:06 AM
I cracked it at last :) Don't you just hate it when you leave something for a while, come back at the problem is staring you straight in the face.

The two problems where this:

Each instance had to have a different name.

The path of the variable should not be specific movie clip named (if you get what I mean) because when you hard code the path in the first instance of the movie clip, the rest will also change and I was back at square one again.

So instead of this -

loadVariables (_root.mi.gphic1.clip.myVar, this);
if (finished == "okay") {
gotoAndStop (10);
}


I used this -

loadVariables(_parent.myVar, this);
if (finished == "okay") {
gotoAndStop(10);
}


Allowing me to use the same movie clip over and over and still change the variable of the .txt file that is loaded in!

Thanks again Sualdam, without your help I would still be stuck, cheers. (and if you want a banner on my site, send one to me)

Deef