A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [RESOLVED] swf shows online as a blank box (CS4, .xml)

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    7

    resolved [RESOLVED] swf shows online as a blank box (CS4, .xml)

    Hello,
    I'm trying to make a simple Flash application to be placed on a web site. It is intended to take data from an .xml file and display it in the Flash movie. There are a number of buttons that display different nodes of the .xml file when clicked. (Not all the buttons are functional yet in this code; I know that.)

    It runs just fine in Flash. It even runs fine when I publish it and then run it by clicking on the html file on my computer.

    When I upload the html and swf files to my server, the html file works fine (gives me a solid colored background) but the swf is just a white box, nothing in it and no functionality.

    Something needs to be declared, imported or linked, I think, but I do not know what or how to do it. (Most irritating is the fact that the code is substantially taken from an online tutorial, with nary a word about this issue.)

    I'm using CS4. Many thanks for any helpful suggestions.

    -----------------
    var chineseSentence:Array=new Array();
    [many other Array vars deleted for space]

    var loader:URLLoader = new URLLoader();

    loader.addEventListener(Event.COMPLETE, loadXML);
    loader.load(new URLRequest("test.xml"));
    function loadXML(e:Event):void {
    var myxml = new XML(e.target.data);

    //var loop=myxml.SENTENCE.length();
    var loop:Number;
    loop=2;
    for(var i=0;i<loop;i++)
    {
    chineseSentence[i]=myxml.SENTENCE[i].CHINESE;
    [other assignments deleted for space]
    }
    gotoAndPlay(2);
    }
    stop();

    --------------------------------
    and on frame 2:
    var qno=0;

    function change_question() {
    statement.text=chineseSentence[qno];
    little_box.text=englishSentence[qno];



    trace ("question changed!");

    }//end of function change_question

    change_question();

    //button code (not completely finished yet)

    next_btn.addEventListener (MouseEvent.CLICK, ButtonAction1);
    function ButtonAction1(eventObject:MouseEvent) {
    qno++;change_question();
    }
    stop();

    //code to enable the "Play Audio" button
    play_btn.addEventListener (MouseEvent.CLICK, playAudio);
    function playAudio(evtObj:MouseEvent):void
    {//Create an instance of the Sound class
    var soundClip:Sound = new Sound();
    //Create a new SoundChannel Object
    var sndChannel:SoundChannel = new SoundChannel();
    //Load sound using URLRequest
    soundClip.load(new URLRequest("sent"+qno+".mp3"));
    //Create an event listener that wll update once sound has finished loading
    soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
    function onComplete(evt:Event):void {
    //Play loaded sound
    sndChannel = soundClip.play();
    }

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    It sounds like your file path is incorrect, especially if it all works correctly when published. From what I read, all three files need to be in the same directory level, is that correct? Are they posted in the same directory?
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    Hi,
    I checked...yep, they are all in the same directory. I even made a completely new directory and uploaded again, just to make sure.

    At one point I think I saw an error message about classes not having been (?) declared or something, and it mentioned the eventlistener for the sound player. Could there be something that is not being incorporated when I publish, that the player can get on my local machine? I just tried the Preview function (to html) and it does still work via html on my local machine.

  4. #4
    Senior Member
    Join Date
    May 2008
    Posts
    332
    I agree with samac1068, if it works on your local machine but not on you server, it's most likely a missing file or a pathing issue. Rarely... like never... does the actionscript work on the local machine and then magically change and throw errors on the server.
    How are you placing the flash .swf on the html page? Are you using any javascript file? If so has that file also been uploaded?
    Since there are so many variable involved, post a live link to the page so we can test.
    When you say "they" are all in the same directory, exactly which files are you talking about?
    Best wishes,
    Eye for Video
    www.cidigitalmedia.com

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    Hi,
    I'm publishing using the CS4 "publish" command, which produces an HTML file and a swf automatically.

    Files in the directory:
    cinderella.swf, cinderella.html, text.xml
    (also the .mp3 files)

    Might I have unwittingly messed up the "publish" settings?

  6. #6
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    Forgot the URL: http://www.chinesepronto.com/cinderella/cinderella.html
    (and BTW the xml file is correctly named "test.xml", the above is a typo)

  7. #7
    Senior Member
    Join Date
    May 2008
    Posts
    332
    Well according to your code:
    <param name="movie" value="cinderella.swf" />
    the .swf should be in the same folder as the .html page. But, direct downloading from that address returns "File not Found". So of course, the .swf cannot display. Test here...
    http://www.chinesepronto.com/cinderella/cinderella.swf
    Checking that folder directly shows that the .swf is Cinderella.swf, spelled with a cap.
    Using that in the address gets the .swf to download but I don't really see any actions available. So double check all the spelling and paths.
    If it still doesn't load, get rid of ALL that auto generated junk! just use something like this:
    Code:
    <object type="application/x-shockwave-flash" data="filename.swf" width="#" height="#">
    <param name="movie" value="filename.swf">
    </object>
    Edit for your .swf of course.
    Best wishes,
    EfV

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    BRILLIANT!!!!
    Thank you SO much. Using your html code works perfectly!!!

    (Also, thanks to everyone for being so nice about the problem. I seem to visit lots of forums with "newbie" forums where people don't bother to be so nice and helpful.) :-)

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