A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Problem embeding swf in index.php

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    38

    Problem embeding swf in index.php

    I'm trying to embed an swf file in a .php file.
    When both files (php & swf) are in the same directory (mysite.com/), works perfectly.
    Here is the code I put in php file (mysite.com/my.php)(some is replaced by 'blah blah' or erased, for short):
    Code:
    <object classid=blah blah...codebase=blah blah...>
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="my.swf" />
    <embed src="my.swf"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
    But when I move 'my.swf' in 'mysite.com/mydir' it doesn't work (even though I change the path in the code):
    Code:
    <object classid=blah blah...codebase=blah blah...>
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="mydir/my.swf" />
    <embed src="mydir/my.swf"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
    I also tried:
    '/mydir/my.swf'
    './mydir/my.swf'
    'mysite.com/mydir/my.swf'.
    Nothing. Worked only when in 'mysite.com/'.
    Last edited by panoss; 05-16-2012 at 11:30 AM.

  2. #2
    Senior Member
    Join Date
    Sep 2010
    Posts
    324
    Does your .swf load/use ANY other assets (photos, videos, xml files)?
    Is "mydir" the exact spelling of an existing folder directly under the root folder?
    php pages are often difficult to work with since the actual Web page may be being constructed on the fly from many different "building blocks". This can make pathing a little difficult.
    I find it often best to use absolute addresses to avoid the "dynamic movement" issues of building .php pages.
    So
    Code:
    <param name="movie" value="mydir/my.swf" />
    should be:
    Code:
    <param name="movie" value="http://www.mysite.com/mydir/my.swf/>
    and same for the <embed>
    Best wishes,
    Video Man

  3. #3
    Member
    Join Date
    Aug 2008
    Posts
    38
    Let me make some things clearer:
    1. I must say that I have TWO files: my.swf and my_preloader.swf.
    The preloader gets loaded first. Then it loads my.swf with commands:
    Code:
    this.createEmptyMovieClip("container", "100");
    my_mc = new MovieClipLoader();
    my_mc.loadClip("my.swf", "container");
    When files are in my mysite.com/ loads perfectly.
    When files are in mysite.com/mydir doesn't load.

    I changed
    my_mc.loadClip("my.swf", "container");
    to
    my_mc.loadClip("mysite.com/mydir/my.swf", "container");
    And now there is a difference: it shows the coundown of my preloader, which goes up to 100% and then stops (instead of loading the my.swf).

    (I also tried the <param name="movie" value="http://www.mysite.com/mydir/my.swf/>) but there was no change.
    I think it has something to do with 'my_mc.loadClip('.

  4. #4
    Senior Member
    Join Date
    Sep 2010
    Posts
    324
    Since you are loading other Flash assets... the second .swf, then the pathing from the .swf doing the loading to the .swf it is loading should be relative to (starting from) the Web page, not the physical location of the actual .swf
    So if you have one .swf being used on a Web page which is in the site root and it loads a second .swf, then this would be the path:
    Code:
    my_mc.loadClip("mydir/my.swf", "container");
    You could also use an absolute address, which must include the "http://www." part, like this:
    Code:
    my_mc.loadClip("http://www.mysite.com/mydir/my.swf", "container");
    but you'll run into security issues when testing loacally... so it's a little more of a hassle
    and the HTML code would include the param:
    Code:
    <param name="movie" value="http://www.mysite.com/mydir/my_preloader.swf/>
    But I'm not sure how you are getting the preloader to work in the method you are using.
    Typically the preloader is in the first few frames of the main .swf and the measurement of getBytesTotal compared to getBytesLoaded (of preloader and main .swf combined) is presented as a %. Once BOTH the preloader section and the main section of the one single .swf is completely loaded, then the timeline moved to the first frame of the main sections and begins the display.
    Not sure how you are measuring the combined bytes of both .swfs before you load the main .swf.
    Best wishes,
    Video Man

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center