<?php include("sample_utils.php"); // provides some utils and using mk $sndFN = "creak_closing.mp3"; $swfFN = "soundStart.swf"; $flasmFN = "f6_sound_preload.flm"; // flasm syntax file from where we'll inject mk assembled bytecode $snd = new MKsound_container("", $sndFN); // start a fresh sound data with soundID = 1 by default $sndAssetTD = $snd->set_linkage_name("creak"); // we'll use as linkage sound $sndTD = $snd->update_tagData(); // tag data $sndSSHTD = $snd->update_soundStreamHead(); // streaming sound settings $as = new MKActionScript_container(); // actionscript container VERY EXPERIMENTAL $frameTD1 = $as->assemble_from_file($flasmFN, 1); // compile frame #1 (0), contain a simple blind preload $frameTD2 = $as->assemble_from_file($flasmFN, 2); // compile frame #2 (1), attach sound and play $swf = new MKswf($swfFN); // a fresh new swf $swf->set_swfDir(SERVER_MKTMP); // we'll store in tmp $swf->add_tagData($sndTD); // start to populate, sound $swf->add_tagData($sndSSHTD); // ... streaming settings $swf->add_tagData($sndAssetTD); // ... sound linkage $swf->add_tagData($frameTD1); // ... actionscript for frame #1 $swf->add_tagData($frameTD2, 2); // ... actionscript form frame #2 $swf->swf_output(); // save $swfHeader = $swf->fetch_assoc(); // prepare to publish to the browser $str = render_swf_box($swfHeader, $imgDir, false); $str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>"; ?>
mp3 sound can be handled by mk to insert in swf files. It reads its properties to store the needed info for player and sound data. I use audacity for testing and ID3 "compatibile" (v1) header. I've noticed some quirks using v2 header so it is suggested to avoid those idtag.
For preloading issue you see a reference to MKflasm assembler, even in very experimental stage it compile without problem the given flasm syntax file. The bytecode is used to preload movie, wait for availability of sound and play it.
Note that sound was inserted as linkage, then used by bytecode. In the next samples we will see a sound event applied to button.
![]()