Ejemplo n.º 1
0
        /// <summary>
        /// Read <see cref="SwfOp.ByteCode.Actions.ActionWaitForFrame2">ActionWaitForFrame2</see> from swf.
        /// </summary>
        private ActionWaitForFrame2 ReadActionWaitForFrame2(BinaryReader br)
        {
            int  len  = Convert.ToInt32(br.ReadUInt16());
            byte skip = br.ReadByte();

            ActionWaitForFrame2 a = new ActionWaitForFrame2(skip);

            //a.ByteSize = len+3;

            return(a);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// create other pseudo actions
        /// </summary>

        private void CreatePseudoActions(ArrayList actionRecord)
        {
            for (int i = 0; i < actionRecord.Count; i++)
            {
                BaseAction a = (BaseAction)actionRecord[i];

                // -----------------------
                // try/catch/finally block
                // -----------------------

                ActionTry aTry = a as ActionTry;
                if (aTry != null)
                {
                    int j      = i + 1;
                    int offset = aTry.SizeTry;
                    // skip try block
                    while (offset > 0)
                    {
                        BaseAction currentAction = (BaseAction)actionRecord[j];
                        offset -= currentAction.ByteCount;
                        j++;
                    }
                    // skip catch
                    if (aTry.SizeCatch > 0)
                    {
                        actionRecord.Insert(j, new ActionCatch());
                        j++;
                        offset = aTry.SizeCatch;
                        while (offset > 0)
                        {
                            BaseAction currentAction = (BaseAction)actionRecord[j];
                            offset -= currentAction.ByteCount;
                            j++;
                        }
                    }
                    // skip finally
                    if (aTry.SizeFinally > 0)
                    {
                        actionRecord.Insert(j, new ActionFinally());
                        j++;
                        offset = aTry.SizeFinally;
                        while (offset > 0)
                        {
                            BaseAction currentAction = (BaseAction)actionRecord[j];
                            offset -= currentAction.ByteCount;
                            j++;
                        }
                    }
                    // end
                    actionRecord.Insert(j, new ActionEndTryBlock());
                }

                // -----------------------
                //          with
                // -----------------------

                ActionWith aWith = a as ActionWith;

                if (aWith != null)
                {
                    int j      = i + 1;
                    int offset = aWith.BlockLength;
                    while (offset > 0)
                    {
                        BaseAction currentAction = (BaseAction)actionRecord[j];
                        offset -= currentAction.ByteCount;
                        j++;
                    }
                    actionRecord.Insert(j, new ActionEndWith());
                }

                // -----------------------
                //    wait for frame
                // -----------------------

                ActionWaitForFrame aWait = a as ActionWaitForFrame;
                if (aWait != null)
                {
                    int j     = i + 1;
                    int count = aWait.SkipCount;
                    while (count > 0)
                    {
                        if (((int)((BaseAction)actionRecord[j]).Code >= 0x00) ||
                            (((BaseAction)actionRecord[j]).Code == (int)ActionCode.PushList))
                        {
                            count--;
                        }
                        j++;
                    }
                    actionRecord.Insert(j, new ActionEndWait());
                }
                ActionWaitForFrame2 aWait2 = a as ActionWaitForFrame2;
                if (aWait2 != null)
                {
                    int j     = i + 1;
                    int count = aWait2.SkipCount;
                    while (count > 0)
                    {
                        if (((int)((BaseAction)actionRecord[j]).Code >= 0x00) ||
                            (((BaseAction)actionRecord[j]).Code == (int)ActionCode.PushList))
                        {
                            count--;
                        }
                        j++;
                    }
                    actionRecord.Insert(j, new ActionEndWait());
                }
            }
        }
Ejemplo n.º 3
0
        ///<summary>
        /// Calculate size or offset for action blocks.
        ///</summary>
        private void CalcBlockOffsets(ArrayList actionRecord)
        {
            if (actionRecord.Count < 1)
            {
                return;
            }

            for (int i = 0; i < actionRecord.Count; i++)
            {
                BaseAction a = (BaseAction)actionRecord[i];

                // action with
                ActionWith aWith = a as ActionWith;
                if (aWith != null)
                {
                    int j      = i;
                    int offset = 0;
                    do
                    {
                        j++;
                        offset += ((BaseAction)actionRecord[j]).ByteCount;
                    } while ((actionRecord[j] as ActionEndWith) == null);

                    int oldOffset = aWith.BlockLength;

                    aWith.BlockLength = offset;
                }

                // action waitForFrame
                ActionWaitForFrame aWait = a as ActionWaitForFrame;
                if (aWait != null)
                {
                    int        j     = i;
                    int        count = 0;
                    BaseAction ca;
                    do
                    {
                        j++;
                        ca = (BaseAction)actionRecord[j];
                        if ((ca.Code >= 0) || (ca.Code == (int)ActionCode.PushList))
                        {
                            count++;
                        }
                    } while ((ca as ActionEndWait) == null);
                    aWait.SkipCount = count;
                }

                // action waitForFrame2
                ActionWaitForFrame2 aWait2 = a as ActionWaitForFrame2;
                if (aWait2 != null)
                {
                    int        j     = i;
                    int        count = 0;
                    BaseAction ca;
                    do
                    {
                        j++;
                        ca = (BaseAction)actionRecord[j];
                        if ((ca.Code >= 0) || (ca.Code == (int)ActionCode.PushList))
                        {
                            count++;
                        }
                    } while ((ca as ActionEndWait) == null);
                    aWait2.SkipCount = count;
                }

                // action function
                ActionDefineFunction f = actionRecord[i] as ActionDefineFunction;
                if (f != null)
                {
                    CalcBlockOffsets(f.ActionRecord);
                }

                // action function2
                ActionDefineFunction2 f2 = actionRecord[i] as ActionDefineFunction2;
                if (f2 != null)
                {
                    CalcBlockOffsets(f2.ActionRecord);
                }
            }
        }
Ejemplo n.º 4
0
 ActionBase IActionVisitor <XElement, ActionBase> .Visit(ActionWaitForFrame2 action, XElement xAction)
 {
     action.SkipCount = xAction.RequiredByteAttribute("skipCount");
     return(action);
 }
Ejemplo n.º 5
0
 XElement IActionVisitor <XElement, XElement> .Visit(ActionWaitForFrame2 action, XElement param)
 {
     return(new XElement("WaitForFrame2",
                         new XAttribute("skipCount", action.SkipCount)));
 }