Flash: Photo Browser V1.0

Source: Internet
Author: User
Tags abs count execution rar reset
The browser puts the photo in the same directory as Flash, and the photo is named 0.jpg,1.jpg,2.jpg,3.jpg,4.jpg,5.jpg .... To Infinity (0.jpg is the cover of the album). Then turn on flash to see the effect.
Note: Use the FLASH8 player to watch properly
Album Test.rar
SOURCE files. rar
Source File Spindle Code:
Frame 1: Mainly to limit the stage, full screen
Frame 2: Load cover picture, when pressing the left button to use a Enterframe event to hide the cover, and after the action is completed to the next frame, that is, the normal stage of the main state
Frame 3: Back up the thumbnail, initializing some of the variables
Frame 4: The body frame. Initialization completes, then at this frame stop, most of the time the stage screen is displayed in this frame
Frame 5: Motion transition frame. If you want to load the next few pictures, jump to frame 3, reload the thumbnail, and then stop at frame 4, echoing the mouse event
Frame 1:
Fscommand ("fullscreen", true);/full Screen
Stop ();
Initializes the drawing state and draws a rectangle of the screen size, using it to mask the stage so that the part outside the stage is not visible, making the picture more perfect.
Clear (); Class
Draw a rectangle
Createemptymovieclip ("Line0", 999);
With (LINE0) {
LineStyle (1, 0X66FFFF, 100);
Beginfill (0xff6600, 100);
MoveTo (0,0);
LineTo (stage.width,0);
LineTo (Stage.width,stage.height);
LineTo (0,stage.height);
Endfill (); }
To mask the stage with a rectangle
_root.setmask (_ROOT.LINE0);


Click the mouse to continue the next screen
_root.onmousedown = function () {
Play ();} Frame 2:
Stop ();
var pic_count:number = 0;//This variable is used to record the count of thumbnails of the current display picture, is to show 1,2,3,4,5 Zhang, or 6,7,8,9,10 Zhang, or ...

----------Set the color-changing method for all movie clips, it needs to be used in conjunction with Onenterframe
MovieClip.prototype.setBrightOffset = function (offset) {
var this = new Color (this);
var trans = This.gettransform ();
With (trans) {
RB = Gb=bb=offset;
}
This.settransform (trans);
};

