A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Why does AS3 make everything so hard?!

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    Why does AS3 make everything so hard?!

    I've got a simple 3 screen flash movie. Each "screen" has frames in the timeline for animation. In the first screen, I need to play an audio file until it's over, then play a video, then another audio file, then stop until the user hits the Next button. On the second 2 screens, I need to play a single audio file and time screen animations to it.

    I tried hacking an mp3 player class, but, using the Back and Next button resulted in multiple sounds overlapping.

    I tried making a new sound class on each of the beginning frames, but I kept getting errors.

    I tried setting the AUDIO_COMPLETE command to play the timeline, but it started double calling itself and I couldn't clear it out...

    Anyone have any simple way to manage a few audio calls in a file??

    Thanks!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    ...and, to make it better, the client just added another screen with a 2 minute audio file that plays and needs some images, a video and more images timed to specific cues...

    uggg...

    makes me want to go back to as2...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    Does AS2 make it any easier? I think the evil in Actionscript is coding in the timeline. Anyways, what errors did you get with the Sound objects? And what is AUDIO_COMPLETE? Aren't you supposed to use EVENT.SOUND_COMPLETE?

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You may want to use a Singleton to play audio:
    http://flashscript.biz/Flash10/inshort/PlayOneSound.php
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Thanks, maybe it's just that I'm used to the quirks of AS2 and am still getting up to speed on the OOP of AS3.

    So, since I had some places where there were 2 audio files playing (background music over several narration pieces) and the fact that I have f4v files with and without audio, I ended up hard-coding everything with a new sound instance and channel for each audio file. Something like:
    Code:
    var s2_1:Sound = new Sound(new URLRequest("audio/Slide2.mp3"));
    var my_channel2_1:SoundChannel = new SoundChannel();
    my_channel2_1 = s2_1.play();
    my_channel2_1.addEventListener(Event.SOUND_COMPLETE, goNext2_1);
    function goNext2_1(myevent:Event):void
    {
    	s2_1.removeEventListener(Event.SOUND_COMPLETE, goNext2_1);
    	this.play();
    }
    and each video file is handled like:
    Code:
    video3_flv.addEventListener(VideoEvent.COMPLETE, onComplete);
    function onComplete(evt:VideoEvent)
    {
    	this.play();
    }
    video3_flv.addEventListener(Event.REMOVED_FROM_STAGE, cleanUp);
    function cleanUp(e:Event)
    {
    	e.target.stop();
    	e.target.removeEventListener(VideoEvent.COMPLETE, onComplete);
    	e.target.removeEventListener(Event.REMOVED_FROM_STAGE, cleanUp);
    }
    So, that's all working fine, although it's a pain to update...HOWEVER, now I have to get the play/pause button to work and, somehow, I need to know if it's currently playing an audio or video file...I suppose I can set a variable with the name(s) of the existing element on the screen so it will know if it's a video or audio piece being played...although, that's going to be a pain to go back and add in...
    ugg...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

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