Skip to content

pixi-hm05 (player) / pixi-hm05/as2

pixi-hm05/as2 ​

Interfaces ​

InterfaceDescription
InstanceInitone on(initialize) / onClipEvent(load) block of a child instance
Pt-

Type Aliases ​

Type AliasDescription
ClipLikea clip, or a Behaviour standing for its clip (this in a ported script)
Varsan AS2 variable bag: dynamic, like an AS2 MovieClip's own variables

Variables ​

VariableDescription
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.
KeyAS2 Key (key codes = KeyboardEvent.keyCode, as in Flash; mouse buttons 1 / 2 / 4 count as keys for isDown)

Functions ​

FunctionDescription
alivea clip reference AS2 could still use: not removed, still on stage (AS2 calls on a removed clip silently did nothing; JS throws)
applyInitan initObject / on(initialize) block: properties onto the clip, the rest into its variables
attachparent.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.
childa 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
clearEnterFrameAS2 delete clip.onEnterFrame
currentFrameAS2 _currentframe (1-based; a queued goto's frame when it is a number)
duplicateSymbolclip.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)
ensureFrame1For 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.
flushGotosruns the queued gotos now (one per clip: the last asked for)
fromRootclip.globalToLocal(pt) from _root (stage) coordinates
getBoundsclip.getBounds(_root) in _root coordinates (hidden clips measured)
getDepthclip.getDepth() (attached clips; timeline clips → -1)
getEnterFramethe handler setEnterFrame gave the clip (AS2 if (clip.onEnterFrame))
getPropreads an AS2 property (_x, _xscale in %, _alpha in %, _currentframe 1-based, _totalframes, _name …); a plain name reads vars(c)
getTimergetTimer(): ms since the movie started
gotoAndPlayAS2 gotoAndPlay(frame) (1-based / label), queued like gotoAndStop
gotoAndStopAS2 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).
hitTesta.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
hitTestPointclip.hitTest(x, y, shapeFlag) with x, y in _root coordinates; hidden clips are measured too (Flash ignored _visible here)
initChildrenon(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.
intAS2 int(x) (truncates; NaN / undefined → 0)
isDownKey.isDown(code)
n0SWF6 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
nextFrameAS2 nextFrame() (queued; stops there)
playAS2 play(): ordered with the queued gotos of the same clip
playSoundnew 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.
prevFrameAS2 prevFrame() (queued; stops there)
randomAS2 random(n): an integer 0 … n-1
removeClipclip.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)
s0SWF6 string conversion: undefined / null → "" ("hp: " + hp)
setEnterFrameAS2 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()
setPropSets 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).
setRootthe main timeline registers itself (its Behaviour's onCreate): setRoot(this.clip) — after that vars(root()) === G
stopAS2 stop(): ordered with the queued gotos of the same clip
stopAllSoundsstopAllSounds() (every playing sound, script-started ones too)
swapDepthsclip.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())
texta TextField by instance name (timebox.text = …), on c or through a dotted path
toRootclip.localToGlobal(pt) in _root (stage) coordinates
traceAS2 trace(…)
up_parent (n = 1), _parent._parent (n = 2) …
varsA 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.
watchInitruns 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().

HereSplash — 2D animation for the web