-
-
Save mitsuse/693aefa9ae9f83f66704 to your computer and use it in GitHub Desktop.
MovieClipSWFLoader.play() and stop() cannot work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:local="*"> | |
<fx:Declarations> | |
<local:PlaySwfHelper id="helper"/> | |
</fx:Declarations> | |
<s:VGroup width="100%" height="100%" | |
paddingTop="8" paddingBottom="8" | |
paddingLeft="8" paddingRight="8"> | |
<s:MovieClipSWFLoader id="loader" width="100%" height="100%" | |
verticalAlign="middle" horizontalAlign="center" | |
autoLoad="false"/> | |
<s:HGroup width="100%"> | |
<s:Button id="playButton" label="Play" width="100%"/> | |
<s:Button id="stopButton" label="Stop" width="100%"/> | |
</s:HGroup> | |
</s:VGroup> | |
</s:WindowedApplication> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.events.MouseEvent; | |
import mx.core.IMXMLObject; | |
import mx.events.FlexEvent; | |
public class PlaySwfHelper implements IMXMLObject { | |
private var root: playswf; | |
public function initialized(object: Object, id: String): void { | |
root = object as playswf; | |
root.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete); | |
} | |
private function onCreationComplete(event: FlexEvent): void { | |
root.loader.source = "asset/example.swf"; | |
root.playButton.addEventListener(MouseEvent.CLICK, onPlayButtonClick); | |
root.stopButton.addEventListener(MouseEvent.CLICK, onStopButtonClick); | |
} | |
private function onPlayButtonClick(event: MouseEvent): void { | |
if (root.loader.content == null) { | |
root.loader.load(); | |
} else { | |
trace(root.loader.content); // this code prints "[object AVM1Movie]" | |
root.loader.movieClip.play(); | |
} | |
} | |
private function onStopButtonClick(event: MouseEvent): void { | |
root.loader.movieClip.stop(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment