This content has been marked as final. Show 2 replies
You are diving right into the deep end, huh?
First off, you are really asking Flash questions here, not Flex. I'd recommend using Flex, at least at first, because it will be a lot easier.
Second, you have to get used to events and the asynchronicity of the Flash Player.
Third, it looks to me that while your PlayPause class does create a child Sprite which is added to PlayPause, it doesn't appear you have added your PlayPause instance to the stage.
I know this is "kind-of" an actionscript question, but I"m using Flex for this issue. I actually have the class being imported into a component that is being used in my main.mxml app file. The audio shows up so it is instantiated. Why doesn't playpauseBtn add to the stage inside of the AudioController component? If I"m still just completely hopeless, can you please send me in the direction of a tutorial/article that may help me?
For this example I used comps as the name space, and the component is on stage correctly.
in AudioController.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="150" height="50">
var sController:SoundController = new SoundController();
<mx:Button label="replay" width="65"/>
<mx:Button label="toggle" width="65"/>
================end AudioController.mxml ============
public class SoundController extends Sprite
private var mSound:Sound;
private var mChannel:SoundChannel;
private var playpauseBtn:Sprite;
private var mPlaying:Boolean = false;
private var mPosition:int;
public function SoundController():void
var mRequest:URLRequest = new URLRequest("audio/sample_audio.mp3");
mSound = new Sound();
mChannel = mSound.play();
mPlaying = true;
playpauseBtn = new Sprite();
public function onPlayPause(e:MouseEvent):void
mPosition = mChannel.position;
mChannel = mSound.play(mPosition);
mPlaying = !mPlaying;
=========== end .as file =====================