flash - SoundTransform with actionscript VPAID -
i have problem actionscript 3
i doing performances in vpaid. can not create method advolume. have compile error
1067: implicit coercion of value of type soundtransform unrelated type flash.media:soundtransform.
1119: access of possibly undefined property volume through reference static type soundtransform.
this function advolume
import flash.display.*; import flash.text.textfield; import flash.text.textformat; import flash.text.textfieldautosize; import flash.net.netconnection; import flash.net.netstream; import flash.display.movieclip; import flash.media.video; import flash.events.*; import flash.net.*; import flash.media.soundtransform; public class fakead extends sprite { private var tw:twitter; private var fb:facebook; private var im:images; public var nc:netconnection; public var ns:netstream; private var video:video; private var adsoundtransform:soundtransform; public function fakead(linecolor:number, fillcolor:number, label:string) { function asyncerrorhandler(event:asyncerrorevent):void { } nc = new netconnection(); nc.connect(null); ns = new netstream(nc); //ns.addeventlistener(asyncerrorevent.async_error, this.asyncerrorhandler); ns.play("http://traffic.idmnet.pl/21057/lekarzeiv.mp4"); video = new video(640,360); video.attachnetstream(ns); video.smoothing = true; addchild(video); ns.resume(); fb = new facebook(); this.addchild(fb); //fb.x = 380; fb.y = 10; tw = new twitter(); this.addchild(tw); //tw.x = 80; tw.y = 40; im = new images(); this.addchild(im); im.y = 60; fb.addeventlistener(mouseevent.click, facebookclicke); tw.addeventlistener(mouseevent.click, twitterclicke); function facebookclicke(e:mouseevent):void { navigatetourl(new urlrequest("https://pl-pl.facebook.com/")); } function twitterclicke(e:mouseevent):void { navigatetourl(new urlrequest("https://twitter.com/")); } this.tw.x = 40; this.fb.x = 40; this.im.x = 40; this.tw.y = 150; } private function asyncerrorhandler(event:asyncerrorevent) : void { return; } public function ipause() : void { this.ns.pause(); return; } public function iresume() : void { ns.resume(); return; } public function advolume(value:number) : void { adsoundtransform.volume = value; ns.soundtransform = adsoundtransform; return; }// end function } and examplevpaid class
import flash.display.*; import flash.events.event; import flash.events.mouseevent; import flash.events.timerevent; import flash.system.security; import flash.utils.timer; public class examplevpaid extends sprite implements ivpaid { protected var timer:timer; protected var adduration:number; protected var timeremaining:number; protected var initwidth:number; protected var initheight:number; private var viewmode:string; private var fakead:fakead; protected var islinearad:boolean = true; private static const vpaid_version:string = "1.0"; public function examplevpaid() { security.allowdomain("*"); mouseenabled = false; return; }// end function public function getvpaid():object { return this; }//end function public function adlinear():boolean { return islinearad; }//end function public function adexpanded():boolean { return false; }//end function public function adremainingtime():number { return timeremaining; }//end function public function advolume():number { return -1; }//end function public function set advolume(value:number):void { }// end function public function handshakeversion(playervpaidversion:string):string { log("the player supports vpaid version " + playervpaidversion + " , ad supports " + vpaid_version); return vpaid_version; } protected function log(mesg:string):void { var data:object = { "message":mesg }; dispatchevent(new vpaidevent(vpaidevent.adlog, data)); } public function initad(initwidth:number, initheight:number, viewmode:string, desiredbitrate:number, creativedata:string, environmentvars:string):void { resizead(initwidth, initheight, viewmode); loadad(); } private function getdurationvalue(creativedata:string):void { var startindex:number = creativedata.indexof("duration="); var endindex:number = creativedata.indexof(";"); adduration = number(creativedata.substring(startindex + 9, endindex)); } protected function loadad():void { dispatchevent(new vpaidevent(vpaidevent.adloaded)); } public function startad():void { log("beginning display of example vpaid ad"); fakead = new fakead(0x4db3b1, 0x38470b," i'm vpaid ad!"); fakead.mouseenabled = true; fakead.addeventlistener(mouseevent.click, onadclick); positionfakead(); addchild(fakead); dispatchevent(new vpaidevent(vpaidevent.adstarted)); dispatchevent(new vpaidevent(vpaidevent.adimpression)); adduration = 15; timer = new timer(1000, adduration); timer.addeventlistener(timerevent.timer, ontimer); timer.addeventlistener(timerevent.timer_complete, timercomplete); timer.start(); } protected function ontimer(pevent:timerevent):void { timeremaining--; } protected function onadclick(event:mouseevent):void { var data:object = { "playerhandles":true }; dispatchevent(new vpaidevent(vpaidevent.adclickthru, data)); } protected function timercomplete(event:event):void { stopad(); } public function stopad():void { log("stopping display of vpaid ad"); if (timer) { timer.removeeventlistener(timerevent.timer, ontimer); timer.removeeventlistener(timerevent.timer_complete, timercomplete); timer = null; } if (fakead) { removechild(fakead); fakead = null; } dispatchevent(new vpaidevent(vpaidevent.adstopped)); } public function resizead(width:number, height:number, viewmode:string):void { this.initwidth = width; this.initheight = height; this.viewmode = viewmode; positionfakead(); } protected function positionfakead():void { if (fakead) { var widthandheight:number = math.min(initheight, initwidth); var scale:number=0; if (initwidth/fakead.width>initheight/ fakead.height) scale=initheight/ fakead.height; else scale=initwidth/fakead.width; fakead.x =0; fakead.y =0; } } public function pausead():void { if (timer) { timer.stop(); } if(this.fakead) { this.fakead.ipause() } return; } public function resumead():void { if (timer) { timer.start(); } } public function expandad():void { } public function collapsead():void { } } and vpaidevent
package { import flash.events.event;
/* * vpaid events vpaid swf can dispatch. class not need used vpaid swfs, * can make coding easier. source can found in vpaid specification: * http://www.iab.net/media/file/vpaidfinal51109.pdf */ public class vpaidevent extends event { public static const adloaded:string = "adloaded"; public static const adstarted:string = "adstarted"; public static const adstopped:string = "adstopped"; public static const adlinearchange:string = "adlinearchange"; public static const adexpandedchange:string = "adexpandedchange"; public static const adremainingtimechange:string= "adremainingtimechange"; public static const advolumechange:string = "advolumechange"; public static const adimpression:string = "adimpression"; public static const advideostart:string = "advideostart"; public static const advideofirstquartile:string= "advideofirstquartile"; public static const advideomidpoint:string = "advideomidpoint"; public static const advideothirdquartile:string= "advideothirdquartile"; public static const advideocomplete:string = "advideocomplete"; public static const adclickthru:string = "adclickthru"; public static const aduseracceptinvitation:string= "aduseracceptinvitation"; public static const aduserminimize:string = "aduserminimize"; public static const aduserclose:string = "aduserclose"; public static const adpaused:string = "adpaused"; public static const adplaying:string = "adplaying"; public static const adlog:string = "adlog"; public static const aderror:string = "aderror"; private var _data:object; public function vpaidevent(type:string, data:object=null, bubbles:boolean=false, cancelable:boolean=false) { super(type, bubbles, cancelable); _data = data; } public function data():object { return _data; } } }
please me
first thing try instantiate variable 'adsoundtransform' before doing it. code written, referencing class, not instance of class.
adsoundtransform = new soundtransform(); adsoundtransform.volume = value; ...
Comments
Post a Comment