Flash Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignFlash Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 6th, 2009, 10:16 AM
justTom justTom is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 3 justTom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 36 sec
Reputation Power: 0
Sound does not work in my .swf file

Here's the situation. If I use Publish Setting and choose a different folder for the .swf and .html file that Flash CS3 will be generating then the audio/sound will not work when open the .html file in a browser. However, if I choose to the "Publish" option or "Publish Setting" but choose the same folder for the .html and .swf folder then the sound will work when opening the .html file inside a browser. But there is a problem with this approach. In my website, here's the file structure:

Quote:
http://www.mysite.com/departmentSite/myFlashFile.html
http://www.mysite.com/departmentSite/scripts/AC_RunActiveContent.js
http://www.mysite.com/departmentSite/FlashFile/myFlasFile.swf
http://www.mysite.com/departmentSite/FlashFile/audioFile/myBGMusic.mp3


Here's the code in the flash file for loading the audio file.

Code:
//start of sound section is for sound
var soundReq:URLRequest = new URLRequest("audioFiles/myBGMusic.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
//end of sound section

function onComplete(event:Event):void
{
    sound.play();
}


Ultimately, I want to embed the .swf in my .aspx page. Here's what I have in my .aspx page. The flash plays fine but no sound/audio when it should.

Code:
<head runat="server">
    <title>Untitled Page</title>
    <script src="scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <Bewise:FlashControl ID="FlashControl1" runat="server" 
            AlternativeImage="~/FlashFiles/e-Solicitations.gif" Height="400px" 
            MovieUrl="~/FlashFiles/e-Solicitations.swf" Width="375px" 
            XHTMLcompliant="True" />
    
    </div>
    </form>
</body>


The site file structure as shown above. Any suggestion is much appreciated.

Reply With Quote
  #2  
Old May 7th, 2009, 05:40 PM
scottyp2 scottyp2 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 13 scottyp2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 26 sec
Reputation Power: 0
Sound

Does the sound play properly outside the aspx page? I didn't notice any errors in your code. If you like I can send you a file that will work with stop and play buttons. Doesn't appear that I can attach a file in the forum.

Reply With Quote
  #3  
Old May 8th, 2009, 08:42 AM
justTom justTom is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 3 justTom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by scottyp2
Does the sound play properly outside the aspx page? I didn't notice any errors in your code. If you like I can send you a file that will work with stop and play buttons. Doesn't appear that I can attach a file in the forum.


Thanks! I got it working now. I didn't know that the path to the audio file is relative to the .html file and NOT to the .swf file.

However, with that said, why would Adobe make the path to the audio file relative to the .html file instead of the .swf file? The generated .html file does not work. And worst yet, when testing the flash inside of the Flash environment, it failed misserably with errors. In addition, it does not make sense to make the path to audio files or any other external files relative to the .html file. The .html file does not do anything besides being a container for the .swf file to do its thing. It's like, why does a cup (container) care if the water in it is from a bottle of water or from tap water? It just doesn't make sense to me.

Reply With Quote
  #4  
Old May 28th, 2009, 12:09 AM
WhiskeyShot WhiskeyShot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 6 WhiskeyShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 38 m 16 sec
Reputation Power: 0
Post hi

Quote:
Originally Posted by justTom
Here's the situation. If I use Publish Setting and choose a different folder for the .swf and .html file that Flash CS3 will be generating then the audio/sound will not work when open the .html file in a browser. However, if I choose to the "Publish" option or "Publish Setting" but choose the same folder for the .html and .swf folder then the sound will work when opening the .html file inside a browser. But there is a problem with this approach. In my website, here's the file structure:



Here's the code in the flash file for loading the audio file.

Code:
//start of sound section is for sound
var soundReq:URLRequest = new URLRequest("audioFiles/myBGMusic.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
//end of sound section

function onComplete(event:Event):void
{
    sound.play();
}


Ultimately, I want to embed the .swf in my .aspx page. Here's what I have in my .aspx page. The flash plays fine but no sound/audio when it should.

Code:
<head runat="server">
    <title>Untitled Page</title>
    <script src="scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <Bewise:FlashControl ID="FlashControl1" runat="server" 
            AlternativeImage="~/FlashFiles/e-Solicitations.gif" Height="400px" 
            MovieUrl="~/FlashFiles/e-Solicitations.swf" Width="375px" 
            XHTMLcompliant="True" />
    
    </div>
    </form>
</body>


The site file structure as shown above. Any suggestion is much appreciated.


if you just import the sound file manually into flash's library (file>import>to library) then right click it in your library and hit "linkage", check off "export for actionscript" and "export in first frame" and give it a linkage instance name, then you can refer to it in actionscript from the library rather than from an external folder. all you have to do is use this:

mySound = new Sound();
mySound.attachSound("linkage_name");
on (whatever the trigger is) {;
_root.mySound.start();
}

just use anything you want in place of mySound.
i don't know if that's what you're looking for, but that's one way to refer to a sound thats in the library.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignFlash Development > Sound does not work in my .swf file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek