Пример #1
0
        void readDefines(byte[] data, Cursor cursor)
        {
            int len      = Utils.ReadLength(data, cursor);
            int newIndex = cursor.index + len;

            int maxcharacterId = Utils.ReadInt32(data, cursor);
            int definesCount   = Utils.ReadInt32(data, cursor);

            chId_defs     = new TagDefine[maxcharacterId + 1];
            classNameDefs = new Dictionary <string, TagDefine> (definesCount / 4);

            for (int i = 0; i < definesCount; i++)
            {
                TagDefine define = parseDefine(this, data, cursor);

                if (define != null)
                {
                    chId_defs[define.characterId] = define;
                    if (define is TagDefine && (define as TagDefine).className != null)
                    {
                        classNameDefs[(define as TagDefine).className] = define;
                    }
                }
            }
            cursor.index = newIndex;
        }
Пример #2
0
        public string trace(int indent = 0)
        {
            string indent0 = Utils.RepeatString(indent);
            string indent2 = Utils.RepeatString(indent + 2);
            string indent4 = Utils.RepeatString(indent + 4);

            string s = indent0 + "[SWF:" + prefix + "]\n" +
                       indent2 + "Header:\n" +
                       indent4 + "Version: " + version + "\n" +
                       indent4 + "FlashVersion: " + flashVersion + "\n" +
                       indent4 + "FrameRate: " + frameRate + "\n" +
                       indent4 + "FrameSize: " + frameSize + "\n" +
                       indent4 + "FrameRate: " + frameRate + "\n";
            int    count        = 0;
            string defineString = "";

            for (int i = 0; i < chId_defs.Length; i++)
            {
                TagDefine define = chId_defs[i];
                if (define != null)
                {
                    count++;
                    defineString += define.trace(indent + 4);
                }
            }

            s += indent2 + "Defines(" + chId_defs.Length + "):\n";
            s += defineString;
            return(s);
        }
Пример #3
0
        public TagDefine parseDefine(Flash flash, byte[] data, Cursor cursor)
        {
            //find nextIndex
            int dataLength = Utils.ReadInt32(data, cursor);
            int nextIndex  = cursor.index + dataLength;

            //parse
            byte      type = Utils.ReadByte(data, cursor);
            TagDefine def  = null;

            if (type == TagDefine.DEF_TYPE_GRAPHIC)
            {
                def = new TagDefineGraphic(flash, data, cursor);
            }
            else if (type == TagDefine.DEF_TYPE_SPRITE)
            {
                def = new TagDefineMovie(flash, data, cursor);
            }

            //nextIndex
            cursor.index = nextIndex;

            return(def);
        }
Пример #4
0
        public void apply(Movie movie, FrameObject frameObj)
        {
            Display display = movie.depthDisplays [depth - 1];

            if (hasCharacter)
            {
                if (display != null)
                {
                    if (hasMove || characterId != display.define.characterId)
                    {
//                        display.removeFromParent();
                        display.removed = true;
                        display.visible = false;
                        movie.caches.DL_APPEND(display);

                        movie.depthDisplays [depth - 1] = null;
                        display = null;
                    }
                    else
                    {
                        //reuse cache
                        display.removed = false;
                    }
                }
                if (display == null)
                {
                    for (var ent = movie.caches.head; ent != null; ent = ent.next)
                    {
                        if (ent.obj.define.characterId == characterId)
                        {
                            display         = ent.obj;
                            display.removed = false;
                            display.visible = true;
                            movie.caches.DL_DELETE(ent);
                            movie.depthDisplays [depth - 1] = display;
                            if (display is Movie)
                            {
                                (display as Movie).movieCtrl.start();
                            }
                            break;
                        }
                    }
                }
                if (display == null)
                {
                    TagDefine newCharacterDefine = flash.getDefine(characterId);
                    if (newCharacterDefine is TagDefineDisplay)
                    {
                        display = flash.displayFactory.ctDisplay(newCharacterDefine as TagDefineDisplay);
                        movie.depthDisplays [depth - 1] = display;
                        movie.addChild(display);
                        if (display is Movie)
                        {
                            (display as Movie).movieCtrl.start();
                        }
                    }
                }
                NSUtils.Assert(display != null, "TagPlaceObject#apply failed to create display.");

                display.position = Vector2.zero;
                display.rotation = 0;
                display.scaleX   = 1; //display.define.preScale;
                display.scaleY   = 1; //display.define.preScale;
                display.zOrder   = depth;
                if (display.hasUserVisible)
                {
                    display.visible = display.userVisible;
                }
                else
                {
                    display.visible = true;
                }
                if (display.hasUserColorTransform)
                {
                    display.colorTransform   = display.userColorTransform;;
                    display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                }
                else
                {
                    display.colorTransform   = ColorTransform.Default;
                    display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                }
            }
            NSUtils.Assert(display != null, "TagPlaceObject#apply try to reference a null display.");


            if (display != null)
            {
                if (hasMatrix)
                {
                    float preScale = display.define.preScale;
                    display.position = new Vector2(position.x, -position.y);
                    display.rotation = rotation;
                    display.scaleX   = scaleX / preScale;
                    display.scaleY   = scaleY / preScale;
                }
                if (hasVisible)
                {
                    if (display.hasUserVisible)
                    {
                        display.visible = display.userVisible;
                    }
                    else
                    {
                        display.visible = visible;
                    }
                }
                if (hasColorTransform)
                {
                    if (display.hasUserColorTransform)
                    {
                        display.colorTransform   = display.userColorTransform;;
                        display.opacityTransform = new OpacityTransform(display.userColorTransform.tint.a, display.userColorTransform.add.a);
                    }
                    else
                    {
                        display.colorTransform   = colorTransform;
                        display.opacityTransform = new OpacityTransform(colorTransform.tint.a, colorTransform.add.a);
                    }
                }
                display.instanceName = instanceName;
            }
        }