![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
hi everybody,
folling problem. I have a swf video which I need to count how often it was played till the end. I thought I can wrap it in another swf and add an eventlistener to recognize the last frame. this is my code: [Q]<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import flash.events.*; import flash.display.MovieClip; public var myMC:MovieClip; public function init():void{ label1.text = "init1"; loadTheSWF.addEventListener(Event.INIT,initHandler ); } private function initHandler(event:Event):void{ label1.text = "init2"; //trace("init"); try{ myMC = MovieClip(loadTheSWF.content); myMC.addEventListener(Event.ENTER_FRAME, onEnterFrameHandler); } catch(error:Error){ trace("Error, error="+error); } } private function onEnterFrameHandler(event:Event):void{ if(event.currentTarget.currentFrame == event.currentTarget.totalFrames){ label1.text = "complete"; myMC.removeEventListener(Event.ENTER_FRAME, onEnterFrameHandler); trace("movie palyed"); } } ]]> </mx:Script> <mx:Panel id="swfPanel" horizontalAlign="center" verticalAlign="center"> <mx:Label id="label1" text="video1"/> <mx:SWFLoader id="loadTheSWF" source="@Embed(source='video1.swf')" height="495" width="640" scaleContent="true"/> </mx:Panel> </mx:Application>[/Q] It goes into init() function but the added eventlistener is not working. does anybody know what my mistake is or is there maybe another/better way to do what I want to do? thx in advance |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise