?
Solved

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

Posted on 2011-05-12
11
Medium Priority
?
1,196 Views
Last Modified: 2012-08-14
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();
0
Comment
Question by:Whitehorsevideo
  • 6
  • 5
11 Comments
 
LVL 5

Expert Comment

by:edchipman
ID: 35756711
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.
0
 

Author Comment

by:Whitehorsevideo
ID: 35756809
Thanks Ed, I'd love to see the auto path code you're offering.
Bill
0
 
LVL 5

Expert Comment

by:edchipman
ID: 35756861
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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:edchipman
ID: 35756867
Adding that to the top of your code should get you on your way :)
0
 

Author Comment

by:Whitehorsevideo
ID: 35757124
Thanks, I'll try as soon as I get in. Is this AS2 or AS3?
0
 
LVL 5

Expert Comment

by:edchipman
ID: 35757177
AS3
0
 

Author Comment

by:Whitehorsevideo
ID: 35762318
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
0
 
LVL 5

Expert Comment

by:edchipman
ID: 35764311
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.
0
 

Author Comment

by:Whitehorsevideo
ID: 35765067
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.
0
 
LVL 5

Accepted Solution

by:
edchipman earned 2000 total points
ID: 35769185
Ya you may have to use my code described above looks like they require absolute paths. Give this a shot, put it right at the top above "VidPlayer1.visible=false".

This should get you on your way :), also if you can remove the path from the FLVPlayback components so they won't try to load when the swf starts up.
var srcURL='';
var temp:Array = stage.loaderInfo.url.split("/");
srcURL=temp.splice(0, temp.length-1).join("/");


VidPlayer1.source=srcURL+'/video1.flv';
VidPlayer2.source=srcURL+'/video2.flv';
VidPlayer3.source=srcURL+'/video3.flv';
VidPlayer4.source=srcURL+'/video4.flv';

Open in new window

0
 

Author Comment

by:Whitehorsevideo
ID: 35778853
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!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question