PDA

View Full Version : syntax problem.........maybe


vosgien
10-06-2002, 11:24 AM
Hi,
I am dynamically loading images into a dynamically created mc,
Originally I used a stack of if/if else statments with setInterval to laod the images automatically one after the after - this worked fine.
I now want to turn all that AS into a short while loop - like this:



function changeimageHolder1(){
var i = 1;
while (i<5){
imageHolder1.loadMovie("image.jpg"+i, i);
i++;

}


}
setInterval(changeimageHolder1,2000);

I get an error message telling me that Flash cannot open image1.jpg, image2.jpg etc etc - so, obviously the images are not loading in, but clearly the code is executing. All the files are located in the same folder

Any ideas on what I have got wrong !!!

Cheers

Vosgien

Billy T
10-06-2002, 11:55 AM
theres a few problems with your code

you can't load a jpg into a depth

your function is loading all 4 images each time it is run...is that what you wanted?

try something like

i=1;
function changeimageHolder1(){
if(i<5){
imageHolder1.loadMovie("image"+i+".jpg");
i++;
}
}
setInterval(changeimageHolder1,2000);

this will load a new image every 2 seconds until it gets to the fourth - is that what you wanted?

vosgien
10-06-2002, 12:20 PM
Hi BillyT,
Thanks, that is exactly what I need ( for now ), I had been pouring over Moocks book, not thinking to set the var before the function.
When I say for now, the above code is the beginning and I am building block by block, so, I will try to get the next two blocks done myself - expect me back later ( lol!!!)

Thanks again

Vosgien

vosgien
10-06-2002, 09:46 PM
Hi,
Back again, as I promised, tho' this time not a syntax prob, more to do with code
First the project came in three parts
1) to load in images one after the other using setInterval as opposed to a button click

2) get the images to go back to the start and load in again

3) this is the difficult bit, at the moment my for loop is set to load in a fixed number of images( see code below), however in the final application I will not know how many images there are - my client wants to put his own images in, and the number will be different on a day to day basis. I have tried using .length & Max. - but to no avail.If I set the for loop to a very large number then there is a blank screen between the last actual image and the first, which is something I want to avoid. I know how to do this when using an array, but have no idea with jpegs as this is pretty new stuff to me.

So to recap, how can I change my code so that when the last image is loaded in, it goes back to "image1.jpeg" without me knowing how many images actually exist.
Does that make sense - I hope so

Thanks again

Vosgien

pom
10-06-2002, 10:46 PM
What do you mean you don't how many images you have? You have to know their names when you load them, don't you? And if you have their names, well, you must be able to know how many there are.

Enfin je me comprends :D

Billy T
10-06-2002, 11:34 PM
OK attcahed is a fairly dodgy solution. Gives an error when running in flash (which was to be expected) but works fine online

cheers

vosgien
10-07-2002, 07:15 AM
Hi BillyT,
No time to test in line but I can see how that works - pretty simple really. One Q. in the last line of the code :

I++; is the captial "I" signifcant or should it read "i++".
Will test later and let you know.

Pom - please re - read the post, my client is going to load in his own images to the site, he will do this on a daily basis and the number of images will vary from day to day - as I will not be involved in this process, I will not know how many images there will be on a day to day basis. If I was involved, I would not want to change the code on a daily basis - therefore, I seek the solution in Flash - and with a little help from the good and kindly people at ActionScript.org - I believe we have finally got there.
perhaps I should also tell you the guy is an estate agent, the images that load in and loop as described above will be photographs of the rooms ( internal) of a house for sale. At any one time he has over a 100 properties on his books that come in all different shapes and sizes...................
Hope that clears it up for you.

btw - I haven't got this job yet - I will be pitching for it today, if succesful it will be my first job in MX and also my very first French client - fingers crossed.

Thanks v. much again

Vosgien

Billy T
10-07-2002, 07:28 AM
yeah should be a "i" but it doesnt seem to make a difference

good luck with the pitch

vosgien
10-07-2002, 02:23 PM
Hi BillyT,
Hope you are still following this thread as I am experiencing serious problems, I think they may be of a tech nature which is beyond my scope. I'll explain:
First of all the code works fine in the test environment - all that happens is that Flash throws up an error message once it has been through the images once saying it cannot find the next file ( that isn't there to be found)
Second it works well in the swf and html pages no problems.

It is not working on line.

At first I published my movie in html and renamed the html doc index.html ( normal )
It wouldn't load in - worse after trying to load it, I couldn't get any other site to load in afterwards - had to shut down my connection and reconnect ????
Tried this in my i.e browser and my AOL browser

Next - tried the same with your file(imageswap.swf & html) and images - same thing.

So then I created an fla ( called index) with a single button that loads in imageswap.swf - exactly the same thing - nothing happens, no images at all. And it is still blocking my browser and I cannot fathom out why.
If you have the time you can see the test here (http://www.test.bcats.com) . You will see a white background with a black circle - this is a button, just click it and imageswap should load in. I will be interested to know if it works on other PC's /browsers.
Any ideas to why this is happening.............

Cheers

Vosgien

vosgien
10-07-2002, 06:18 PM
Hi,
I've now changed the file to the original, this had a set if else if statements in it that load the images at 2 second intervals to a maximum of four - still not working. This was the first file I put together after doing your tute, the text loads in fine, but no images - and still blocking my browser whenever I try the site. I have triple checked the code ( for typo's and stuff ), but it all seems to be fine. So now I'm stuck and can't really work why this happening - I am beginning to wonder if it has anything to do with my PC. If anyone has the time to check and get back to me and let me know what is going on I will be very grateful.
What should happen is this:
When site opens there is a large round black button ( I am not going for any design awards here - just want to get the functionality working OK), click the button, another swf will load with four buttons and a blue text box, to the right of this there should be a black square, above the black square, changing images, only the first two ( square ) buttons are active.
If anyone can let me kknow...........please
Click here (http://www.test.bcats.com)

Cheers

Vosgien

pom
10-07-2002, 09:29 PM
Well, I can see 4 buttons, a text box, a black square "Main house", and another black square "Main house" that changes to "chambre3" and a picture of George W. Bush...

And sorry for my last post, I didn't read your posts thoroughly (?? don't know if this exists). Maybe this will be out of the subject too, but why don't you try to use PHP to get all your image names? If you upload everything in a unique folder, it shouldn't be to hard to get the names, load them into Flash, put them in an Array and then load the jpgs you want, no?

I'm hope I'm not totally out of the line...

pom :(

Billy T
10-08-2002, 12:27 AM
seems to be working fine for me...

Pom's php idea would be a much better solution than my hack-job :)

I can't help you there though sorry

cheers

vosgien
10-08-2002, 04:04 AM
Hi,
yep, it seems to work for everyone but me - can't see why this should be, bit of a bummmer when testing as I can't see anything. I think I'll drop a couple of jpgs onto the site and see if they show up. Can't understand why.

Pom - do like your idea of php, tho' not sure where to go with that one - any pointers be helpful. I've built a couple of mailto forms and one longwinded registration doc with php, so suppose I have a basic understanding of php

BittlyT - thanks for your help man - v. grateful

Vosgien

Billy T
10-08-2002, 04:08 AM
BittlyT - I like that ;)

might be worth posting the php question in the scripting and backend forum

cheer

vosgien
10-08-2002, 04:55 AM
Hi,
here it 6.am, I switched my PC on as soon as I got up 'cos the prob we where discussing was playing on my mind - it is genuine typo - sorry Billy T

Vosgien

vosgien
10-08-2002, 05:07 AM
Ok, final post on this one I think -jpegs do show up in both my AOL and ie browser, however they do not load in dynamcally in my AOL browser, it is working ( the dynamic loading ) in my ie browser but a bit hapazardly - but it works OK.
So it is a browser issue or something to do with my PC. I'm running Windows 2000 proffesional, with IGg memory & bog standard 56k dial up - this is something that is way out of my scope ????

its way way to early, I gotta have that second cup of tea !!!

Cheers again

Vosgien

Billy T
10-08-2002, 07:58 AM
Originally posted by vosgien
...'cos the prob we where discussing was playing on my mind

LOL yeah I know that feeeling...

pom
10-08-2002, 02:23 PM
Did you find the PHP code? Cos I must have it somewhere...

vosgien
10-08-2002, 03:33 PM
Hi Pom,
No, I haven't had the time to look yet, been a bit pre - occupied trying to solve why my PC will not display dynamically loaded images. If you have it and the time to look for it, greatly appreciated

Cheers

Vosgien

pom
10-08-2002, 05:19 PM
There you go. It is based on a very good playlist fla from www.flashxpress.net so it is in French mais je ne pense pas que ça te pose trop de problèmes ;)

To make it work (assuming you're using EasyPHP), just unzip the swf and the php file in www/yourProjectFolder and create a folder called images. Put a few jpegs there. If you test it, you'll see the names of the jpegs appear in the listbox.

Good luck with that project.

pom :D

vosgien
10-08-2002, 05:30 PM
Hi Pom,
Thanks a lot, that will be a big help, I'll test tomorrow but whilst I have this bitty problem with my PC I have to go somewhere else and test........

I saw the guy ( for the project ) last night and am waiting for him to come back to me. It is likely I'll have to do a demo for him - he really wants to do his own site admin ( doesn't wanna pay admin fees to anyone ). He has this canon app on his PC, he takes photo's with a digital, loads them in and they play around in a loop, neg is he has to hold down the ctrl key and click on all the photo's before the loop will play !!

I know he has seen a couple of web agencies that have implied it can't be done. One of these agencies refuses to work in Flash ( stupid). How I know that is another story and for another thread.

Keep ya posted

Thanks again

Vosgien

pom
10-08-2002, 05:45 PM
You show, them, Vosgien... You show them :D

Billy T
10-09-2002, 12:39 AM
howdy

have a look at this - could be a solution (but client will have to alter a text file) - http://www.actionscript.org/forums/showthread.php3?s=&threadid=16927

cheers