actionscript 3 - SharedObject, clicking every users button -
i have imageslider.swf , has 2 buttons. nextbtn pass next image , prevbtn go previous image. swf slide share app. want when presenter press of button, every slide show change( on every clients). happen on internet.not on localnetwork.
import flash.display.loader; import flash.net.urlrequest; import flash.events.event; import flash.events.mouseevent; import fl.transitions.tween; import fl.transitions.easing.*; import flash.filters.glowfilter; import flash.filters.dropshadowfilter; import flash.utils.timer; import flash.events.timerevent; //*****************declaring variables*****************************// //the array has picture labels var myarray:array = ["barbecued chicken", "bread & rolls", "burger", "chicken chilly" , "awesome fish"]; var myglow:glowfilter = new glowfilter(0xffffff,1,10,10,255);// saving glow var myshadow:dropshadowfilter = new dropshadowfilter(6);// saving shadow applied later var totalimages=11; var imagenumber=1; var mytimer:timer = new timer(4000);// 4 second timer var myloader:loader = new loader(); //************fetching pictures lying in external folder********************// var myrequest:urlrequest = new urlrequest("images/"+imagenumber+".jpg"); myloader.load(myrequest); addchildat(myloader,1);// added under buttons layer on texture //************centering pics , applying border , drop shadow****************// myloader.contentloaderinfo.addeventlistener(event.init, getimageinfo); function getimageinfo(event:event){ var imgx=(stage.stagewidth- myloader.width)/2; var imgy=(stage.stageheight- myloader.height)/2; myloader.x=imgx; myloader.y = imgy;// lines 37,38,39 & 40 centering loader formulae myloader.filters = [myglow, myshadow];// adding white color glow / grey shadow var mytween:tween = new tween(myloader, "alpha", none.easenone, 0,1,2,true);//apply fade in } //**************automatic progression ********************************// mytimer.addeventlistener(timerevent.timer, autoadvance); function autoadvance(event:timerevent){ if(imagenumber<totalimages){imagenumber++} else (imagenumber=1); reload(); } mytimer.start(); //**************going next image********************************// rightbutton.addeventlistener(mouseevent.click, nextimage); function nextimage(event:mouseevent){ if(imagenumber<totalimages){imagenumber++} else (imagenumber=1); reload(); } //**************going previous image********************************// leftbutton.addeventlistener(mouseevent.click, previousimage); function previousimage(event:mouseevent){ if(imagenumber>1){imagenumber--} else (imagenumber=totalimages); reload(); } //*****************controlling thumbnails****************************// t1.addeventlistener(mouseevent.click, thumbhandler); t2.addeventlistener(mouseevent.click, thumbhandler); t3.addeventlistener(mouseevent.click, thumbhandler); t4.addeventlistener(mouseevent.click, thumbhandler); t5.addeventlistener(mouseevent.click, thumbhandler); function thumbhandler(event:mouseevent){ if(event.currenttarget==t1){imagenumber=1} else if(event.currenttarget==t2){imagenumber=2} else if(event.currenttarget==t3){imagenumber=3} else if(event.currenttarget==t4){imagenumber=4} else{imagenumber=5} reload(); } //**************replacing old image new ********************************// function reload(){ removechild(myloader); myrequest= new urlrequest("images/"+imagenumber+".jpg"); myloader.load(myrequest); addchildat(myloader,1); //changing label , tweening 3 mylabel.picturelabel.text = myarray[imagenumber-1]; var tweenlabel:tween = new tween(mylabel, "rotation", bounce.easeout, 360, 390,1,true) } //***************playing music placed externally*******************************// var my_sound:sound = new sound(); my_sound.load(new urlrequest("soothing_music.mp3")); var my_channel:soundchannel = new soundchannel(); my_channel = my_sound.play(0,9999);// 9999 number of times music should loop. //*********detecting if mouse on stage stop/resume timer***********// //stopping timer. stage.addeventlistener(mouseevent.mouse_move, stop_the_timer); function stop_the_timer(event:mouseevent){ mytimer.stop(); } //resume timer stage.addeventlistener(event.mouse_leave, resumetimer); function resumetimer(event:event){ mytimer.start(); }
Comments
Post a Comment