Other Websites

  • SeaCloud9 Interactive
  • SeaCloud9 Commercial Development
  • i-os
  • stArcade9

Brendon Smith Social Networks

  • On Linkedin
  • Bookmarks
  • On Twitter
  • On Facebook
Open ↓ Close ↑
  • Home
  • Subscribe
Browse: Home / 2008/ / March
i-create | therefore-i am
i-create | therefore i-am | a blog about opensource technology and rich internet applications

March 2008

You are browsing the archive for March 2008.

ActionScript3 SharedObject / FlashVars

By Brendon Smith on March 14, 2008

Custom C# Control:

Note this is only part of the control. With a little more work you can easily make is so you can drop it on a page and simply name the FlashAudioVariable to point to the name of the flv.

Panel pnlAudioContainer = new Panel();
pnlAudioContainer.ID = string.Concat(this.ID, "_pnlAudioContainer");
pnlAudioContainer.Style.Add("float", "left");
pnlAudioContainer.Style.Add(HtmlTextWriterStyle.Width, "100%");
pnlAudioContainer.Style.Add(HtmlTextWriterStyle.Height, "2px");
Panel pnlAudio = new Panel();
pnlAudio.ID = string.Concat(this.ID, "_pnlAudio");
pnlAudio.Style.Add("display", "inline");
pnlAudio.Style.Add("float", "right");
pnlAudio.Style.Add("_margin-top", "-23px");
pnlAudio.Style.Add(HtmlTextWriterStyle.Width, "90px");
pnlAudio.Style.Add(HtmlTextWriterStyle.Height, "30px");

string Flashobjectstart = "<noscript><object classid=’clsid:d27cdb6e-ae6d-11cf-96b8-444553540000′ codebase=’http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0′width=’90′ height=’30′ align=’middle’><param name=’movie’ value=’yourlocatointo.swf’ /><param name=’quality’ value=’high’ /><param name=’bgcolor’ value=’#FFFFFF’ /><param name=’FlashVars’ value=’myVid=rtmp://video/audio/location/";
string Flashobjectmid = "’ /><embed src=’yourlocatointo.swf’ flashvars=’myVid=rtmp://video/audio/location/";
string Flashobjectend = "’ quality=’high’ bgcolor=’#FFFFFF’ width=’90′ height=’30′ align=’middle’ type=’application/x-shockwave-flash’pluginspage=’http://www.macromedia.com/go/getflashplayer’ /></object></noscript>";
string FlashJS1 = "<script language=’javascript’ type=’text/javascript’>FlashAudio(‘";
string FlashJS2 = "’);</script>";
string FlashAudio = string.Concat(Flashobjectstart, audioFileName, Flashobjectmid, audioFileName, Flashobjectend);
string FlashAudio2 = string.Concat(FlashJS1, audioFileName, FlashJS2);
pnlAudio.Controls.Add(new LiteralControl(FlashAudio));
pnlAudio.Controls.Add(new LiteralControl(FlashAudio2));
pnlCaptionMain.Controls.Add(pnlAudioContainer);
pnlCaptionMain.Controls.Add(pnlAudio);

Shared Object in ActionScript3 w/ FlashVars:
There are slight differences in the way the flash player 9 handles flashvars. This is a working example of how a custom flv player would use flash vars to call a video or audio file and play it! It also uses a shared object the benefit of this is its persistence (like a cookie on stereiods) if you had say several videos that you wanted to play on several different pages but you wanted the player to stop / rewind and if your user tells it to stop to remember the user told the flash player to stop here is how you would do that:

ActionScript3 SharedObject External Video / Audio in Flashvars:
import fl.video.*;
var flvControl = display;
var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
var flvSource = flashvars['myVid'];
flvControl.autoRewind = true;
var my_so:SharedObject = SharedObject.getLocal("userPref");
if (my_so.data.stopped == undefined) {
flvControl.play();
flvControl.autoPlay = true;
toggle_btn.gotoAndPlay(1);
} else {
flvControl.stop();
flvControl.autoPlay = false;
toggle_btn.gotoAndPlay(2);
}
function completeHandler(event:VideoEvent):void
{
flvControl.seek(0);
flvControl.play()
}
flvControl.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl.source = flvSource;
function toggleHandler(event:MouseEvent):void
{
if( flvControl.playing ){
my_so.data.stopped = 1;
my_so.flush();
flvControl.stop();
toggle_btn.gotoAndPlay(1);
}else{
if(my_so.data.stopped == !undefined)
{
my_so.clear();
}
flvControl.play();
toggle_btn.gotoAndPlay(2)
}
}
toggle_btn.addEventListener(MouseEvent.CLICK, toggleHandler);

Posted in ActionScript, C# | Tagged ActionScript, C#, Flash | Leave a response

 
 

3d ActionScript Adobe Air Android Apollo Apple art as3 ASP.NET Blend C# CakePHP CSS Experiment Flash Flash Develop Flex Games Generative Design Google Informatics JavaScript Joshua Davis JSON Life Lingo Linux MashUp Open Source OpenSource PaperVision3D PC History Processing quick tip RIA Silverlight Technology/Internet travel twitter Web Web 3.0 Webware XML Yahoo Pipes

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

  • Monthly
  • Yearly
  • Links
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • agit8
  • Bit-101
  • D.I.Y.
  • draw.logic
  • Flight404
  • Flong
  • generatorX
  • haXe
  • Jonathan Snook
  • Joshua Davis
  • Jot
  • Kirupa
  • LifeHacker
  • Make
  • NurseOnTheRun
  • octane42
  • PV3D
  • Senocular
  • Sephiroth
  • ShineDraw
  • SWX
  • Tech News
  • Toxi
  • ZeusLabs

Brendon's Photos

DSC00050.JPG

Recent Comments

  • morganae23 on Processing JS
  • morganae23 on Processing JS

RSS LifeStream

  • #Flash and Windows Phone 7 #RIA
  • Douglas Crockford: “Crockford on #JavaScript — Episode IV: The Metamorphosis of #Ajax” (93 min.) #YUI
  • The #HTML5 Flash Marriage: #Geolocation