<?php include("sample_utils.php"); // provides some utils and using mk $swfFN = "test_mk_movieclip01.swf"; // swf file that we will create $mad["rotation"] = 89; // ... that will contain $mad["x"] = 0; // placing settings, x $mad["y"] = 0; // ... y $mad["width"] = 200; // ... width and ... $mad["height"] = 200; // height $colors[0] = get_color_array("#FFFF00"); // two colors, yellow ... $colors[1] = get_color_array("#FF0000"); // ... and red $sc = new MKshape_container(); // create ... $sc1 = new MKshape_container(); // two shapes $sc1->set_itemID(2); // assign item id to the last shape // the first have item id = 1 by default $sc1->add_gradient_fill(LINEAR_GRADIENT_FILL, $mad); // add gradient fill $sc1->add_rect(0, 0, 200, 200); // draw a rectangle, it will be the background $mad["x"] = -50; // setup a new placing settings $mad["y"] = -50; // ... $mad["width"] = 100; // ... $mad["height"] = 100; // ... $mad["rotation"] = 0; // ... $sc->add_gradient_fill(RADIAL_GRADIENT_FILL, $mad); // a new gradient fill, for the foreground shape $coords = get_coords_star(0, 0, 50); // get star coordinates $sc->add_mixed_poly($coords); // draw star $mc = new MKmovieclip(); // create new movieclip $mc->set_spriteID(3); // with its item id $mc->add_tagData($sc->update_place_tagData(), 1); // place the star in the first frame of mc for($i = 4.5, $k = 2; $i < 72; $i += 4.5, $k++){ // rotate by 4.5 degree $sc->rotate($i,true); // assign rotation $mc->add_tagData($sc->update_place_tagData(), $k); // get binary tag data } $s1 = $sc1->update_tagData(); // get binary tag data from shapes $s2 = $sc->update_tagData(); // .. $mcTagData = $mc->update_tagData(); // get binary tag data from mc $swf = new MKswf($swfFN); // create new swf $swf->set_stageWidth(200); // setup canvas $swf->set_stageHeight(200); // ... $swf->set_fps(24); // frames per second $swf->set_swfDir(SERVER_MKTMP); // set working directory $swf->add_tagData($s1); // start to populate swf $swf->add_tagData($s2); // ... $swf->add_tagData($mcTagData); // ... $po = new MKplaceObject2("", 3, 3); // new placing settings $po->set_position(100, 100); // ... $swf->add_tagData($sc1->update_place_tagData()); // ... $swf->add_tagData($po->update_tagData()); // ... $swf->swf_output(); // write to disk $swfHeader = $swf->fetch_assoc(); // prepare to publish $str = render_swf_box($swfHeader, $imgDir, false); $str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>"; ?>
movieclips (or sprites, as sometime defined in the swf ff specification) are object with their own timeline, they don't define any new contrib, they simply use what is defined in the main timeline (there are some exception e.g. actionscript containers). They support control tags, mandatory for placing objects and satisfy the rules of well-formed timeline. A movieclip may use items defined BEFORE it appear in the main timeline, in case of nested movieclips, that is a movieclip inside another, the inner (child) mc must be defined before the outer (parent) and all are stored in the main timeline.
This method allows to simplify swf structure analysis avoiding recursions (that are well known as prone to errors).
So, if we want to create a movieclip, we first have to define the item that will be used by that mc.
Another crucial advantage derived from using movieclips is at actionscript level, the real potential of flash movie is bound to the scripting features offered by this language.