Seekbar for mp3 player in Actionscript 3.0 Flash CS-6 - actionscript-3

I'm trying to create a music player in Flash CS6. I'm new to Flash. I have created the play/pause/volume buttons. I have also been able to extract the mp3 information using the id3 tags. So i have the song duration. I now need to create a seekbar/progress bar. I have taken the progress bar from the components, but do not understand how to code it now. Please help!

According to the reference on Sound.play():
public function play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel
where the first argument is
startTime:Number (default = 0)//The initial position in milliseconds at which playback should start.
so you can call
channel.stop();
channel = sound.play(offset);
There is an example in the reference. Hope this helps.

You can get some idea using my audio player on my Github page.Also it's developed using flash CS6 and ActionScript 3.0. Use it, change it and develop your future with ActionScript .

Related

Controlling Sound / Volume

I added a sound to the Flash Professional CC library and had the program convert it to MP3. If I create a layer and drag-and-drop the sound onto the stage the sound plays fine (even after passing it through Swiffy), however that is all I am able to do so far.
I need some way to control when the sound plays as well as volume. I tried the giving the sound a class (Sound Properties -> ActionScript -> Export for ActionScript and assigned a class name mySound).
Then added this ActionScript to the first frame:
var myAudio:Sound = new mySound();
myAudio.play();
However, after passing it through Swiffy, I get the following errors:
The ActionScript class flash.media.Sound is not supported.
The ActionScript method flash.media.Sound.play() is not supported.
So I can't use the base Sound class in Flash? Is there another base class that can be used and is it compatible with the flash.media.Sound class? Is there some other way to control playback so that it can be played at a specific time -- such as on mouse roll-over or when something is clicked?
You could try using SoundJS. BTW, Flash Pro CC does have an HTML Canvas document type that uses CreateJS (which SoundJS is part of) under the hood. It won't convert AS3 to JS, though, you have to write the JS code yourself.

AS3: Custom native cursor [Flash CS4]

I'm currently developing a flash game using Adobe Flash CS4 Professional and AS3.
I have a custom cursor set up in my game, but it only changes position when the game renders a frame, 30 times per second, which could be better, so i want a custom native cursor.
Custom native cursor is a feature of Flash Player 10.2+, but in Flash CS4 i can only publish as Flash Player 10, and i can't have a custom native cursor.
So how do i add a custom native cursor to my game? Any workarounds/hacks appreciated.
I wont be buying a later version of Flash since this will probably by my last Flash game, as i will start to use Unity3D.
EDIT:
I used this tutorial from an answer below. I can now publish as Flash Player 10.2 or any other version i want. But i still can't get a custom native cursor working. I get the following error: VerifyError: Error #1014: Class flash.ui::MouseCursorData could not be found.
How can i make the flash.ui.MouseCursorData class work with Flash Pro CS4?
This is my code:
var bitmapDatas:Vector.<BitmapData> = new Vector.<BitmapData>(1, true);
var bitmapData:BitmapData = new CustomCursor(32,32);
bitmapDatas[0] = bitmapData;
var cursorData:MouseCursorData = new MouseCursorData();
cursorData.hotSpot = new Point(0,0);
cursorData.data = bitmapDatas;
Mouse.registerCursor("MyCursor", cursorData);
Mouse.cursor = "MyCursor";
You need to add a new playerglobal.swc and a new Flash Player target configuration. Here's a tutorial that is specific to Flash CS5 and Flash Player 11, but should work for CS4 and any player you want.

google doubleclick studio. video component

im bulding a flash banner where I'm using the components that double-click studio offers for free use in rich media banners.
Im the VideoPlayerAdvanced.
API documentatio here: http://www.google.com/doubleclick/studio/docs/sdk/flash/as3/en/com_google_ads_studio_video_VideoPlayerAdvanced.html
My question is how i dynamically can add a video player like the to the stage by addChild() or something like that. I also want to be able to set the urls for the player to play by code. That part seems quite straight forwards. But i can't figure out how to create an instance of the player dynamically by code.
Anyone that knows this?
Thanks!
Solved it by adding the component itself to a container movie clip and exported it with a classname for action script.
var video:Video = new Video();
addChild(video);
"video" holding the component.

Flash Auto Pause video after x seconds and play after selected option

I am doing project on developing a small game(A Soccer Penalty shootout guess game). I was hoping if someone could tell if it is possible to do the following function. I am using Adobe Flash Pro CC.
I am trying to pause the video that i have imported at 3.5 seconds and then two buttons appear with options either a Miss or Goal.. Once the user selects either option the video continues to play.
My question, is it possible to do this using Actionscript in Flash. if so what commands/function does it require.
Thanks
You could do it something like this (given that you are using the FLVPlayback component with the variable name of myFLVPlaybackComponent)
should be
myFLVPlaybackComponent.addEventListener(VideoEvent.PLAYHEAD_UPDATE, videoPause);
private function videoPause(evt:VideoEvent):void {
if (evt.playheadTime >= 3500){
myFLVPlaybackComponent.stop();
}
}
then call myFLVPlaybackComponent.play(); on your resume video function

How does one stop a SWF Movie dynamically loaded using the Loader class using ActionScript 3.0?

MovieClip(_loader.content).stop();
this.removeChild(_loader);
_loader.unload();
_loader = null;
I've been trying that, but it doesn't stop the movie. The movie has an embedded voiceover
and that keeps running. thank you.
Flash 10 introduced unloadAndStop(); (_loader.unloadAndStop() if it's named _loader like in your example) and if you are using Flash 10 then you should use this.
But the original idea of what Adobe intended in AS3 for Flash 9 was that the loaded in swf would be self reliant, able to detect when it was removed and stop the sound from within itself. Use this inside the swf that is being loaded in, so that it can detect when it is removed from the stage, and therefore shut down it's own sound:
addEventListener(Event.REMOVED_FROM_STAGE, swfWasRemoved);
function swfWasRemoved(event: Event) : void
{
// inside this function shut down the sound that is inside the swf
}
If the only remaining thing that is playing is the sound, use SoundMixer.stopAll() to stop that as well.
Make sure the embedded voice over is set to stream. If its on event, it will just keep playing until it's done regardless of the playhead of the swf.