JavaScript :: SWF Object - Play Song Function (Not Defined)
Sep 4, 2010
I'm trying to have JavaScript call a function from my ActionScript.
ActionScript:
import flash.external.ExternalInterface;
ExternalInterface.addCallback( "playSong", playSong );
function playSong():void {
var _sound:Sound = new Sound();
var _request = new URLRequest("music.mp3");
_sound.load(_request);
_sound.play();
}
JavaScript:
swfobject.embedSWF('[URL]', 'musicplayercontrol1', '1', '1', '9', null, null, {
allowScriptAccess: 'always', wmode: 'transparent' }, { }, function( e ) {
document.getElementById('musicplayercontrol1').playSong();
});
I keep getting a function not defined from firebug. I tried having the song play as soon as the swf load, and that works for sure.
View 1 Replies
Similar Posts:
Apr 5, 2012
I'm currently working with soundmanager2 in an IE/flash context (not html5). The issue is that audio playback of mp3 content does not occur for the following case where the 'onload' callback function is defined as null OR as a function that does almost nothing.
[Code]...
View 1 Replies
May 20, 2011
Here's the challenge: I have a Flash movie which will be embedded in a page using an unknown DOM ID that I want to be able to identify/store for callback in a JS function. My ideal user flow would be: User clicks button in Flash. Flash pauses any animations / video / sounds / etc. Flash calls an injected JS function to display a page-covering overlay experience. When user closes overlay experience, a callback method on the Flash object is called. Flash resumes playback.
The problem is, when AS3 uses the ExternalInterface.call("functionName", args...) method, there doesn't seem to be a DOM event triggered, and thus it is impossible to tell which object called a JS function, so having a "registerMe()" function doesn't seem to work. Basically, the injected JS function has no way to determine which DOM object to call, because the ID of the Flash object is unknown.
[Code]...
View 3 Replies
Aug 29, 2011
I am developing an online listen music website, on that I want to play song based on the user selection from gridview.right now I am using flash object for playing mp3 and video file this is running fine but its static path.how I can dynamically pass file URL of selected song on flash object.
View 3 Replies
Apr 14, 2010
i use Adobe flash player in my site, and now i need to increment some filed in database, when user click on player.here is the script
<div id="conteiner" style="text-align: center;" ></div>
<script type="text/javascript">
var s1 = new SWFObject("player.swf","ply","420","380","9","#FFFFFF");[code]...
i deside to use ajax for it, but how can i write a function in the flash object?
UPDATE: i only have the swfobject.js file, which contains such data
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new [code]....
and the player.swf, and the html, i've shown allready. i don't now is this flash player or no, and what can i do?
View 1 Replies
Oct 17, 2011
I'm building an AIR desktop application. At one point the application loads a popup window (an MXML component based on s:Window), which contains an mx:HTML component which loads a local (in the application directory) html file, blank.html. The relevant elements in blank.html are:
<script src="jw/jwplayer.js"/> <!--JW Player's JS-based Embedder-->
<div id="jwtarget" /> <!-- the target that the embedder will use -->
Since the parameters I want to use are determined at runtime, I use the domWindow property to invoke the method which loads the player. Here's an example that works:
[Code]...
View 2 Replies
Nov 1, 2009
In the animation im making i have multiple scenes in it and i was wondering how i could have 1 song play throughout the whole animation?
View 2 Replies
Apr 3, 2010
i want to play a mp3 song when i click on button song play and when i click on stop song will be stop.
View 5 Replies
Apr 12, 2012
I'm having some trouble with the code below. the flash player has a default volume slider, but I want to use the jQuery slider to change the volume. the volume value(nr) is changing while I move the slider, but the volume of the song doesn't.
<!DOCTYPE html>
<script type='text/javascript'>
$(document).ready(function(){
[Code].....
View 1 Replies
Aug 11, 2009
I need to be able to send a bytearray object to a javascript function or a java method, but I was wondering if I could do it using XMLHTTPRequest.
import asfiles.encoding.JPEGEncoder;import flash.display.Bitmap;import flash.display.BitmapData;import flash.external.[code]...
So I have a video that plays stream from a webcam,I will click a button and take a picture. I encode that picture using JPEGEncoder then I store it in a ByteArray.How do I send that data over to either a javascript function or a java class?I don't want to use the navigateToURL (URLRequest) method because that will redirect my page.Is there a way to send the data to a function while still staying on the same page?For example, make a asynchronous call to a javascript function or java method?
View 1 Replies
Mar 8, 2010
I was recently searching for a way to call the print function on a PDF I was displaying in adobe air. I solved this problem with a little help from this fellow, and by calling postMessage on my PDF like so:
//this is the HTML I use to view my PDF
<object id="PDFObj" data="test.pdf" type="application/pdf"/>
//this actionscript lives in my air app
var pdfObj:Object = htmlLoader.window.document.getElementById("PDFObj");
pdfObj.postMessage([message]);
I've tried this in JavaScript as well, just to be sure it wasn't adobe sneaking in and helping me out..
[Code]...
View 1 Replies
Feb 7, 2011
I am trying to call a Jscript function from a flash object. I want the function to be called when the animation ends.
Here is the embed code
<h1 align="center">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="360" HEIGHT="250" id="Yourfilename" ALIGN="center">
[code].....
here is the action code I add to the last frame of the flash object
URLLoader("javascript:mainFunction();");
The object loads but the function is not called. I can call the function other ways such as using an "onclick = mainFunction()" event on a button for example.
View 1 Replies
Jul 11, 2011
My web application pass a javascript object to flex application using addCallback function.
when the flex application is in modal dialog in safari browser, the object in the flex application is null and when I open the flex application just in a new window, the object is passed correctly. But, I need the showmodaldialog to show the flex application.
The flex code:
ExternalInterface.addCallback( "handleEvent", handleEvent );
override public function handleEvent( event:Object ):Object {
Alert.show(String(event)); .....
View 1 Replies
Jan 2, 2011
[code]...
It can only allow me to play the songs once? How cn i modify it such that it can play it continuously?
View 1 Replies
Jul 21, 2011
I have a page with multiple flash objects which are written by a third party and thus can't be changed. They call a JS function but don't seem to pass any identifying parameters. Is there any way to determine inside the function which flash object called it?
View 2 Replies
Jul 8, 2010
I am refactoring some code. I have a PHP page that contains a MySQL query and stores the result in a PHP variable $my_result. This result is then echoed to a Flash SWF during embedding with SWFObject. I now want to call this PHP page that makes the query from a javascript function like so - one change I have made to the PHP is that instead of storing the result in a variable $my_result I am echoing the result. Javascript function to call the PHP page and make the database query
[Code]....
View 2 Replies
Nov 16, 2011
I have a flex app using the facebook js bridge to log in, and I am trying to pass the users name back to the app, but I am coming across the thing that I will explain after the code:
function getFriends() {
var nameOfPlayer = "";
FB.api('/me', function(response) {
[code].....
View 2 Replies
Sep 11, 2011
I am loading mp3's externally as to not bloat the swf. However, only 1 out of 3 songs play (2nd song plays) for this jukebox I'm having to create for an assignment. I would think if one song played, they all would. I've checked the AS2 code and it all seems right to me; the song names and button instance names. I sure could use some insight as to why the 1st and 3rd song doesn't play. My jukebox is at: [URL] and here is my simple code in the first Actions frame. This is the only code I used for the jukebox.
[Code]...
View 3 Replies
Nov 3, 2011
I have problem with the code below. its a flash mp3 player. I need to prevent it from autoplay from the start. but keeps on playing all the tracks after the user click on play. How can i fix this?
Code:
import flash.filters.DropShadowFilter;
var infostruc:Array = [];
var xmlData:XML = new XML();
[Code].....
View 2 Replies
Sep 1, 2006
I have this text file text.txt and it has a variable in it named song1 with the url of a song file. In flash, I set up this actionscript:
onClipEvent (load) {
loadVariables("text.txt", "_root");
var my_sound:Sound = new Sound();
my_sound.loadSound(song1,false);
}
the problem is that I get an UNDEFINED message for the variable song1. But, if I put it in for the variable of dynamic text, the text will show up in the exported flash. I suspect it has something to do with where the variable is being exported to.
View 3 Replies
Oct 7, 2009
I have a play button and stop button when I click on the play button the song keeps repeating over and over. How to stop this? This is the code I'm using:
var req:URLRequest = new URLRequest("song.mp3");
var sound:Sound = new Sound();
var controller:SoundChannel;
function soundLoaded(event:Event):void {
controller = sound.play();
[Code] .....
View 2 Replies
Nov 25, 2010
I am creating a project and I want the user when they hover over my button to have a song play, when the user leaves the over state, the song stops, I can't seem to get it to work. Here is what I am doing, I have my button, inside the button on the over state I nest a Movie Clip, inside of that I bring in the song, in the properties I set it to "Start" and "Repeat x 0".
When I load the SWF it automatically plays.I've tried adding some AS3 to it but I can't seem to get it to work. like "stop();" which did nothing.I did some googling and found "SoundMixer.stopAll();" which does stop the song from loading on start.
ActionScript Code:
stop();
SoundMixer.stopAll();[code].....
View 2 Replies
Mar 3, 2011
I have a situation where, upon loading my swf, I add an event listener to the stage to listen for keyboard commands. One of them is to listen for the spacebar, and if it is pressed, it should play a movie. The problem is, that movie is not loaded until later on, depending other user interactions, therefore, until it is loaded, the reference to it would be undefined.
But if I wait and add the listener for key commands only when the movie is loaded, then I can't utilize the listener for other keyboard commands, like RIGHT or LEFT, which are the buttons which get you to the movie in the first place. Is there a way to add a conditional or something to prevent that code from being executed if the video is not defined yet? Here's my code:
[code]...
View 2 Replies
Jul 6, 2011
Curious question:Take this function:
function something():Array
{
var ar:Array = [];
[code]....
View 2 Replies
Nov 27, 2010
At the moment, I am attempting to make a music player that will play a specific song of my choosing. I am stuck at the part where you can pause the sound, and then play it in the same place. I have tried many things such as using the timer utilities. Right now, when I pause it, it stops, and when I press play, it plays from the beginning.
stop();
var channel:SoundChannel;
var soundCheck:Boolean = true;
var song:Sound = new Sound(new URLRequest("song.mp3"));
channel = song.play();
[Code] .....
View 1 Replies
Nov 8, 2004
I am trying to have a streamed mp3 loaded from xml, randomly play a new song on complete. I already have it play randomly onload. Here is what I have, and it doesnt work .
Code:
tickerLength = 52;
for (i=0; i<tickerLength; i++) {
leading += " ";[code].........
View 1 Replies
Nov 23, 2009
I followed your tutorial for the Volume Control Slider [URL] and it works well, but instead of having to press play and turn up the slider I would like the song to play at start and volume at like 50, 75 or 100%. I've messed around a bit but haven't been able to come up with anything that works
[Code]...
View 4 Replies
Nov 8, 2004
I am trying to have a streamed mp3 loaded from xml, randomly play a new song on complete. I already have it play randomly onload. Here is what I have, and it doesnt work :
Code:
tickerLength = 52;
for (i=0; i<tickerLength; i++) {
leading += " ";[code].....
View 1 Replies
Aug 19, 2009
I have a list of mp3-songs, when song 1 is clicked it gets streamed, a stop-button appears, if this Btn is clicked, this Btn disappears as it should - but if user forgets to click for stopping sound and clicks song 2, stopBtn 1 remains and the new stopBtn 2 also appears. there should be only one stopBtn, the one next to the song is playing.
I would like to move the stopBtn and I have tried several approaches move; graphics.moveTo; if(stopButton !=null) {removeChild (stopButton)}; I packed the var stopButton:Sprite in the header and so on.
Code:
SoundMixer.stopAll();
import flash.display.Sprite;[code]..........
View 0 Replies
Apr 28, 2009
I am making flash CS4-based music player with ActionScript 3. When I host the player on my site, e.g. [URL], and play an mp3 on the server of my site, e.g.[URL], it works well.
When I link to an mp3 of another site, e.g. [URL], in my local machine, it also works. However, when I host the music player in my site [URL], and play an mp3 of [URL], then it can't be played.
View 8 Replies