The correct way... valid code

Discussion in 'HTML & Website Design' started by oo7ml, Feb 16, 2009.

  1. #1
    What is the best (most valid) way to embed a flash file.

    Say we have a file called flash.swf which is 500 x 500. What is the correct code to use to insert this flash file into a page.

    Thanks in advance
     
    oo7ml, Feb 16, 2009 IP
  2. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #2
    ExtremeData, Feb 16, 2009 IP
  3. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #3
    I use this:

    <object data="flash.swf" type="application/x-shockwave-flash" width="xxx" height="xxx" ><param name="movie" value="flash.swf" /></object>
    Code (markup):
    Seems to work with most browsers, and validates as XHTML 1.0 Strict.
     
    Kerosene, Feb 16, 2009 IP
  4. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Hi Kerosene, your code is not the best one.
    You must use the object tag but the embed tag too (to work with all browsers).
    This is the minimum code you need to embed a Flash movie in a browser :
    
    <object width="500" height="500">
    <param name="movie" value="flash.swf">
    <embed src="flash.swf" width="500" height="500">
    </embed>
    </object>
    
    Code (markup):
     
    ExtremeData, Feb 16, 2009 IP
  5. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #5
    <embed> isn't valid.
     
    Kerosene, Feb 16, 2009 IP
  6. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #6
    Check what W3C says : http://www.w3schools.com/flash/flash_inhtml.asp

     
    ExtremeData, Feb 16, 2009 IP
  7. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #7
    W3schools.com is NOT W3C, and they don't mention that <embed> IS valid - because it's not.

    Run your <embed> code through the W3C validator. <embed> is not part of the XHTML specification and will not validate.
     
    Kerosene, Feb 16, 2009 IP
  8. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #8
    I know W3schools.com is NOT W3C, sorry for that.
    But I think a website is for visitators not for search engines or to be W3C valid.
    If a website is not W3C valid but works in all browsers is ok.But if is valid and not works in Netscape or another browser isn't ok.
     
    ExtremeData, Feb 16, 2009 IP
  9. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #9
    This thread is about validation, not usability:
    I generally don't bother to validate my own sites that use Flash, but sometimes it's a legal requirement to do so - some universities and government departments legally require their sites to be 100% W3C valid.

    Valid is valid. And no matter what you do, <embed> will never be part of the XHTML standards.

    :)
     
    Kerosene, Feb 16, 2009 IP