PDA

View Full Version : Help to load picture on given frame



dribblit
August 19th, 2005, 03:06 AM
need some real help here,

I'm trying to monitor the currentframe of a movie so that when it goes to a specific frame, its loads the corresponding a picture out of an array dynamically using XML.

I think I have most of that loading part sorted out, the issue i think comes when i am looping code on the movieclip. I'm trying to set it up in such a way that if the currentframe remains the same, that it does nothing...this is so that it does not repeatedly load the same image over and over if the frame does not change.

I only want an image to load if the current frame has changed. I realise an example is in order so i posted the .fla and the .xml files in a zip file.

[ a rookie here like he bit off more than he can chew :) please help!! ]

dribblit
August 19th, 2005, 11:36 AM
anyone? :S

dribblit
August 19th, 2005, 04:13 PM
still heh

dribblit
August 19th, 2005, 06:20 PM
:whistle:

dribblit
August 19th, 2005, 11:28 PM
:puzzled:

freeskier89
August 20th, 2005, 12:10 AM
Do you want something like:
//on mc
onClipEvent(load){
lastframe=1
}
onClipEvent(enterFrame){
if(this._currentframe!=lastframe){
_root.loadmovie("JpgImage");
}
lastframe=this._currentframe
}

dribblit
August 20th, 2005, 11:19 AM
yep that is it...i think i have generally the same thing...



//display the corresponding xml picture according to the corresponding frame

//previousFrame=1; // the last frame visited
tempFrame=_root._currentframe; // the frame currently at
//trace(tempFrame)

_root.onEnterFrame=function()
{
if (tempFrame != _root._currentFrame)// then this means that the current frame has moved
{
previousFrame=tempFrame;
tempFrame=_root._currentFrame;
switch (_root._currentFrame)
{
case 1 :
trace("1st frame");
//trace("the current frame is:")
//trace(_root._currentFrame);
loadImage(_root._currentFrame);
break;
case 2 :
trace("2nd frame");
loadImage(_root._currentFrame);
break;
default :
trace("default frame");
defaultImage();
} //end switch
}
else // the current frame hasn't moved so do nothing
{
//trace("do nothing");
}
}


the problem comes when i call the function to load the picture....



function loadImage(pFrame:Number) {
if (loaded == filesize) {
trace("loading image...")
picture._alpha = 0;
trace(pFrame);
picture.loadMovie(image[pFrame], 1); // the image just would not load! :$
trace("finished loading image...")
// desc_txt.text = description[0];
// picture_num();
}
}

the picture.loadMovie(image[pFrame],1) line would not load the image...everything gets passed to the function correctly, all the traces around the function are correct..but the picture just would not load! :(

dribblit
August 21st, 2005, 12:35 AM
y won't it load?

dribblit
August 21st, 2005, 12:53 PM
:-/

dribblit
August 22nd, 2005, 09:14 AM
ain givin up

x.vector
August 22nd, 2005, 09:28 AM
hi,

i think your problem is that you give the "picture" movieclip an
_alpha value of 0.

in your 'loadImage' function change the line ...
'picture._alpha = 0;' to 'picture._alpha += 10;'
or 'picture._alpha = true;'

that should do the trick

freeskier89
August 22nd, 2005, 11:33 AM
as far as I know you cant set the _alpha property to a boolean value, so instead of _alpha=true it should be _alpha=100. Visibility is the boolean variable.

dribblit
August 22nd, 2005, 05:28 PM
thanx for replying...changing the alpha does nothing tho, it still doesn't work...i got this code straight from kirupa's xml photogallery...i just basically take that code...apply the frame listener code like what i got from freeskier89 to a higher layer MC and everything else works except that the picture does not load. i know for sure that the problem is something simple, like i have something wrong in the .fla somewhere and, being as i am new to flash it is very likely that that is the case.

freeskier89
August 22nd, 2005, 05:40 PM
in your loadImage function try tracing image[pFrame]... Does it result in undefined?

dribblit
August 22nd, 2005, 06:51 PM
naw its legit...i get the path to the .jpg file.

do u think it has something to do with the loop being there? Coz once i apply your script or mine to an MC, kirupa's photogallery doesn't work at all and to me it still should because all the MC is doing it listening to the currentframe so this just has me miffed.

freeskier89
August 22nd, 2005, 07:23 PM
Ill just have to look at your fla sometime... currently this comp doesnt have flash , but I can have access to it in a few days. If thats not to much of a delay, can you post it in mx format?

dribblit
August 22nd, 2005, 09:19 PM
sure thnx..its very urgent actually :) but i guess beggars can't be choosers yuh know? :D

i was messin wid the .fla so now its actually showing some photos but they keep loading the first one now...least its further along than before :smirk:

i posted the most recent .fla in MX format like you asked. thnx again.

freeskier89
August 22nd, 2005, 10:57 PM
thanks for the zip. Unfortunatly the soonest I can fix it will be friday :( . Hope this will be fine. What is this for by the way?

dribblit
August 23rd, 2005, 10:45 AM
its for my summer research project for university...i'm trying to do a 3D model of the campus in shockwave...the reason i need the flash to be set up this way is that i have a 3D library of behaviours for shockwave that i'm using and the way it communicates with flash is by going to a specific frame in the flash movie.

So my idea was to have the flash movie always listening to when the frame changes, and then based on the current frame, call up the right picture in the picture array. Who knew that something so simple could be so tough to implement? :-/ The deadline for the report is this thurs but i think that i still have until next week to get the software finished. This is like the last thing that i have to do software wise...that and gettin an XML menu to be scrollable :S but i guess that's a whole other issue.

thanx for the help...and what ever you can get done will be fine.

If anyone else can help me a bit sooner that would be great also. :)

dribblit
August 23rd, 2005, 06:58 PM
n e 1?

freeskier89
August 23rd, 2005, 07:20 PM
talking like that will not get "n e 1" to help. If you want someone to spend their time helping you, you might as well show that you can type actual english.

dribblit
August 23rd, 2005, 09:55 PM
lol...ok...I don't even know how much more English I can type...that was just to let people know that I am still around, but i hear you loud and clear "n e way" sry...anyway :)

dribblit
August 26th, 2005, 02:57 AM
freeskier89, whatever you can come up with would be fine.

thanks.

freeskier89
August 27th, 2005, 01:06 PM
Here it is. I just totally redid it. There was a LOT of unnecessary code in there. I know that graphically it looks like crap now, but thats just a matter of you making it fit your needs. To go to a different image use gotoAndStop(frame>=2) and so on. Hopefully this will help, it still needs some minor work though.

dribblit
August 28th, 2005, 02:16 AM
thanx!! freeskier89! top job there! that is exactly what i wanted. I even wanted it minus all the graphical stuff as you have given me, because i want to do my own. when i'm through i'll post it here and show you what you've laid the ground work for. :D thanx again!

freeskier89
August 28th, 2005, 02:36 AM
few :sigh of relief:... Your welcome! I was hoping that's what you wanted. Feel free to pm me if you have any more dilemmas with it. Modifying Kirupa's was just twice as much work as just pulling the barebones out of it and making a new one ;)

Glad to help,
-freeskier89