sample #17
export assets (linkage symbols)
  1. <?php
  2. include("sample_utils.php"); // provides some utils and using mk
  3.  
  4. $swfFN = "test_asset.swf"; // file to generate
  5.  
  6. $shape1 = new MKshape_container(); // the shape
  7. $shape1->add_fillStyle_solid("#FF0000"); // add a new fill color
  8. $shape1->add_rect(-50, -50, 100, 100); // draw a rectangle
  9. $shape1->add_fillStyle_solid("#660000"); // add a new fill color
  10. $shape1->add_circle(30, 0, 0); // draw a circle
  11. $shapeTD1 = $shape1->update_tagData(); // get binary tag data
  12. $shapePB1 = $shape1->update_place_tagData();
  13.  
  14. $mc = new MKmovieclip("", 2); // create new movieclip
  15. $mc->set_linkage_name("mc"); // assign a linkage name
  16. $mc->add_tagData($shapePB1, 1); // populate mc with placing settings
  17. $mcTD = $mc->update_tagData(); // get binary tag data from mc
  18. $mcAssetTD = $mc->update_linkage_tagData();
  19.  
  20. $swf = new MKswf($swfFN); // start a fresh swf
  21. $swf->set_swfDir(SERVER_MKTMP); // change default working dir
  22. $swf->set_swfVersion(7); // set version (flash mx 2004)
  23. $swf->set_fps(24); // set frames per second
  24.  
  25. $swf->add_tagData($shapeTD1); // populate with shape
  26. $swf->add_tagData($mcTD); // populate with mc
  27. $swf->add_tagData($mcAssetTD); // populate with linkage
  28.  
  29. $swf->swf_output(); // save to disk
  30.  
  31. $swfHeader = $swf->fetch_assoc();
  32.  
  33. $str = "<div style=\"background-color:#CCCCCC; width:700px; height:500px; padding:10px; text-align:center\">";
  34. $str .= render_swf_box($swfHeader, $imgDir, false);
  35. $str .= "<br/><strong>" .$swfFN ." created in :<br />";
  36. $str .= SERVER_MKTMP ."</strong><p>don't worry if it looks empty :P</div>";
  37. echo show_content($str, basename(__FILE__));
  38. ?>

Linkage Symbols are used at run-time by actionscript, they are like actors awaiting in the backstage, ready to let the show go on at your call. The movie created by this sample in effect will looks empty an unusable as is.

The main objective of creating movies with linkage symbols is to constitute the initial stage developing a whole flash app. Mk support actionscript partially at bytecode level with an approach very similar to flasm, see sample #18, you may use advanced open source developing tools such are:

The are useful video tutorial to get start in developing in flash, mk "can" be used instead of flash IDE e.g. in the video #07

mikrokosmos