Click to See Complete Forum and Search --> : Flash - loading an external swf file


borboleta
03-09-2009, 10:35 AM
Good day to all flashers!

I have a flash site (as3) with many buttons, and each button loads an external .swf file.

I'm having some trouble on loading an external .swf file containing video.
I would like this video starts to work where you click on the button to open a corresponding video in the video player and stops wenn you click another button.

Any assistance would be most helpful.


import flash.events.MouseEvent;
import fl.transitions.*;
import fl.transitions.easing.*;


stop();

var sahne=root;
mainscroller.scroller.clip5.stop();

but1.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

//this loader is used to load the external swf files
var loader:Loader;

//URLRequest stores the path to the file to be loaded
var urlRequest:URLRequest;

// _root.imagewidth defines the width of the image//


var imagewidth:Number;
var speed:Number;
var xposnew:Number;

sahne.imagewidth = 720;

// _root.speed defines the speed of the sliding images//

sahne.speed = 3;

/* _root.trig.xposnew defines the x position of the
sliding images */

sahne.trig.xposnew = -(sahne.imagewidth);

//but1.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

but1.addEventListener(MouseEvent.CLICK, buttonClicked);
but2.addEventListener(MouseEvent.CLICK, buttonClicked);
but3.addEventListener(MouseEvent.CLICK, buttonClicked);
but4.addEventListener(MouseEvent.CLICK, buttonClicked);
but5.addEventListener(MouseEvent.CLICK, buttonClicked);


function buttonClicked(evt:MouseEvent):void {
loader = new Loader();

if(evt.target == but1){
sahne.trig.xposnew = -(sahne.imagewidth);
urlRequest = new URLRequest("movieClips/page1.swf");
loader.load(urlRequest);

}

else if(evt.target == but2){
sahne.trig.xposnew = -((sahne.imagewidth)*2);
urlRequest = new URLRequest("movieClips/page2.swf");
loader.load(urlRequest);

}

else if(evt.target == but3){
sahne.trig.xposnew = -((sahne.imagewidth)*3);
urlRequest = new URLRequest("movieClips/page3.swf");
loader.load(urlRequest);

}

else if(evt.target == but4){
sahne.trig.xposnew = -((sahne.imagewidth)*4);
urlRequest = new URLRequest("movieClips/page4.swf");
loader.load(urlRequest);

}

else{
sahne.trig.xposnew = -((sahne.imagewidth)*5);
urlRequest = new URLRequest("movieClips/page5.swf");
loader.load(urlRequest);

}

mainscroller.scroller.addChild(loader);
}

//but1.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

Eye for Video
03-09-2009, 10:23 PM
So do you mean that swfs without video will load and play? Have you tested loading a simple swf without video? Have you tested the .swf with video... and separately that .swf works just fine?
Does the swf have the video in the main timeline or does the swf load a separate .flv file?
Who knows, maybe this is just a simple pathing problem.
Best wishes,
EfV

borboleta
03-10-2009, 02:59 AM
Hi!

thank you very much for your answer.

Yes, the swfs without video load and play perfectly. I have tested all swf files without video and works. The .swf with video works fine.

The swf loads a separate .flv file.

Do you have any hint?

Best wishes

Eye for Video
03-10-2009, 11:20 AM
I'm wondering if it's just a pathing problem, since everything seems to work when tested by itself. Often when a swf is placed on an html page, the path back to the swf, xml file, or the flv can be confusing. Just remember that the path to each of those will be relative to the new location on the html page.
A quick test for this would be to place a copy of the video player swf on the same page you are trying to get the video to play on... no button.. just embed the the swf and see if it can find the correct path to the .flv and play the video. If it does not, the path coded in the Actionscript of the swf will have to be changed or the location of the flv will have to be changed.
Did you also create the swfs that are playing the video? so someplace in there will be a path to the .flv... something like
ns.play("video1.flv");
So in this case the flv must be in the same folder as the swf.
But let's say that the original path relative to the swf is:
ns.play("videos/video1.flv");
Taking that same swf and placing it on an html page which uses this path back to the swf
movieClips/page5.swf
Now relative to the location on the html page, the path from the swf back to the flv has changed. From that page the new path would be
ns.play("movieClips/videos/video1.flv");
So that would have to be changed or the video folder would have to be moved up one folder level, just one level below the movie clip folder.
Hopefully this will help provide some answers.
Best wishes,
EfV

borboleta
03-11-2009, 10:48 AM
Thank you very much.

Now it works perfectly.

Best wishes!