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 Away3D C# CakePHP CSS Experiment Flash Flash Develop Flex Games Generative Design Google HTML5 hype JavaScript Joshua Davis JQuery JSON Life Linux MashUp OpenSource Open Source PaperVision3D PC History Processing quick tip RIA Silverlight Technology/Internet travel twitter Web webGL Webware XML Yahoo Pipes

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

  • Monthly
  • Yearly
  • Links
  • August 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • agit8
  • Away3D
  • Ben Nadel
  • Bit-101
  • Bruce Jawn
  • Causecast
  • D.I.Y.
  • Dr Woohoo
  • draw.logic
  • Flight404
  • Flong
  • generatorX
  • gSkinner
  • haXe
  • Jonathan Snook
  • Joshua Davis
  • Jot
  • Kirupa
  • LifeHacker
  • Make
  • Minor White
  • Mr Doob
  • NihiLogic
  • NurseOnTheRun
  • octane42
  • OpenFrameWorks
  • Processing
  • PV3D
  • Senocular
  • Sephiroth
  • ShineDraw
  • Stroep
  • SWX
  • Tech News
  • Toxi
  • UnitZeroOne
  • World We Live In
  • ZeusLabs

Photos

myUniveRSS is a 3D news aggregation application on Facebook I created with Flash and PaperVision3D.

Recent Comments

  • seacloud9 on Tweet Tank in Away3D and Hype pt. 2
  • Brendon Smith on Tweet Tank in Away3D and Hype pt. 2

RSS LifeStream

  • Elysium
  • Giles Bowkett: Archaeopteryx: A Ruby MIDI Generator
  • Grant Nestor » Blog Archive » Generative music, huh?

Copyright © 2010 i-create | therefore-i am.