morako
asked on
How can I write a var in an embeded script from action script
Hello, I am not familiar with action script so I need a little help with this.
How can I make settings and index.html not be required or needed and how can I make the 835 on the tube=835 a var that can be set at the embeded script level.
http://website.com/distribution/xml/v1/?display=full&tube=835 on the original script it has settings.xml. I would like to replace settings.xml for ttp://website.com/distribu tion/xml/v 1/?display =full&tube =835 where the 835 can be a var set at the object level of the embeded code on a webpage.
beginning at line 79:
if (_root.htmlPage == undefined) {
_root.htmlPage = _root.playerPath + "index.html";
} else {
var pos : Number = _root.htmlPage.indexOf("cu rrCateg");
if(pos != -1) {
_root.htmlPage = _root.htmlPage.substring(0 , pos - 1);
}
if (_root.htmlPage.indexOf("http://" ) == -1 && _root.htmlPage.indexOf("fi le://") == -1) {
_root.htmlPage = _root.playerPath + _root.htmlPage;
}
}
if (_parent.settingsFile == undefined) {
this.settingsFile = _root.playerPath + "http://website.com/distribution/xml/v1/?display=full&tube=835";
}else if (_parent.settingsFile.inde xOf("http" ) == -1) {
this.settingsFile = _root.playerPath + _parent.settingsFile;
} else {
this.settingsFile = _parent.settingsFile;
}
How can I make settings and index.html not be required or needed and how can I make the 835 on the tube=835 a var that can be set at the embeded script level.
http://website.com/distribution/xml/v1/?display=full&tube=835 on the original script it has settings.xml. I would like to replace settings.xml for ttp://website.com/distribu
beginning at line 79:
if (_root.htmlPage == undefined) {
_root.htmlPage = _root.playerPath + "index.html";
} else {
var pos : Number = _root.htmlPage.indexOf("cu
if(pos != -1) {
_root.htmlPage = _root.htmlPage.substring(0
}
if (_root.htmlPage.indexOf("http://"
_root.htmlPage = _root.playerPath + _root.htmlPage;
}
}
if (_parent.settingsFile == undefined) {
this.settingsFile = _root.playerPath + "http://website.com/distribution/xml/v1/?display=full&tube=835";
}else if (_parent.settingsFile.inde
this.settingsFile = _root.playerPath + _parent.settingsFile;
} else {
this.settingsFile = _parent.settingsFile;
}
/**
* The Main Class
* @author FlashXpert
* @version 2.0
*/
import mx.transitions.easing.None;
import mx.transitions.Tween;
import net.flashXpert.utils.ToolTip;
import net.flashXpert.utils.Prototypes;
import net.flashXpert.utils.Proxy;
import net.flashXpert.videoPlayer.SettingsManager;
import net.flashXpert.videoPlayer.ControlsBar;
import net.flashXpert.videoPlayer.VideoDisplay;
import net.flashXpert.videoPlayer.Playlist;
import net.flashXpert.videoPlayer.Share;
import net.flashXpert.videoPlayer.Description;
import net.flashXpert.videoPlayer.Caption;
class net.flashXpert.videoPlayer.VideoPlayer extends MovieClip {
/** The Movieclip that contains the Preloader */
private var mcPreloader : MovieClip;
/** The Movieclip that contains the Share to a Friend */
private var mcShare : Share;
/** The Movieclip that contains the Middle Play Button */
private var mcMiddlePlayBtn : MovieClip;
/** The Movieclip that contains the Playlist */
private var mcPlaylist : Playlist;
/** The Movieclip that contains the current video's title and description texts */
private var mcDescription : Description;
/** The Movieclip that contains the Image Preview */
private var mcPreview : MovieClip;
/** The Movieclip that contains the Controll Bar */
private var mcControlsBar : ControlsBar;
/** The Movieclip that contains the Caption text */
private var mcCaption : Caption;
/** The Movieclip that contains the Video Display */
private var mcDisplay : VideoDisplay;
/** The Movieclip that contains the Background */
private var mcBackground : MovieClip;
/** The main XML */
private var settingsXML : XML;
/** The class that handle the main XML */
private var settingsManager : SettingsManager;
/** The current player's width */
private var playerW : Number;
/** The current player's height */
private var playerH : Number;
/** The player's initial X coordonate */
private var playerX : Number;
/** The player's initial Y coordonate */
private var playerY : Number;
private var settingsFile : String;
private var tween : Tween;
/**
* Builds/checks the paths (player's html page, swf and main XML) and starts loading the XML file
*/
public function VideoPlayer() {
System.security.allowDomain("*");
Stage.align = "LT";
Stage.scaleMode = "noScale";
this.tabChildren = false;
new Prototypes();
this.mcControlsBar._visible = false;
this.mcPreloader._alpha = 0;
this.mcPreloader.mcTxt.procTxt.embedFonts = true;
this.mcPreloader.mcTxt.procTxt.autoSize = true;
this.mcMiddlePlayBtn._width = 0;
this.mcMiddlePlayBtn._height = 0;
var currURL : String = _root._url.split("\\").join("/");
_root.playerPath = currURL.substring(0, currURL.lastIndexOf("/") + 1);
if (_root.htmlPage == undefined) {
_root.htmlPage = _root.playerPath + "index.html";
} else {
var pos : Number = _root.htmlPage.indexOf("currCateg");
if(pos != -1) {
_root.htmlPage = _root.htmlPage.substring(0, pos - 1);
}
if (_root.htmlPage.indexOf("http://") == -1 && _root.htmlPage.indexOf("file://") == -1) {
_root.htmlPage = _root.playerPath + _root.htmlPage;
}
}
if (_parent.settingsFile == undefined) {
this.settingsFile = _root.playerPath + "settings.xml";
}else if (_parent.settingsFile.indexOf("http") == -1) {
this.settingsFile = _root.playerPath + _parent.settingsFile;
} else {
this.settingsFile = _parent.settingsFile;
}
//loads the main XML file
this.settingsXML = new XML();
this.settingsXML.ignoreWhite = true;
this.settingsXML.onLoad = Proxy.create(this, settingsLoaded);
this.settingsXML.load(this.settingsFile);
}
/**
* Called when the main XML is loaded and initializes player's components: Controll Bar, Video Display and Share
*/
private function settingsLoaded() : Void {
this.settingsManager = new SettingsManager(this.settingsXML);
if (this.settingsManager.getOption("playerSize", "autoResize") || this.settingsManager.getOption("buttons").indexOf("fullScreen") != -1 || this.settingsManager.getOption("listeners", "doubleClick")) {
var stageListener : Object = new Object();
stageListener.onResize = Proxy.create(this, resize);
Stage.addListener(stageListener);
}
this.playerX = this._x;
this.playerY = this._y;
this.mcPreloader.mcBck.setColor(this.settingsManager.getColor("preloader", "background"));
this.mcPreloader.mcBck._alpha = this.settingsManager.getColor("preloader", "bckAlpha");
this.mcPreloader.mcTxt.setColor(this.settingsManager.getColor("preloader", "text"));
this.mcPreloader.mcRotCircle.setColor(this.settingsManager.getColor("preloader", "circle"));
this.mcBackground.useHandCursor = false;
this.mcBackground.setColor(this.settingsManager.getColor("playerBackground", "value"));
if (this.settingsManager.getOption("tooltip", "visible")) {
ToolTip.getInstance().init(Number(this.settingsManager.getOption("tooltip", "hideDelay")), this.settingsManager.getColor("tooltip", "bckColor"), this.settingsManager.getColor("tooltip", "txtColor"), Number(this.settingsManager.getColor("tooltip", "alpha")));
}
this.mcDescription.init(this.settingsManager);
this.mcControlsBar.init(this, this.mcDisplay, this.mcPreloader, this.mcPreview, this.mcMiddlePlayBtn, this.mcBackground, this.mcShare, this.settingsManager, this.mcPlaylist, this.mcDescription, this.mcCaption);
this.mcDisplay.init(this.mcControlsBar, this.mcPreloader, this.settingsManager);
this.mcShare.init(this.mcControlsBar, this.settingsManager, this.settingsFile);
this.mcCaption.init(this.settingsManager);
this.mcPlaylist.init(this.mcControlsBar, this.settingsManager);
this.resize();
this.mcControlsBar._visible = true;
}
/**
* Sets the new sizes and calls the resize functions for each of the player's compnents: Controll Bar, Video Display and Share
*/
private function resize() : Void {
var newSize : Number;
if (this.settingsManager.getOption("description", "visible")) {
if (this.tween.position != undefined) {
newSize = Math.round(Number(this.settingsManager.getOption("description", "size")) * this.tween.position);
} else {
newSize = Number(this.settingsManager.getOption("description", "size"));
}
} else {
newSize = 0;
}
var wProc : Number = (this.tween.position == undefined) ? 1 : this.tween.position;
if (Stage["displayState"] == "fullScreen") {
var myPoint : Object = new Object();
myPoint.x = 0;
myPoint.y = 0;
this.localToGlobal(myPoint);
this._x = Math.floor(this.playerX - myPoint.x);
this._y = Math.floor(this.playerY - myPoint.y);
this.playerW = Math.floor(Stage.width);
this.playerH = Math.floor(Stage.height);
} else {
this._x = Math.floor(this.playerX);
this._y = Math.floor(this.playerY);
if (this.settingsManager.getOption("playerSize", "autoResize")) {
this.playerW = Math.floor(Stage.width - this.playerX);
this.playerH = Math.floor(Stage.height - this.playerY);
} else {
this.playerW = Math.floor(Number(this.settingsManager.getOption("playerSize", "width")));
this.playerH = Math.floor(Number(this.settingsManager.getOption("playerSize", "height")));
}
}
this.mcControlsBar.resize(this.playerW - Number(this.settingsManager.getOption("playlist", "size")) * wProc, this.playerH - newSize);
if (this.settingsManager.getOption("controlsBar", "hide")) {
this.mcDisplay.resize(this.playerW - Number(this.settingsManager.getOption("playlist", "size")) * wProc, this.playerH - newSize);
} else {
this.mcDisplay.resize(this.playerW - Number(this.settingsManager.getOption("playlist", "size")) * wProc, this.playerH - this.mcControlsBar.controllerHeight - newSize);
}
this.mcPlaylist.resize(this.playerW, this.playerH);
this.mcCaption.resize(this.playerW, this.playerH - this.mcControlsBar.controllerHeight - newSize);
this.mcDescription.resize(this.playerW - Number(this.settingsManager.getOption("playlist", "size")), this.playerH);
this.mcShare.resize(this.playerW, this.playerH);
}
public function expandCollapse(pCollapse : Boolean) : Void {
var from : Number;
if (this.tween.position != null) {
from = this.tween.position;
this.tween.stop();
} else {
from = pCollapse ? 1 : 0;
}
if (pCollapse) {
this.tween = new Tween("this", "newProc", None.easeNone, from, 0, 0.2, true);
} else {
this.tween = new Tween("this", "newProc", None.easeNone, from, 1, 0.2, true);
}
this.tween.onMotionChanged = Proxy.create(this, resize);
this.tween.onMotionFinished = Proxy.create(this, resize);
}
/**
* Call this function to destroy the YooTube instance
*/
public function unload() : Void {
this.mcDisplay.unload();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
well then what do you mean?
um it's not resolved don't close it just explain what you want . if we really can't help you then you can close it.
ASKER
On an action script there is a script that puts out ?currVideo=11&currCateg=4 according to the video the player is watching in order to link back to that video.
The problem is that at times the url originating the call already has a http://website.com/?mid=867
And the result is this and it gives me an error.
http://website.com/?mid=867?currVideo=11&currCateg=4
So I was thinking if there wars a way to write something in the object tags that recognized if the player sits in a ? so that we can change it to a & or something. I am not quite sure what is the solutions.
The problem is that at times the url originating the call already has a http://website.com/?mid=867
And the result is this and it gives me an error.
http://website.com/?mid=867?currVideo=11&currCateg=4
So I was thinking if there wars a way to write something in the object tags that recognized if the player sits in a ? so that we can change it to a & or something. I am not quite sure what is the solutions.
this.clearStaf();
this.wasPlaying = pWasPlaying;
this.stafImage = pStafImage;
this.currLink = "?";
if (pCurrVideo != null) {
this.currLink += "currVideo=" + pCurrVideo;
}
if (pCurrCateg != null) {
if (this.currLink != "?") {
this.currLink += "&currCateg=" + pCurrCateg;
} else {
this.currLink += "currCateg=" + pCurrCateg;
}
}
"the player sits in a ?"
do you mean if the url has a ?
if so try this
http://blog.circlecube.com/2008/01/tutorial/get-current-url-to-flash-swf-using-an-external-interface-call/
you can then search the url for indexOf("?") to determine if it exists.
do you mean if the url has a ?
if so try this
http://blog.circlecube.com/2008/01/tutorial/get-current-url-to-flash-swf-using-an-external-interface-call/
you can then search the url for indexOf("?") to determine if it exists.
ASKER
Thank you.
ASKER
if (_root.htmlPage == undefined) {
_root.htmlPage = _root.playerPath + "index.html";
} else {
var pos : Number = _root.htmlPage.indexOf("cu
if(pos != -1) {
_root.htmlPage = _root.htmlPage.substring(0
}
if (_root.htmlPage.indexOf("http://"
_root.htmlPage = _root.playerPath + _root.htmlPage;
}
}
if (_parent.settingsFile == undefined) {
this.settingsFile = _root.playerPath + "settings.xml";
}else if (_parent.settingsFile.inde
this.settingsFile = _root.playerPath + _parent.settingsFile;
} else {
this.settingsFile = _parent.settingsFile;
}
Thanks in advance.
Open in new window