A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Autoplay?

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    20

    Autoplay?

    I'm trying to have the music on my site autoplay & I don't know the code to put into flash to have my music player automatically play. If anyone can help, it'd be much appreciated. Thank you.

    www.gangsterpaintball.com/testt.html

    Here's the code:
    Code:
    package com.lynda.audio
    {
    	import flash.display.*;
    	import flash.events.*;
    	import flash.geom.*;
    	import flash.media.*;
    	import flash.net.*;
    	
    	public class Player extends MovieClip
    	{
    		public var channel:SoundChannel;
    		public var sound:Sound;
    		public var resumeTime:Number = 0;
    		
    		public function Player()
    		{
    			play_mc.buttonMode = true;
    			pause_mc.buttonMode = true;
    			pause_mc.visible = false;
    			
    			play_mc.addEventListener(MouseEvent.CLICK, playSong);
    			pause_mc.addEventListener(MouseEvent.CLICK, pauseSong);
    			
    		}
    		
    		public function playSong(event:MouseEvent = null):void
    		{
    			var soundFile:String = "Gangster1234.mp3";
    			if(channel)
    			{
    				channel.stop();
    			}
    			sound = new Sound();
    			sound.load(new URLRequest(soundFile));
    			channel = sound.play(resumeTime);
    			play_mc.visible = false;
    			pause_mc.visible = true;
    			
    		}
    		
    		public function pauseSong(event:MouseEvent = null):void
    		{
    			resumeTime = channel.position;
    			channel.stop();
    			play_mc.visible = true;
    			pause_mc.visible = false;
    		}
    
    	}
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Just put
    playSong();
    within the Player function.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center