Results 1 to 8 of 8

Thread: problem with externally loaded swf

  1. #1
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default problem with externally loaded swf

    Hey!

    I have been trying to sort this problem out for a few days now without any joy! Its driving me crazy!

    Im creating a flash music quiz which loads in mp3 samples and questions from an xml file. This is working fine. What I want to do is change the enabled property of 2 movieclips in an externally loaded swf so when the mp3 is loaded the play button for the mp3 enables. Its working when I test it in flash but not when I test it outside? Its probably a quick fix but to be honest im lost as to what the problem could be?

    Hopefully somebody with a better understanding of AS can help me.

    my code looks like this...

    ////////////////////////////////////////////////////////////////////////////

    var songTrack:Sound = new Sound();

    songTrack.loadSound(qList[questionNbr].ans_z); // takes the mp3 from the xml
    function checkProgress (soundObj:Object):Void {
    var numBytesLoaded:Number = soundObj.getBytesLoaded();
    var numBytesTotal:Number = soundObj.getBytesTotal();
    var numPercentLoaded:Number = Math.floor(numBytesLoaded / numBytesTotal * 100);
    if (!isNaN(numPercentLoaded)) {
    trace(numPercentLoaded + "% loaded.");
    }
    };
    songTrack.onLoad = function (){
    songTrack.stop;
    displayLoad();

    };

    loaded_mc.play_btn.onRelease= function (){
    button_a.enabled= true;
    button_b.enabled= true;
    button_c.enabled= true;
    button_d.enabled= true;
    loaded_mc.play_btn.enabled= false;
    cover_mc.gotoAndPlay("fade");
    songTrack.start(1,0);
    };

    function displayLoad() {
    loaded_mc._alpha = 100;
    loaded_mc.play_btn.enabled= true;
    load_mc._alpha = 0;
    load_mc.enabled= false;
    };

    loaded_mc._alpha = 10;
    this.loaded_mc.play_btn.enabled= false;
    loaded_mc.enabled= false;
    button_a.enabled= false;
    button_b.enabled= false;
    button_c.enabled= false;
    button_d.enabled= false;


    stop();

    ////////////////////////////////////////////////////////////////////////////

    BTW

    this is the code in the external swf! I tried to make the links relative but yet it still wont work! Where's that baseball bat!?

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You need an on(load) section for the holder MC with an if/else statement. This will check when the mp3 is loaded button.enabled="true";

    something like:

    Code:
    onClipEvent (enterFrame) {
        if ( mp3.name.getBytesLoaded == mp3.name.getBytesTotal){
           buttonPlayInstance.enabled = "true";
        }
        else if ( mp3.name.getBytesLoaded != mp3.name.getBytesTotal){
                 buttonPlayInstance.enabled = "false";
        }
    }
    That should give you the idea.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks Blizzard for the reply!!

    I tried entering the code onto the holder_mc yet still it didnt work? Its weird, when i test it locally from within flash, simulate download it works fine but when I test it outside the code doesnt operate?

    I wonder could you look at the source and see if you can spot the problem?

    I have attached it to this post.

    once again thanks for the help!
    Last edited by Hu4ley; 11-23-2007 at 08:35 PM. Reason: conscience

  4. #4
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    success!

    I tested it on a web server and it worked?? You know why I was having this problem?

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    The structure of files and sources for Flash is flaky at best. Testing locally and on a server all files must be in the same base directory, some code types will look for the directory (XML, php in Flash, etc.) while other look through the Flash itself.

    Depending on the type and what you are trying to do it may or may not work in all three spots.

    It's hard to say which will do what, but testing locally through Flash and being on the server are usually the same, so that is really all you need to worry about. (For the most part)
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Ah i see.

    Well thanks for your help Blizzard. Much appreciated!

    btw

    Im just thinking... i included a few mp3's in that attachment for the example. Might be a good idea to remove them? Sharing music online etc?

    Thanks again

    Hurl

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You can click the edit button on that post, then go advanced and manage attachments, there will be the option to remove it
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    done

    ... now where's that bottle of Jack Daniels?

Bookmarks

Posting Permissions

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