Log in

View Full Version : problem with externally loaded swf



Hu4ley
11-21-2007, 11:26 AM
Hey!

I have been trying to sort this problem out for a few days now without any joy! Its driving me crazy!

Im creating a flash music quiz which loads in mp3 samples and questions from an xml file. This is working fine. What I want to do is change the enabled property of 2 movieclips in an externally loaded swf so when the mp3 is loaded the play button for the mp3 enables. Its working when I test it in flash but not when I test it outside? Its probably a quick fix but to be honest im lost as to what the problem could be?

Hopefully somebody with a better understanding of AS can help me.

my code looks like this...

////////////////////////////////////////////////////////////////////////////

var songTrack:Sound = new Sound();

songTrack.loadSound(qList[questionNbr].ans_z); // takes the mp3 from the xml
function checkProgress (soundObj:Object):Void {
var numBytesLoaded:Number = soundObj.getBytesLoaded();
var numBytesTotal:Number = soundObj.getBytesTotal();
var numPercentLoaded:Number = Math.floor(numBytesLoaded / numBytesTotal * 100);
if (!isNaN(numPercentLoaded)) {
trace(numPercentLoaded + "% loaded.");
}
};
songTrack.onLoad = function (){
songTrack.stop;
displayLoad();

};

loaded_mc.play_btn.onRelease= function (){
button_a.enabled= true;
button_b.enabled= true;
button_c.enabled= true;
button_d.enabled= true;
loaded_mc.play_btn.enabled= false;
cover_mc.gotoAndPlay("fade");
songTrack.start(1,0);
};

function displayLoad() {
loaded_mc._alpha = 100;
loaded_mc.play_btn.enabled= true;
load_mc._alpha = 0;
load_mc.enabled= false;
};

loaded_mc._alpha = 10;
this.loaded_mc.play_btn.enabled= false;
loaded_mc.enabled= false;
button_a.enabled= false;
button_b.enabled= false;
button_c.enabled= false;
button_d.enabled= false;


stop();

////////////////////////////////////////////////////////////////////////////

BTW

this is the code in the external swf! I tried to make the links relative but yet it still wont work! Where's that baseball bat!?

BLiZZaRD
11-21-2007, 02:56 PM
You need an on(load) section for the holder MC with an if/else statement. This will check when the mp3 is loaded button.enabled="true";

something like:



onClipEvent (enterFrame) {
if ( mp3.name.getBytesLoaded == mp3.name.getBytesTotal){
buttonPlayInstance.enabled = "true";
}
else if ( mp3.name.getBytesLoaded != mp3.name.getBytesTotal){
buttonPlayInstance.enabled = "false";
}
}


That should give you the idea.

Hu4ley
11-22-2007, 01:26 PM
Thanks Blizzard for the reply!!

I tried entering the code onto the holder_mc yet still it didnt work? Its weird, when i test it locally from within flash, simulate download it works fine but when I test it outside the code doesnt operate?

I wonder could you look at the source and see if you can spot the problem?

I have attached it to this post.

once again thanks for the help!

Hu4ley
11-22-2007, 01:58 PM
success!

I tested it on a web server and it worked?? You know why I was having this problem?

BLiZZaRD
11-22-2007, 08:43 PM
The structure of files and sources for Flash is flaky at best. Testing locally and on a server all files must be in the same base directory, some code types will look for the directory (XML, php in Flash, etc.) while other look through the Flash itself.

Depending on the type and what you are trying to do it may or may not work in all three spots.

It's hard to say which will do what, but testing locally through Flash and being on the server are usually the same, so that is really all you need to worry about. (For the most part)

Hu4ley
11-23-2007, 02:13 PM
Ah i see.

Well thanks for your help Blizzard. Much appreciated!

btw

Im just thinking... i included a few mp3's in that attachment for the example. Might be a good idea to remove them? Sharing music online etc?

Thanks again

Hurl

BLiZZaRD
11-23-2007, 03:50 PM
You can click the edit button on that post, then go advanced and manage attachments, there will be the option to remove it ;)

Hu4ley
11-23-2007, 08:38 PM
done :)

... now where's that bottle of Jack Daniels?