SpriteProc() public method

Calls a delegate method on each descendant sprite in this sprite.
public SpriteProc ( SpriteProcessor sp ) : void
sp SpriteProcessor
return void
示例#1
0
 /// <summary>
 /// Calls a delegate method on each descendant sprite in this sprite.
 /// </summary>
 /// <param name="sp"></param>
 public void SpriteProc(SpriteProcessor sp)
 {
     foreach (Frame f in FrameList)
     {
         foreach (IDisplayListItem dli in f.DisplayList)
         {
             ICharacterReference cr = dli as ICharacterReference;
             if (cr != null)
             {
                 Sprite child = cr.Character as Sprite;
                 if (child != null)
                 {
                     sp(child);
                     child.SpriteProc(sp);
                 }
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// Creates an instance from a referenced SWF.
        /// </summary>
        /// <param name="insTag">The instance tag.</param>
        /// <param name="swf">The SWF to place the instance into.</param>
        /// <param name="className">Name of the class for the new clip.</param>
        /// <param name="importSwf">The SWF to import as a clip.</param>
        private void CreateInstanceFromSWF(XPathNavigator insTag, SWF swf, string className, SWF importSwf)
        {
            if (!swf.HasClass)
            {
                /* Can't create instances if the parent timeline has no code now can we? */
                swf.GenerateTimelineScripts();
            }

            bool isAdobeClassname = className.StartsWith("flash.")
                || className.StartsWith("fl.")
                || className.StartsWith("adobe.")
                || className.StartsWith("air.")
                || className.StartsWith("flashx.");

            if (isAdobeClassname && importSwf.HasClass)
            {
                /* Can't rename a class to an Adobe class name. That's bonkers. */
                throw new SwiffotronException(
                        SwiffotronError.BadInputXML,
                        this.Context.Sentinel("InstanceClassNameInappropriate"),
                        "You can't rename a timeline class to a reserved adobe classname (" + className + "), SWF: " + importSwf.Context);
            }

            if (className == string.Empty)
            {
                if (importSwf.Class == null)
                {
                    /* No class name is fine if the imported SWF has no class to rename. We need
                     * a class to bind it to though, so let's make it MovieClip, just like
                     * real flash. */
                    className = "flash.display.MovieClip";
                }
                else
                {
                    throw new SwiffotronException(
                            SwiffotronError.BadInputXML,
                            this.Context.Sentinel("MainTimelineInstanceNotRenamed"),
                            "An external instance with timeline code must be explicitely renamed with the instance tag's class attribute.");
                }
            }

            if (className == "flash.display.MovieClip")
            {
                Sprite spr = new Sprite(importSwf, swf);

                this.CreateInstanceIn(
                        insTag.GetAttribute(XMLHelper.AttrID, string.Empty),
                        swf,
                        insTag,
                        spr,
                        className);
            }
            else
            {
                Sprite spr = new Sprite(importSwf, swf, className);

                this.CreateInstanceIn(
                        insTag.GetAttribute(XMLHelper.AttrID, string.Empty),
                        swf,
                        insTag,
                        spr,
                        className);

                spr.SpriteProc(delegate(Sprite s)
                {
                    if (s.Class != null && !(s.Class is AdobeClass))
                    {
                        /* ISSUE 29: Only do this if the class hasn't already been bound. */
                        swf.FirstScript.Code.GenerateClipClassBindingScript(s);
                    }
                });

                if (spr.Class != null)
                {
                    swf.FirstScript.Code.GenerateClipClassBindingScript(spr);
                }
            }
        }