dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: where's my error?

  1. #1
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156

    where's my error?

    I've gone from mx 2004 to flash8 pro to cs3 pro. This sound.onLoad script worked just fine in the first two. But now I can't get it to work.



    Code:
    var game_sound:Sound = new Sound();
    game_sound.onLoad = function(success:Boolean):Void{
        if (success) {
            trace("Sound Loaded");
            game_sound.start(loops,1000);
    		game_sound.setVolume(20);
        }
    };
    game_sound.loadSound("atmosphe-PSION-3280_hifi.mp3", false);
    If it is in its own swf on one frame it works fine, but when I put it into another swf of mine I get an error.

    line 2 expected '{'
    line 10 unexpected '};'

    When I remove the :Void then the error goes away, but then the sound doesn't load. What's wrong?

  2. #2
    Member
    Join Date
    Sep 2003
    Location
    Verona, Italy
    Posts
    61
    with actionscript 3, "void" has replaced "Void" (note the uppercase).
    In addition, the event system has changed a lot, so I don't think you can use the onLoad....

  3. #3
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Set your publish settings to actionscript 2.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  4. #4
    Flash by name, Flash by nature
    Join Date
    May 2006
    Location
    Oslo, Norway
    Posts
    70
    As cancerinform says, your script is ActionScript 2.

    Converted to AS3 it will be something like:
    Code:
    var soundURL:String = "atmosphe-PSION-3280_hifi.mp3";
    var soundURLReq:URLRequest = new URLRequest(soundURL);
    var game_sound:Sound = new Sound(soundURLReq);
    game_sound.addEventListener(Event.COMPLETE, soundOnLoad);
    game_sound.addEventListener(IOErrorEvent.IO_ERROR, soundLoadError);
    
    function soundOnLoad (e:Event):void {
    	trace("Sound Loaded");
    	game_sound.play();
    }
    function soundLoadError (e:IOErrorEvent):void {
    	trace("Error: \n" + e);
    }

  5. #5
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I'll try that when I get home. Thanks

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