This content has been marked as final. Show 5 replies
is this a trick question? is there some point to using that code instead of just using:
oops - my bad
file.substr(file.length - 3,3) == 'mp3'
if that code is in the file then the whole thing fails - just include one of them and its fine. Am I correct in thinking that the if statement would only include one of the as files or is there some idiosyncrosy where they would both be included regardless (much like the require in php3!)
there's no problem with your code. but you are making an error.
my guess is that you're defining file dynamically (as an mp3 file reference) and video.as is the code that's compiled, NOT audio.as
that's because you can't define file during run-time and have it affect that if-statement. file must be assigned during compile-time when your as files are included for compilation. in other words, #include statements are compiled into your swf when you publish your swf, NOT during run-time.
You are correct I reference a file dynamically... it is either mp3 or flv
So is my logic at fault?
I was of the impression that the if statement above would include audio.as if the file ended in mp3 and video.as if it didn't...
again, there is no problem with your code. the problem is you don't understand the #include directive.
when #include is encountered during compile-time (ie, when you publish your swf), flash includes the code in your as file in the published swf. once the swf is published, more code cannot be added to it so encountering an #include statement during run-time is irrelevant.