Link to home
Start Free TrialLog in
Avatar of Whitehorsevideo
WhitehorsevideoFlag for United States of America

asked on

Adobe Flash CS5 HTML/SWF work locally but not from webserver

I have a project which Debugs fine and publishes html/swf files which work well locally. However when I move/copy folder or upload to webserver the FLVPlayback components don't show. I believe it's a relative paths problem, even though I have used the instance.source command.
AS3, Win XP, Win Inet explorer
Sigh... When I try to upload the .FLA file for you I get the following stupidity even though .Fla is in the list of supported types... I hate computers
"The extension of one or more files in the archive is not in the list of allowed extensions: bin/8g1b9l0f102.dat"
So, in through the back door...

import flash.events.MouseEvent;
import fl.video.VideoEvent;

// Assign the PlayBut1 instance to the VidPlayer1 instance VidPlayer1.playbutton = PlayBut1;
// Assign the PlayBut2 instance to the VidPlayer2 instance VidPlayer2.playbutton = PlayBut2;
// Assign the PlayBut3 instance to the VidPlayer3 instance VidPlayer3.playbutton = PlayBut3;
// Assign the PlayBut4 instance to the VidPlayer4 instance VidPlayer4.playbutton = PlayBut4;

VidPlayer1.source = "1.flv";
VidPlayer2.source = "2.flv";
VidPlayer3.source = "3.flv";
VidPlayer4.source = "4.flv";

PlayBut1.addEventListener(MouseEvent.CLICK,button1Click);
function button1Click(event:MouseEvent):void{
      PlayBut1.alpha=0;
};

VidPlayer1.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd1);
function FLVPlayBackEnd1(evt:VideoEvent):void{
      PlayBut1.alpha=100;
      var url:String = "http://www.whitehorsevideo.com";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};
stop();

PlayBut2.addEventListener(MouseEvent.CLICK,button2Click);
function button2Click(event:MouseEvent):void{
      PlayBut2.alpha=0;
};

VidPlayer2.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd2);
function FLVPlayBackEnd2(evt:VideoEvent):void{
      PlayBut2.alpha=100;
      var url:String = "http://www.whitehorsevideo.com";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};
stop();

PlayBut3.addEventListener(MouseEvent.CLICK,button3Click);
function button3Click(event:MouseEvent):void{
      PlayBut3.alpha=0;
};

VidPlayer3.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd3);
function FLVPlayBackEnd3(evt:VideoEvent):void{
      PlayBut3.alpha=100;
      var url:String = "http://www.whitehorsevideo.com";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};
stop();

PlayBut4.addEventListener(MouseEvent.CLICK,button4Click);
function button4Click(event:MouseEvent):void{
      PlayBut4.alpha=0;
};

VidPlayer4.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd4);
function FLVPlayBackEnd4(evt:VideoEvent):void{
      PlayBut4.alpha=100;
      var url:String = "http://www.whitehorsevideo.com";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};
stop();
Avatar of edchipman
edchipman
Flag of Canada image

In flash paths are relative to the page displaying the content. So if your swf is in say /content/myflash.swf and your html file is /index.html. Then it looks for your flv files in /.

So make sure you eather use full paths to your flv files or if you like I can provide code to determine this automatically.
Avatar of Whitehorsevideo

ASKER

Thanks Ed, I'd love to see the auto path code you're offering.
Bill
Here have a look at this, srcURL will contain a path without a trailing slash. So for your video's you would concat it onto the start like so.

VidPlayer1.source = srcURL+"/1.flv";
var srcURL='';

var temp:Array = stage.loaderInfo.url.split("/");
srcURL=temp.splice(0, temp.length-1).join("/");

Open in new window

Adding that to the top of your code should get you on your way :)
Thanks, I'll try as soon as I get in. Is this AS2 or AS3?
Ed,
I've been redesigning this element, hence the delayed reply. Everythings still working locally just fine, but AS3 will only (apparently) accept absolute paths.  In the best of all possible worlds I'd like to drop all relevant files into a folder on the server and do a direct http:// to the html page. Any idea where I'm going stupid?
Thanks,
Bill
Well AS3 will allow for relative paths but its relative to the html file your viewing so if the swf is in the same directory as your html file you should be fine using relative paths.
Hi, The problem is in the .swf. The html generated by flash publish finds and displays the .swf fine and when I click on a play button the visibility parameters function but the FLV does not appear or play. The http: call at the end never happens. It just freezes. Refreshing the page resets the smf to the starting state and I can repeat the process.

Try it here. http://www.whitehorsevideo.com/Test7.html

