Picture Viewer File

  • IAteYouItTastedSoNice
  • Newbie
  • Newbie
  • IAteYouItTastedSoNice
  • Posts: 5

Post 3+ Months Ago

what is the actionscript, for when a image (button) is pressed that image but larger appears in the center?

like

if i have all my images loaded into my library thumbs and larger ones, and all the thumbs are around the border, if i clikc one, i want that one to be bigger in the middle
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

this supose u to have in the library, checked for export,
thumb1, thumb2 , thumb3 ....
and image1, image2, image3 ....
Code: [ Select ]
this.createEmptyMovieClip("thumbs", 0);
this.createEmptyMovieClip("bigImg", 1);
var crtThumbMC;
var crtX = 10;
var crtY = 10;
for (iIndex = 0; iIndex < thumbImgCount; iIndex++)
{
  crtThumbMC = thumbs.attachMovie("thumb"+iIndex, "stage_thumb"+iIndex, iIndex);
  crtThumbMC._x = crtX;
  crtThumbMC._y = crtY;
  crtThumbMC .onPress = function()
  {
    bigImg.attachMovie("image"+iIndex, "img", 0);
    bigImg._x = (Stage.width - bigImg._width)/2;
    bigImg._y = (Stage.height - bigImg._height)/2;
  }
  crtX += 50;
  if (crtX + 50 > Stage.width)
  {
    crtY += 50; crtX = 10;
  }
}
  1. this.createEmptyMovieClip("thumbs", 0);
  2. this.createEmptyMovieClip("bigImg", 1);
  3. var crtThumbMC;
  4. var crtX = 10;
  5. var crtY = 10;
  6. for (iIndex = 0; iIndex < thumbImgCount; iIndex++)
  7. {
  8.   crtThumbMC = thumbs.attachMovie("thumb"+iIndex, "stage_thumb"+iIndex, iIndex);
  9.   crtThumbMC._x = crtX;
  10.   crtThumbMC._y = crtY;
  11.   crtThumbMC .onPress = function()
  12.   {
  13.     bigImg.attachMovie("image"+iIndex, "img", 0);
  14.     bigImg._x = (Stage.width - bigImg._width)/2;
  15.     bigImg._y = (Stage.height - bigImg._height)/2;
  16.   }
  17.   crtX += 50;
  18.   if (crtX + 50 > Stage.width)
  19.   {
  20.     crtY += 50; crtX = 10;
  21.   }
  22. }
  • IAteYouItTastedSoNice
  • Newbie
  • Newbie
  • IAteYouItTastedSoNice
  • Posts: 5

Post 3+ Months Ago

not exactly sure what you mean....
but thanks for the reply.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

uhhh ... then it means
1) u dont know actionscript
2) u may or may not try to understand the code above
  • IAteYouItTastedSoNice
  • Newbie
  • Newbie
  • IAteYouItTastedSoNice
  • Posts: 5

Post 3+ Months Ago

....i dont think you understand how i have it layed out, cuz i know there is an easier way
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

ok ... you do it easier than my way and then share your idea.
  • IAteYouItTastedSoNice
  • Newbie
  • Newbie
  • IAteYouItTastedSoNice
  • Posts: 5

Post 3+ Months Ago

okay
so i have 10 pictures, i ahve them all duplicated, so theres 2 of each but one is small a thumb, and one is a larger picture.....

the thumbs are present the whole time, so i made them into buttons, now im wondering, without all your thumb etc. code if theres a way to make it so that when i click a thumb the larger version appears in the middle, its like loading a movieclip or something, i jsut dont know the exact code
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

geee, now i wonder what for is the code i wrote above.
probably it`s a program that calculates the probablities to throw a rock through a circle, from 50 feets distance, knowing that the rock weight is 200 grams, it's radius is 4 cm, and the radius of the circle is 50 cm.
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

IceCold wrote:
geee, now i wonder what for is the code i wrote above.
probably it`s a program that calculates the probablities to throw a rock through a circle, from 50 feets distance, knowing that the rock weight is 200 grams, it's radius is 4 cm, and the radius of the circle is 50 cm.



:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:

okay
lemme try explaining ... no worries ... everyone started from Zero ...


this create empty movieclips on the stage , one for thr big images & one for the small ones since they'll be dynamically attached from library ...
Code: [ Select ]

this.createEmptyMovieClip("thumbs", 0);

this.createEmptyMovieClip("bigImg", 1);
  1. this.createEmptyMovieClip("thumbs", 0);
  2. this.createEmptyMovieClip("bigImg", 1);


declared without datatyping but will be a referer to the attached Movies
Code: [ Select ]
var crtThumbMC;




the X & Y positions of the attached thumbs

Code: [ Select ]
var crtX = 10;

var crtY = 10;
  1. var crtX = 10;
  2. var crtY = 10;


loooooping

Code: [ Select ]
for (iIndex = 0; iIndex < thumbImgCount; iIndex++)

{
  1. for (iIndex = 0; iIndex < thumbImgCount; iIndex++)
  2. {


Look Ma , the variable we declared up there , = attach Movie(oldname,newname,depth)
Code: [ Select ]
  crtThumbMC = thumbs.attachMovie("thumb"+iIndex, "stage_thumb"+iIndex, iIndex);

  crtThumbMC._x = crtX;

  crtThumbMC._y = crtY;
  1.   crtThumbMC = thumbs.attachMovie("thumb"+iIndex, "stage_thumb"+iIndex, iIndex);
  2.   crtThumbMC._x = crtX;
  3.   crtThumbMC._y = crtY;


function 2 show big images in the center in the empty movieClip we first declared ...

Code: [ Select ]
crtThumbMC .onPress = function()

  {

    bigImg.attachMovie("image"+iIndex, "img", 0);

    bigImg._x = (Stage.width - bigImg._width)/2;

    bigImg._y = (Stage.height - bigImg._height)/2;

  }
  1. crtThumbMC .onPress = function()
  2.   {
  3.     bigImg.attachMovie("image"+iIndex, "img", 0);
  4.     bigImg._x = (Stage.width - bigImg._width)/2;
  5.     bigImg._y = (Stage.height - bigImg._height)/2;
  6.   }


now create next thumb ... increase its X so it sits next to the prev thumbnail otherwise they'll over lap ..
now check if you have reached maximum Raw for then push down the Y it'll be on the next line and reset the x position to 10 ....



Code: [ Select ]
crtX += 50;

  if (crtX + 50 > Stage.width)

  {

    crtY += 50; crtX = 10;

  }

}
  1. crtX += 50;
  2.   if (crtX + 50 > Stage.width)
  3.   {
  4.     crtY += 50; crtX = 10;
  5.   }
  6. }




if you cant understand the above , then you should learn the basics of actionscript ... get a solid background ...


u can do it easier by placing in the thumbnail manually and give them instance names ...
like thumb1 thumb2

now go to your actions & rite this * dont assign it ON a button .



Code: [ Select ]
this.createEmptyMovieClip("bigImg", 999);

thumb1.onRelease = function() {


    bigImg.attachMovie("image"+iIndex, "img", 0);

    bigImg._x = (Stage.width - bigImg._width)/2;

    bigImg._y = (Stage.height - bigImg._height)/2;
}
  1. this.createEmptyMovieClip("bigImg", 999);
  2. thumb1.onRelease = function() {
  3.     bigImg.attachMovie("image"+iIndex, "img", 0);
  4.     bigImg._x = (Stage.width - bigImg._width)/2;
  5.     bigImg._y = (Stage.height - bigImg._height)/2;
  6. }



if you dont understand that either ... you should learn more about :

creating empty movieClips
loading images from library durning runTime .
positioning ...

Post Information

  • Total Posts in this topic: 9 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.