Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIntroduces anchor-based alignment functionality for Scaleform MovieClips. A new static method and injected prototype method enable repositioning a target MovieClip by aligning specified anchor points between source and target clips, with optional frame deferral and coordinate space conversions. Changes
Sequence DiagramsequenceDiagram
participant Caller
participant TargetClip as Target MovieClip
participant SourceClip as Source MovieClip
participant ParentCoordSpace as Parent Coordinate Space
Caller->>TargetClip: Anchor(source, targetAnchor, sourceAnchor, offsetX, offsetY, waitNextFrame)
TargetClip->>TargetClip: Parse anchor strings to IDs
alt waitNextFrame is true
TargetClip->>TargetClip: Create temporary helper clip<br/>Schedule deferred execution
TargetClip->>TargetClip: Execute on next frame
end
TargetClip->>SourceClip: Compute source anchor in global coordinates
SourceClip->>SourceClip: Extract bounds & calculate anchor point
SourceClip-->>TargetClip: Return global anchor position
TargetClip->>TargetClip: Apply offsetX/offsetY adjustment
TargetClip->>TargetClip: Compute target anchor in local bounds space
TargetClip->>ParentCoordSpace: Convert points between coordinate spaces
ParentCoordSpace-->>TargetClip: Return converted coordinates
TargetClip->>TargetClip: Update _x/_y to align anchors
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
source/actionscript/Vanilla/Shared/GlobalFunc.as (1)
370-385: Make prototype injection idempotent.If
AddAnchorFunction()runs more than once, Line 384 redefinesMovieClip.prototype.Anchoreach time. Add a guard to avoid repeated mutation of the global prototype.♻️ Proposed fix
static function AddAnchorFunction() { + if (MovieClip.prototype.Anchor != undefined) return; if (Shared.GlobalFunc._deferCounter == undefined) Shared.GlobalFunc._deferCounter = 0;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@source/actionscript/Vanilla/Shared/GlobalFunc.as` around lines 370 - 385, Add an idempotency guard in AddAnchorFunction so it doesn't reassign MovieClip.prototype.Anchor on repeated calls: check a unique flag (e.g., Shared.GlobalFunc._anchorAdded) or test if MovieClip.prototype.Anchor already exists at the start of AddAnchorFunction and return early if set; if you set the flag, assign it after the first successful prototype injection. This ensures MovieClip.prototype.Anchor (the Anchor method) is only defined once and prevents repeated global prototype mutation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@source/actionscript/Vanilla/Shared/GlobalFunc.as`:
- Around line 430-438: The code currently only validates destPt.x before
applying offsets and transforming targetPt, which can allow destPt.y or
targetPt.x/targetPt.y to be NaN and later set _x/_y to invalid values; update
the logic around Shared.GlobalFunc._getAnchorPointGlobal and
Shared.GlobalFunc._getAnchorPointLocal to validate destPt and targetPt fully:
check destPt exists and that neither destPt.x nor destPt.y is NaN (after
applying offsetX/offsetY) and call target.localToGlobal(targetPt) only if
targetPt exists and its x and y are finite (use isNaN or similar), and bail out
early if any coordinate is invalid before assigning to _x/_y. Ensure you
reference destPt, targetPt, _getAnchorPointGlobal, _getAnchorPointLocal, and
target.localToGlobal in your changes so the validation surrounds the transform
and assignment steps.
---
Nitpick comments:
In `@source/actionscript/Vanilla/Shared/GlobalFunc.as`:
- Around line 370-385: Add an idempotency guard in AddAnchorFunction so it
doesn't reassign MovieClip.prototype.Anchor on repeated calls: check a unique
flag (e.g., Shared.GlobalFunc._anchorAdded) or test if
MovieClip.prototype.Anchor already exists at the start of AddAnchorFunction and
return early if set; if you set the flag, assign it after the first successful
prototype injection. This ensures MovieClip.prototype.Anchor (the Anchor method)
is only defined once and prevents repeated global prototype mutation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8b59a5f7-78a6-495c-8938-1c8d9051eda9
📒 Files selected for processing (1)
source/actionscript/Vanilla/Shared/GlobalFunc.as
Another innovation in the field of dynamic layout: Anchor (Relative Positioning).
Sometimes globally positioning elements in ActionScript code can be inconvenient, requiring manual offset adjustments. Sometimes buttons like ComboBoxes with drop-down menus are easier to simply bind to the button. Or, for example, if you have a dynamic background width and need to attach an element to it, the element will be attached, eliminating the need to write any further logic for positioning it as the background width changes.
Example:
Summary by CodeRabbit