Link:INB Home|INB English| INB русский язык|INB العربية|INB Türkiye|INB فارسی|INB Español|INB Français|INB Português|INB Deutsch|INB 國語|INB 中文|INB 日本语|INB 한국어|INB ภาษาไทย|INB tiếng Việt||[FL]Flash Tutorial Displaying Pictures According to the Cursor Positio
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum

Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, Permanent name: inb-english.forumotion.com


You are not connected. Please login or register

《《《《《《《上一页INBforum   Go down

上一页INBforum》》》》》》》View previous topic View next topic Go down  Message [Page 1 of 1]

1[FL]Flash Tutorial Displaying Pictures According to the Cursor Positio Empty [FL]Flash Tutorial Displaying Pictures According to the Cursor Positio Wed Sep 22, 2010 10:58 am

Admin

Admin
Admin
1. Create a new flash file (Actionscript 3.0) and save it as src.fla.
2. Create a movie clip and put each one of your picture in a new frame. Set its registration point to the top left and give it an instance name of “pic_mc”.
3. Create an “actions” layer and with its first frame selected open the actions panel.
First add a stop() to the “pic_mc” movie clip to prevent if from looping through its frames and add ROLL_OVER and ROLL_OUT event listeners.view source

print?


1pic_mc.stop();

2pic_mc.addEventListener(MouseEvent.ROLL_OVER, overHandler);

3pic_mc.addEventListener(MouseEvent.ROLL_OUT, outHandler);



4. In the overHandler() function, we add a MOUSE_MOVE event listener that will call the changeFrame() function when the event will be triggered. In the changeFrame() function, we set the current frame of “pic_mc” according to the mouse position on the movie clip.view source

print?


1function overHandler(e:Event):void {

2 pic_mc.addEventListener(MouseEvent.MOUSE_MOVE,changeFrame);

3}

4

5function changeFrame(e:Event):void {

6 var frame : uint = Math.ceil(pic_mc.totalFrames * pic_mc.mouseX / pic_mc.width);

7 pic_mc.gotoAndStop(frame);

8}



5. In the outHandler() function, we simply remove the MOUSE_MOVE listener.view source

print?


1function outHandler(e:Event):void {

2 pic_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeFrame);

3}



6. Here’s the final code, test your movie to see it in action.view source

print?


01pic_mc.stop();

02pic_mc.addEventListener(MouseEvent.ROLL_OVER, overHandler);

03pic_mc.addEventListener(MouseEvent.ROLL_OUT, outHandler);

04

05function overHandler(e:Event):void {

06 pic_mc.addEventListener(MouseEvent.MOUSE_MOVE,changeFrame);

07}

08

09function changeFrame(e:Event):void {

10 var frame : uint = Math.ceil(pic_mc.totalFrames * pic_mc.mouseX / pic_mc.width);

11 pic_mc.gotoAndStop(frame);

12}

13

14function outHandler(e:Event):void {

15 pic_mc.removeEventListener(MouseEvent.MOUSE_MOVE, changeFrame);

16}
]

http://eng.inbforum.com

上一页INBforum   Go down

上一页INBforumView previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

Copyright ©2009-2016 LTD Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

IT:SINGLESERVGoogle谷歌翻译TranslateFORUMSOFTLAYERGoogle谷歌广告联盟AdSenseAsia

 

Create a forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com