If I copy the project files to a thumb drive and open the .FLA project it loses track of the .flvs even though they are in the same folder with everything else. I get the following error:

The video player is in the connection error state. It enters this state when a video stream attempted to load but was unsuccessful. There are two possible reasons for the error: no connection to the server or the stream was not found.

In the properties panel of the FLVPlayback instances the source is set to Comp1_1.flv . I've deleted the absolute path that Flash generates on video import, but it has no effect. The darned thing is still looking for a absolute location...

Here's the currnet Actions code:

import flash.events.MouseEvent;
import fl.video.VideoEvent;
import fl.video.FLVPlayback
import flash.display.Stage;

VidPlayer1.visible=false
VidPlayer2.visible=false
VidPlayer3.visible=false
VidPlayer4.visible=false

PlayBut1.enabled=true
PlayBut2.enabled=true
PlayBut3.enabled=true
PlayBut4.enabled=true

PlayBut1.addEventListener(MouseEvent.CLICK, fl_ClickToPlayVideo_1);
function fl_ClickToPlayVideo_1(event:MouseEvent):void
{
      PlayBut1.enabled=false
      PlayBut2.enabled=false
      PlayBut3.enabled=false
      PlayBut4.enabled=false
      VidPlayer1.visible=true
      VidPlayer1.play();
}

VidPlayer1.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd1);
function FLVPlayBackEnd1(evt:VideoEvent):void{
      VidPlayer1.visible=false
      PlayBut1.enabled=true
      PlayBut2.enabled=true
      PlayBut3.enabled=true
      PlayBut4.enabled=true
      var url:String = "http://www.wheelhousecommunications.com/index.php";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};

PlayBut2.addEventListener(MouseEvent.CLICK, fl_ClickToPlayVideo_2);
function fl_ClickToPlayVideo_2(event:MouseEvent):void
{
      PlayBut1.enabled=false
      PlayBut2.enabled=false
      PlayBut3.enabled=false
      PlayBut4.enabled=false
      VidPlayer2.visible=true
      VidPlayer2.play();
}

VidPlayer2.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd2);
function FLVPlayBackEnd2(evt:VideoEvent):void{
      VidPlayer2.visible=false
      PlayBut1.enabled=true
      PlayBut2.enabled=true
      PlayBut3.enabled=true
      PlayBut4.enabled=true
      var url:String = "http://www.wheelhousecommunications.com/index.php";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};

PlayBut3.addEventListener(MouseEvent.CLICK, fl_ClickToPlayVideo_3);
function fl_ClickToPlayVideo_3(event:MouseEvent):void
{
      PlayBut1.enabled=false
      PlayBut2.enabled=false
      PlayBut3.enabled=false
      PlayBut4.enabled=false
      VidPlayer3.visible=true
      VidPlayer3.play();
}

VidPlayer3.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd3);
function FLVPlayBackEnd3(evt:VideoEvent):void{
      VidPlayer3.visible=false
      PlayBut1.enabled=true
      PlayBut2.enabled=true
      PlayBut3.enabled=true
      PlayBut4.enabled=true
      var url:String = "http://www.wheelhousecommunications.com/index.php";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};

PlayBut4.addEventListener(MouseEvent.CLICK, fl_ClickToPlayVideo_4);
function fl_ClickToPlayVideo_4(event:MouseEvent):void
{
      PlayBut1.enabled=false
      PlayBut2.enabled=false
      PlayBut3.enabled=false
      PlayBut4.enabled=false
      VidPlayer4.visible=true
      VidPlayer4.play();
}

VidPlayer4.addEventListener(VideoEvent.COMPLETE,FLVPlayBackEnd4);
function FLVPlayBackEnd4(evt:VideoEvent):void{
      VidPlayer4.visible=false
      PlayBut1.enabled=true
      PlayBut2.enabled=true
      PlayBut3.enabled=true
      PlayBut4.enabled=true
      var url:String = "http://www.wheelhousecommunications.com/index.php";
      var request:URLRequest = new URLRequest(url);
      try {
      navigateToURL(request, "_self");
      } catch (e:Error) {
      trace("Error occurred!");
      }
};

stop();

This making me crazy because if I can just get it relative it's ready to deploy. Curse you Adobe!
Thanks for your help Ed.
ASKER CERTIFIED SOLUTION
Avatar of edchipman
edchipman
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ed, You get the solution. Thanks for all your help. It still doesn't work on the web server, but I don't think it's a flash problem. Looking like a problem with the host. Code works great everywhere else.

ED, ED, He's da man.
If he can't do it, no one can.
YaaaaAAAYY ED!