Any help with loading .jpgs in Flash MX2004would be awesome!

  • nickadocker
  • Novice
  • Novice
  • nickadocker
  • Posts: 23

Post 3+ Months Ago

Hi! if anyone can help it would be greatly appreciated!
I was wondering how to get this to work in Flash MX 2004:

1. When the HTML page first loads I want "01.jpg" to automatically load in an area of the flash movie
2. Then when user clicks a Forward Button I want it to load "02.jpg"
3. Then if user clicks the Forward Button again it will load the next .jpg (03.jpg, 04.jpg, 05.jpg, and so on)
4. If user wishes to go back and clicks the Previous Button it will go back one .jpg
5. Also in load area if no button is clicked, I want it to automatically load the next .jpg after 40 seconds and to cycle through changing to the next .jpg every 40 seconds.

Any help/advice would be extremely appreciated!
Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • voycieh
  • Novice
  • Novice
  • User avatar
  • Posts: 24
  • Loc: Poland, Warsaw

Post 3+ Months Ago

Hi,

You need to put all your images into first frame. It is good to distribute them to different layer. Change them to movie clips. Set their instance names: "first", "second" and so on... (You can't use 01, 02 ,03 - instance name doesn't accept numbers without the letters).
Create one more layer for actionscript.
You need to hide the images for start.

to first frame put this actionscript:

first._visible = false;
second._visible = false;
and so on...

create buttons with action script:

on (press) {

_root.first._visible = true;
_root.first.gotoAndPlay(1);

_root.second._visible = false;
_root.third._visible = false;

//and so on...

}

Have fun! :)

Marcin
  • roarmeow
  • Professor
  • Professor
  • User avatar
  • Posts: 861
  • Loc: BKNY

Post 3+ Months Ago

Another option is to have the images load externally.
voycieh's code will work for sure, but I think this'll end up being less work and will allow you to switch out any of the images without having to mess with the flash document itself.

You can set up a folder called "photos" with the jpgs saved into it.
Make sure that the photos are names with the pure number... i.e. "1.jpg, 2.jpg, 3.jpg... 15.jpg, 16.jpg, 17.jpg, etc." as opposed to having "01.jpg." 'cos that'll cause a little issue.

We're going to assume you have 20 images, cool?

Then you want to set up your timeline like this.
Wherever you want the images to load, insert an empty movieclip (you can call it "empty," how about that) with instance name "holder."
On frame one, in the actions layer, write:
Code: [ Select ]
var i=0;

Then make two buttons... in the actions of the forward button, put
Code: [ Select ]
on(release){gotoAndPlay("forward");}

and in the actions of the backward button, put
Code: [ Select ]
on(release){gotoAndPlay("backward");}

I'm assuming you've got your framerate set to 12 frames/second (pretty standard, I think).
Label frame two "forward" and make it 480 frames long (you know 40 seconds is an awfully long time). On the next frame (after the 480 frames of "forward"), put in a keyframe and label the section "backward"... make it 480 frames long as well.
On the first frame of the "forward" section, put the script
Code: [ Select ]
i++;
if(i>20){i=1;
loadMovie(i+".jpg", "holder");
}else{
loadMovie(i+".jpg", "holder");}
  1. i++;
  2. if(i>20){i=1;
  3. loadMovie(i+".jpg", "holder");
  4. }else{
  5. loadMovie(i+".jpg", "holder");}

On the first frame of the "backward" section, put the script
Code: [ Select ]
i--;
if(i<1){i=20;
loadMovie(i+".jpg", "holder");
}else{
loadMovie(i+".jpg", "holder");}
  1. i--;
  2. if(i<1){i=20;
  3. loadMovie(i+".jpg", "holder");
  4. }else{
  5. loadMovie(i+".jpg", "holder");}

On the last frame of BOTH the "forward" and "backward" sections, insert a keyframe with the action
Code: [ Select ]
gotoAndPlay("forward");


What this is going to do is make it so that when you press the forward button, it cycles to the next "up" number image and when you press the backward button, it cycles to the next "down" number image. When you press nothing, it goes "up" after 40 seconds (a long, long time for someone like me with ADHD.)

The variable "i", which is initialized at the beginning (i=0), is the determinant of which image it's going to load.

I've also set if/else statements up so that, if, when moving forward, the number is greater than the number of images you've got, it'll cycle back down to image 1.jpg and if, when moving backward, the number drops below 1, it cycles back up to image 20.jpg.

If you've got a different number than 20 images, just change that 20 to whatever that number is.

peace out,
puck
  • nickadocker
  • Novice
  • Novice
  • nickadocker
  • Posts: 23

Post 3+ Months Ago

Wow! you totally saved me, thanks so much for your help puck (roarmeow)! i appreciate your help too, voycieh, but puck told me exactly what i wanted to know.

you wrote the directions so simply to understand and i just followed through and it worked perfect! i decided to subsitute the .jpgs with .swf files instead so that i could animate the .jpgs to fade in when they load, and that worked too. thanks again for your help puck, your a bad ass!

nickadocker.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.