The picture on the cover shows, that is, the second screen, called "Theloader" to display, the following thumbnail is also used to load the video clip
_root.attachmovie ("Theloader", "Theloader0", 1);
Theloader0.canplay = true;//picture after loading, do not place the action, this value as a unified command (the back thumbnail is to use this value to control a sheet out)
_root.theloader0.num = 0;//Load the control variable of the first few graphs, then load the cover, that is, "0.jpg"
_root.theloader0.howwide = height limit of pictures displayed by stage.height+10;//
_root.theloader0._x = 0;
_root.theloader0._y = 0;
Picture after loading on their own fade action, by the Enterframe event plus film clip color properties to achieve, equal to 255 value when the picture is white, and the implementation of jump to the next screen
j = 1;
_root.onenterframe = function () {
if (j<255) {
_root.theloader0._x = (stage.width-_root.theloader0.loadit_mc._width)/2;//displays the picture in the middle of the screen
_root.theloader0._y = (stage.height-_root.theloader0.loadit_mc._height)/2;//displays the picture in the middle of the screen
_root.theloader0.setbrightoffset (j);
J + + j/6;//for display acceleration effect, gradually accelerated
else {//Remove discoloration action, to next screen
Delete _root.onenterframe;
Play ();
}
}; Frame 3:
Removemovieclip ("Theloader0");/delete Previous Frame 4:
Stop ();
var howmany_x:number = 5;//thumbnail shows 5 sheets at a time
var top_position:number = 20;//The coordinate value of the thumbnail in high and low control
For (i=0 i_root.attachmovie ("Theloader", "Theloader" +i, 100*i);/load
_root["Theloader" +i].num = pic_count+i+1;//tells each thumbnail clip should load the first few JPG
_root["Theloader" +i].howwide = 65;//Control the height value of the picture (x,y value of scale is uniformly set, the height set is equal to the limit width)
_root["Theloader" +i]._x = top_position+stage.width/howmany_x*i*1.35-10*i*i;//thumbnail x coordinate position
Trace (_root["Theloader" +i]._x);
_root["Theloader" +i]._y = 20*math.sin (360+0.3*i);//Let the Y-value of the thumbnail curve distribute
_root["Theloader" +i]._xscale = _root["Theloader" +i]._yscale=110-100/howmany_x*i;//the smaller the thumbnail
_root["Theloader" +i]._rotation = i*7;//adds a little rotation to each thumbnail
}
_root.onmousedown = function () {//The mouse presses the response on the stage, if the mouse is the point on the thumbnail to perform the stage master replace operation
For (i=0 iif (_root["Theloader" +i].hittest (_root._xmouse, _root._ymouse)) {
_root.getit.num = pic_count+i+1;//the picture number corresponding to the thumbnail at this time
Trace (_root.getit.thenum);
_root.getit.gotoandplay (2);//"Getit" Reload picture
break;//only one thumbnail is clicked at the same time, so as long as the thumbnail is clicked, exit the For loop
}
}
};

The time function that lets the thumbnails come out of each other only executes each thumbnail action when Canplay is set to true. Thumbnail action execution checks this value.
K =-1;
var countit = setinterval (function () {
if (kk++;
_root["Theloader" +k].canplay = true;//starts the next thumbnail action every 100 milliseconds
} else {
Clearinterval (countit);//thumbnail after loading delete timer function
}
}, 100); Frame 5:
gotoAndPlay ("reload"); If the button on the stage for the five picture (the largest button) is clicked, download the next five thumbnails again, and the small button on the side will load the first five pictures and attach it separately:
The interactive response event description of the main figure:
Divided into left Key press, release two major events.
(A function on the "Getit" time spindle, the following "This" refers to the larger image of this video clip):
Left mouse button pressed
This.onmousedown = function () {//If the mouse is pressed on a larger image and its position coordinates are recorded, the larger image activates the drag function at this time
if (This.hittest (_root._xmouse, _root._ymouse)) {
The_xmouse1 = _root._xmouse;//Record x value
The_ymouse1 = _root._ymouse;//Record Y-value
This.startdrag (lock), or can drag, here without judgment, as long as the press on the drag. Because anyway, if the double-click Action, drag distance will not be big.
}
};


Left mouse button loosened
This.onmouseup = function (a) {
This.stopdrag ()//Stop dragging
if (This.hittest (_root._xmouse, _root._ymouse)) {
The_xmouse2 = _root._xmouse;//record x value after stopping
The_ymouse2 = _root._ymouse;//Record Y-value after stopping
The_x = this._x;//Remember the coordinates of the current large graph
The_y = this._y;//Remember the coordinates of the current large graph
Count = Math.sqrt (THE_XMOUSE1-THE_XMOUSE2) +math.sqrt (THE_YMOUSE1-THE_YMOUSE2);//Use two-point distance formula to calculate the distance between Mouse press and release
//------------
DoubleClick = false;//value of the monitor variable that initializes the double-click
With the system with the GetTime function to detect the interval of two mouse press action, if the time is very fast (less than 400 milliseconds) to think that the current did a double click left action
var currenttime:number = new Date (). GetTime ();
With a
if (_global.lasttime = = undefined) {//Last left button pressed time, no record of this time pressed
Initialize _global.lasttime
_global.lasttime = currenttime;
else if (currenttime-_global.lasttime<400) {//Take this time as compared to the last pressed time, and change the double-click Monitor variable to true at less than 400ms
DoubleClick = true;
}
_global.lasttime = Currenttime;//lasttime as a global variable, so the value does not disappear with the function, and is updated every time the function executes
If you double-click the event confirmation, and the distance value of the two action is less than 4 (the description is not to drag the larger picture, or drag the distance will generally be larger than 4), then perform a double click response
if (_root.hitbut!= true && count<4) {//If this action does not occur on the action of the thumbnail (but on the larger image) and the distance is a double click the condition is set
if (DoubleClick = = true) {//time is also more reasonable, that is double-click, wrong, ah ~
Loadit_mc._xscale = loadit_mc._yscale=this.a;//the size of the reply when it was just loaded
this._x = (stage.width-loadit_mc._width)/2;//Reset, placed in the middle of the bottom margin
This._y = (stage.height-loadit_mc._height)/2;//Reset, placed in the middle of the bottom margin
Redrawit ()///border with picture
else {//In the above judgment, if it is not a double click (longer than the double-click), it must be clicked, then the execution put big, every 10%, don't forget to enlarge the position correction
Loadit_mc._xscale + 10;
Loadit_mc._yscale + 10;
this._x = This._x-math.abs (the_x-the_xmouse2) *.109;
this._y = This._y-math.abs (the_y-the_ymouse2) *.109;
Redrawit ();
}
} else {
_root.hitbut = false;//above is not the case, the reset value of the lower
}
}
}; Hope to be helpful to the beginners of the code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.