Appearance
pixi-hm05 (player) / pixi-hm05/as2
pixi-hm05/as2
Interfaces
| Interface | Description |
|---|---|
| InstanceInit | one on(initialize) / onClipEvent(load) block of a child instance |
| Pt | - |
Type Aliases
| Type Alias | Description |
|---|---|
| ClipLike | a clip, or a Behaviour standing for its clip (this in a ported script) |
| Vars | an AS2 variable bag: dynamic, like an AS2 MovieClip's own variables |
Variables
| Variable | Description |
|---|---|
| G | _root's variables (the main timeline's own variables, _root.foo, and clips attached to _root by name, e.g. G.hero). Also globalThis.__AS2_G__ for play tests. |
| Key | AS2 Key (key codes = KeyboardEvent.keyCode, as in Flash; mouse buttons 1 / 2 / 4 count as keys for isDown) |
Functions
| Function | Description |
|---|---|
| alive | a clip reference AS2 could still use: not removed, still on stage (AS2 calls on a removed clip silently did nothing; JS throws) |
| applyInit | an initObject / on(initialize) block: properties onto the clip, the rest into its variables |
| attach | parent.attachMovie(id, name, depth[, init]): a new clip of the Library symbol with that Linkage id (Script ID / name / key), named in vars(parent) (a clip already at that depth is replaced, as in Flash). init = the initObject (_x, _y … and variables), set before its first frame's scripts run. |
| child | a named child clip, AS2 clip.a.b: each step is a clip named by _name = / attach (in vars) or an instance name in the editor; _parent / _root steps work too; null when it is not there now |
| clearEnterFrame | AS2 delete clip.onEnterFrame |
| currentFrame | AS2 _currentframe (1-based; a queued goto's frame when it is a number) |
| duplicateSymbol | clip.duplicateSymbol(name, depth[, init]): a new clip of the same symbol in the same parent, at the clip's place (attached, so removeClip removes it) |
| ensureFrame1 | For a clip on an OBJECT layer whose frame-0 call frame1 was lost (the player makes such a clip before its first keyframe; pixi-hm05 logs "no frame1() of script … on <name>"). Call from onCreate(): if frame1 did not run by the next microtask, it runs then. |
| flushGotos | runs the queued gotos now (one per clip: the last asked for) |
| fromRoot | clip.globalToLocal(pt) from _root (stage) coordinates |
| getBounds | clip.getBounds(_root) in _root coordinates (hidden clips measured) |
| getDepth | clip.getDepth() (attached clips; timeline clips → -1) |
| getEnterFrame | the handler setEnterFrame gave the clip (AS2 if (clip.onEnterFrame)) |
| getProp | reads an AS2 property (_x, _xscale in %, _alpha in %, _currentframe 1-based, _totalframes, _name …); a plain name reads vars(c) |
| getTimer | getTimer(): ms since the movie started |
| gotoAndPlay | AS2 gotoAndPlay(frame) (1-based / label), queued like gotoAndStop |
| gotoAndStop | AS2 gotoAndStop(frame) with AS2 ordering: frame is the 1-BASED Flash frame number (or a label). hm05's own timeline.gotoAndStop runs the target frame's scripts AT ONCE, in the middle of the calling script; AS2 ran them after the script finished, and only for the LAST goto of the script. These helpers queue the goto (and play / stop) per clip and run the last one when the current script is done (a microtask). |
| hitTest | a.hitTest(b): bounding boxes overlap. Flash ignored _visible here (invisible hit boxes are the usual AS2 pattern) — so does SymbolInstance.hitTestObject since 2026-11-07 |
| hitTestPoint | clip.hitTest(x, y, shapeFlag) with x, y in _root coordinates; hidden clips are measured too (Flash ignored _visible here) |
| initChildren | on(initialize) of child instances: each new child on a listed layer gets its values once, before its own frame1 runs. Prefer watchInit (once, from onCreate), which also covers frames reached by a goto. |
| int | AS2 int(x) (truncates; NaN / undefined → 0) |
| isDown | Key.isDown(code) |
| n0 | SWF6 number conversion: undefined / null / NaN / "" → 0. AS1 / AS2 maths AND comparisons treat an unset variable as 0 (undefined + 1 = 1, undefined >= 0 is true, hp -= dmg on an unset hp = -dmg); in JS they give NaN / false. Wrap every operand that may be unset. |
| nameOf | _name |
| nextFrame | AS2 nextFrame() (queued; stops there) |
| play | AS2 play(): ordered with the queued gotos of the same clip |
| playSound | new Sound(this); s.attachSound(id); s.start(…): plays a sound by its Linkage id (Export id), id or Library name. A sound only scripts use must have an Export id (Library › Details) or it is not published. |
| prevFrame | AS2 prevFrame() (queued; stops there) |
| random | AS2 random(n): an integer 0 … n-1 |
| removeClip | clip.removeSymbol(): only clips made by attach / duplicateSymbol go (a clip placed by a timeline stays, as in Flash) |
| root | _root as a clip (the one setRoot registered, else the file root of from) |
| s0 | SWF6 string conversion: undefined / null → "" ("hp: " + hp) |
| setEnterFrame | AS2 clip.onEnterFrame = function () {…} on ANY clip (also one with no script, an attached bullet …): fn(clip) runs once per movie frame (the _root frame rate) while the clip is on stage, until clearEnterFrame(clip) (AS2 delete clip.onEnterFrame) or the clip is removed. Assigning again replaces it, as in AS2. A Behaviour's own onEnterFrame() method is the usual place for the clip's OWN handler; use this for handlers set at run time (this.onEnterFrame = this.move after a hit, on a child, …). |
| setName | _name = name: also reachable as vars(_parent)[name] / child() |
| setProp | Sets an AS2 movie-clip property by name (_x, _xscale, _alpha …); false = not one (a plain variable). Flash IGNORED a NaN / undefined write (_x = undefined kept the old x); pixi takes it and the clip vanishes — so non-numbers are skipped here (console.warn once per property name). |
| setRoot | the main timeline registers itself (its Behaviour's onCreate): setRoot(this.clip) — after that vars(root()) === G |
| stop | AS2 stop(): ordered with the queued gotos of the same clip |
| stopAllSounds | stopAllSounds() (every playing sound, script-started ones too) |
| swapDepths | clip.swapDepths(depth) for attached clips (a timeline clip is moved into its parent's attached clips, as Flash does; its name stays reachable through child()) |
| text | a TextField by instance name (timebox.text = …), on c or through a dotted path |
| toRoot | clip.localToGlobal(pt) in _root (stage) coordinates |
| trace | AS2 trace(…) |
| up | _parent (n = 1), _parent._parent (n = 2) … |
| vars | A clip's AS2 variables (this.hp, _parent.speed, _root.score = vars(root()) = G). Per clip, not per Behaviour, so _parent.x style reads from other clips work. Safe in a field initialiser (v = vars(this), which runs before hm05 sets this.clip): a view that finds the bag on first use is returned then. |
| watchInit | runs initChildren(owner, table) now and on every frame the timeline enters (also frames reached by a goto, which get no onEnterFrame beat). Call once from onCreate(). |