Jump to content

JavaScript to Flash


shocker-z

Recommended Posts

Hi im wanting to know the simplest way to pass a variable to flash

 

 

I have this line in my flash movie

 

var _vidURL = "http://www.website.com/stream/flvprovider.php?ID=" + _vidID;

 

and im wanting to define _vidID in the webpage so i can pull this from the database in PHP.

 

Everything ive looked up so far is to do with buttons calling functions, but i just need a basic Var i can change.

 

Regards

Liam

Link to comment
Share on other sites

That doesn't seem to be working

 

Do i need anything in flash to define _VidID to say to use _GET?

 

heres the HTML/JavaScript

 

 

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','400','height','200','id','sample','align','middle','src','scrubber','allowscriptaccess','always','quality','high','bgcolor','#ffffff','name','sample','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','scrubber' ); //end AC code
</script><noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="200" id="sample" align="middle">
<param name="movie" value="scrubber.swf?VidID=golf.php" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />

<param nam="allowScriptAccess" value="always">
<embed src="scrubber.swf" allowScriptAccess="always" quality="high" bgcolor="#ffffff" width="400" height="200" name="sample" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object></noscript>

 

 

Thanks

Regards

Liam

Link to comment
Share on other sites

Can't edit but here is more info.

 

Flash Actionscript

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

var _vidName = _vidNamevar;
var _vidURL = "http://www.xxxx.com/cammonitor/stream/flvprovider.php?file=" + _vidName;
var _phpURL = "http://www.xxxx.com/cammonitor/stream/flvprovider.php";
var ending = false;
var amountLoaded:Number;
var duration:Number;
var loaderwidth = loader.loadbar._width;

theVideo.attachVideo(ns);
ns.setBufferTime(2);

statusID = setInterval(videoStatus, 200);

ns.onStatus = function(info) {

trace(info.code);	
if(info.code == "NetStream.Buffer.Full") {
	bufferClip._visible = false;		
	ending = false;

	clearInterval( statusID );
	statusID = setInterval(videoStatus, 200);
}
if(info.code == "NetStream.Buffer.Empty") {
	if ( !ending ) {
		bufferClip._visible = true;
	}
}
if(info.code == "NetStream.Play.Stop") {
	bufferClip._visible = false;
	//ending = true;
}
if(info.code == "NetStream.Play.Start") {
	ending = false;
}
if(info.code == "NetStream.Buffer.Flush") {
	ending = true;
}
}

playButton.onRelease = function() {
ns.pause();
}

play_btn.onRelease = function() {
restartIt();
this._visible = false;
}

rewindButton.onRelease = function() {
restartIt();
}

ns["onMetaData"] = function(obj) {
duration = obj.duration;
//trace(obj.width);
//trace(obj.height);
// suck out the times and filepositions array, this was added by flvmdi27b
times = obj.keyframes.times;
positions = obj.keyframes.filepositions;
}

function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * loaderwidth;
loader.scrub._x = ns.time / duration * loaderwidth;
}

loader.scrub.onPress = function() {
clearInterval (statusID );
ns.pause();
this.startDrag(false,0,this._y,loaderwidth,this._y);
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {	
scrubit();
this.stopDrag();
}

function scrubit() {
var tofind = Math.floor((loader.scrub._x/loaderwidth)*duration);
if (tofind <= 0 ) {
	restartIt();
	return;
}

for (var i:Number=0; i < times.length; i++){
	var j = i + 1;
	if( (times[i] <= tofind) && (times[j] >= tofind ) ){
		trace("match at " + times[i] + " and " +  positions[i]);
		bufferClip._visible = true;
		ns.play( _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
		trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
		break;
	}
}
}

function pauseIt() {
ns.pause();
}

function stopIt() {
ns.seek(0);
ns.pause();
}

function restartIt() {
ns.play( _vidURL );
}

//restartIt();

// holds sound
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(ns);

var so:Sound = new Sound(vSound);
so.setVolume(100);

mute.onRollOver = function() {
if(so.getVolume()== 100) {
	this.gotoAndStop("onOver");
}
else {
	this.gotoAndStop("muteOver");
}
}

mute.onRollOut = function() {
if(so.getVolume()== 100) {
	this.gotoAndStop("on");
}
else {
	this.gotoAndStop("mute");
}
}

mute.onRelease = function() {
if(so.getVolume()== 100) {
	so.setVolume(0);
	this.gotoAndStop("muteOver");
}
else {
	so.setVolume(100);
	this.gotoAndStop("onOver");
}
}



/*
var theMenu:ContextMenu = new ContextMenu();
theMenu.hideBuiltInItems();
_root.menu = theMenu;

var item1:ContextMenuItem = new ContextMenuItem("::::: Video Controls :::::",trace);
theMenu.customItems[0] = item1;

var item2:ContextMenuItem = new ContextMenuItem("Play / Pause Video",pauseIt,true);
theMenu.customItems[1] = item2;

var item3:ContextMenuItem = new ContextMenuItem("Replay the Video",restartIt);
theMenu.customItems[2] = item3;

*/



 

test.php

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','380','height','260','src','scrubber','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','scrubber' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="380" height="260">
  <param name="movie" value="scrubber.swf?_vidnamevar=golfers.flv">
  <param name="_vidnamevar" value="golfers.flv">
  <param name="FlashVars" VALUE="_vidnamevar=golfers.flv">
  <param name="quality" value="high">
  <embed src="scrubber.swf?__vidnamevar=golfers.flv?_vidnamevar=golfers.flv" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="380" height="260" FlashVars="_vidnamevar=golfers.flv" ></embed>
</object>
</noscript></body>
</html>

 

Now i know this isn't passing a value to the variable as in flvprovider.php i exec("echo $file >> file.txt"); and it returns "/home/www/cammonitor/stream/undefined" but if i set the var within the flash file "var _vidName = 'golfers.flv'" then it returns "var _vidName = _vidNamevar;"

 

Do i need anything extra in the flash file to define the variable as comming from the url string?

 

Regards

Liam

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.