170 likes | 295 Views
Advanced Actionscript for Flash 5 by Dr SC Li. Exercise 1 (Creating sound objects). Download and unzip the file sound1-ex.zip Open the library window by clicking Windows > Library
E N D
Exercise 1(Creating sound objects) • Download and unzip the file sound1-ex.zip • Open the library window by clicking Windows > Library • To establish a linkage for the sound symbol, highlight “technoloop” and right click it and choose the “Linkage” option. • To create an action for Frame 1: Highlight Frame 1 and right click it, then choose “Actions”
Exercise 1(Creating sound objects) • Select the “Expert Mode” for the script editor and type in: • function mysound(music){ • soundobject=new Sound(this); • soundobject.attachSound(music); • soundobject.start(0,50); • soundobject.setVolume(100); • } • mysound("soundtrack")
Exercise 1(Creating sound objects) • To select buttons from the Common Libraries, click Windows > Common Libraries > Buttons > (Oval) Button Set • Drag the “Oval-stop” and the “Oval-play” symbols on to the main stage • To create an action for the stop button: highlight and right-click it, then select “Actions”. • On the script editor, type in: • on (press){ • _root.soundobject.stop("soundtrack"); • }
Exercise 1(Creating sound objects) • Save and preview the file.
Exercise 2 (Creating simple controls for sound object) • Download and unzip the file sound2-ex.zip • To select buttons from the Common Libraries, click Windows > Common Libraries > Buttons > (Rectangle) Button Set • Drag two “Grey-button Play” symbols (volume-up; volume-down) on to the main stage • To create actions for the buttons: highlight and right-click it, then select “Actions”.
Exercise 2 (Creating simple controls for sound object) • For the volume-up button, type in: • on (press){ • dummy=_root.soundobject.getVolume; • _root.soundobject.getTransform(); • mySoundTransformObject.ll= • mySoundTransformObject.ll+10; • mySoundTransformObject.rr= • mySoundTransformObject.rr+ 10;
Exercise 2 (Creating simple controls for sound object) • if(mySoundTransformObject.ll <= 100 && mySoundTransformObject.rr <= 100){ • _root.soundobject.setTransform( • mySoundTransformObject); • } • }
Exercise 2 (Creating simple controls for sound object) • For the volume-down button, type in: • on (press){ • dummy=_root.soundobject.getVolume; • _root.soundobject.getTransform(); • mySoundTransformObject.ll= • mySoundTransformObject.ll-10; • mySoundTransformObject.rr= • mySoundTransformObject.rr- 10;
Exercise 2 (Creating simple controls for sound object) • if(mySoundTransformObject.ll >= 0 && mySoundTransformObject.rr >= 0){ • _root.soundobject.setTransform( • mySoundTransformObject); • } • } • Then save and preview the file
Exercise 3(Creating sound preloader) • Download and unzip the file sound3-ex.zip • Create a pre-loading animation while the sound movie clip is being downloaded. • Open the “attachsound.fla” file and insert a key fame for Frame 1. • Drag the preloading symbol onto the stage and name the instance as “preloader”. • Insert an action for the preloader instance:
Exercise 3(Creating sound preloader) • onClipEvent(load){ • loadMovieNum("soundsource3.swf",1) • } • onClipEvent(enterFrame){ • percentloaded=Math.floor( • (_level1.getBytesLoaded()/ • _level1.getBytesTotal())*100); • percentdisplay=percentloaded + "%”;
Exercise 3(Creating sound preloader) • if(percentloaded == 100 && !initialize){ • _level1.mysound("soundtrack") • initialize=true; • _visible=false; • } • } • Save and preview the file
Exercise 4(Creating smart MC movie clip) • Download and unzip the file smart-mc-ex.zip • Open the file “smart-mc.fla”and create a smart MC flash movie clip as shown in http://ited.hkubu.edu.hk/hkbu-ited/session5/actions/smart-mc/smart-mc.swf
Exercise 5(Creating simple scrolling text) • Download and unzip the file scrolltext1-ex.zip • Open the file “scrolltext1.fla”and create a movie clip with scrolling text as shown in http://ited.hkubu.edu.hk/hkbu-ited/session5/actions/scrolltext1/scrolltext1.swf
Exercise 6(Creating auto scrolling text 1) Download and unzip the file scrolltext2-ex.zip • Open the file “scrolltext2.fla”and create a movie clip with auto-scrolling text as shown in http://ited.hkubu.edu.hk/hkbu-ited/session5/actions/scrolltext2/scrolltext2.swf
Exercise 7(Creating auto scrolling text 2) Download and unzip the file scrolltext2-ex.zip • Open the file “scrolltext3.fla”and create a movie clip with auto-scrolling text as shown in http://ited.hkubu.edu.hk/hkbu-ited/session5/actions/scrolltext2/scrolltext3.swf