I am looking into creating a YouTube video search and play widget for inside IMVU’s Widget API.
Here is the link to download the getting started files needed from IMVU:
http://code.google.com/p/imvu-flash/downloads/list and click the link to download the zip.
Everything needed is there.
Actionscript 3 code written with Flash CS3:
.fla file only consists of a rectangle window movie clip (any color) with 100% alpha using Document Class of YtubeWidget.
package {
// Needed for package to work through IMVU API
import com.imvu.widget.*;
import com.imvu.events.*;
import flash.system.Security;
import flash.events.*;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
Security.allowDomain("*"); // Can be ("w.w.w.youtube.com") also.
//Class needed for IMVU API
public class YtubeWidget extends ClientWidget {
// My variables
public var my_loader:Loader = new Loader();
public var my_player:Object;
// Function to initiate widget inside IMVU pipeline and add to stage
public function initWidget(event:Event):void {
//trace(“init”);
this.widgetName = “YtubePlayer”;
this.space.addEventListener(com.imvu.widget.WidgetSpace.WIDGET_LOADED, addWidgetToStage);
//YouTube URL call
my_loader.load(new URLRequest(htp://w.w.w.youtube.com/apiplayer?version=3")); //(<reconfigure)
my_loader.contentLoaderInfo.addEventListener(Event.INIT, addWidgetToStage);
}
// Remove Listener
public function addWidgetToStage(event:Event):void {
this.space.removeEventListener(com.imvu.widget.WidgetSpace.WIDGET_LOADED, addWidgetToStage);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, widgetLoaded);
}
// Adding loader from YouTube
public function widgetLoaded(event:Event):void {
addChild(my_loader);
my_player = my_loader.content;
my_loader.content.addEventListener(“onReady”, onPlayerReady);
}
// Loaded video request
public function onPlayerReady(event:Event):void {
// YouTube ID for video explaining, but outside of a package needed in this code
//Full link: https://www.youtube.com/watch?v=gLkB00Fj0bw
my_player.loadVideoById(“gLkB00Fj0bw”,0);
my_player.setSize(640,480);
}
}
}
// Stop
This is just to get the YouTube Chromeless player into the IMVU test environment!
This code shows no errors in compiler, but won’t pull video loader to stage request.
This is how I understood IMVU’s ways to test inside their Mock Server and Mock Client SWF’s (Included in API zip and how to use it).
If anyone knows about the IMVU API and can show me where I went wrong or why the YouTube call for the loader wont load in the test environment, please post answers.