Fixes level/index for the timeline children (again)

This commit is contained in:
Yury Delendik 2013-09-05 11:11:56 -05:00
Родитель da72eb382f
Коммит fdec5d1748
7 изменённых файлов: 159 добавлений и 0 удалений

Просмотреть файл

@ -118,6 +118,8 @@ var SpriteDefinition = (function () {
props.owned = true;
props.parent = this;
props.stage = this._stage;
props.level = this._level + 1;
props.index = i;
var instance = symbolClass.createAsSymbol(props);

Двоичные данные
test/swfs/3_joystick.fla Normal file

Двоичный файл не отображается.

24
test/swfs/3_joystick.stas Normal file
Просмотреть файл

@ -0,0 +1,24 @@
// 3_joystick.swf test script
run_test = function (t, file) {
var initx = 115.1, inity = 116, delta = 70;
print ("Testing " + file);
t.reset (file);
var expected = Buffer.load (file + ".trace");
t.advance (100);
t.mouse_move (initx, inity);
t.advance (100);
t.mouse_press (initx, inity);
t.advance (100);
t.mouse_move (initx + delta, inity);
t.advance (1600);
t.mouse_release (initx + delta, inity);
t.advance (100);
var diff = t.trace.diff (expected);
};
t = new Test ();
for (var i = 0; i < filenames.length; i++) {
run_test (t, filenames[i]);
}

Двоичные данные
test/swfs/3_joystick.swf Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,4 @@
Interactivity3 init
dragPressHandler
wrap
dragReleaseHandler

Просмотреть файл

@ -0,0 +1,122 @@
package code
{
/*****************************************
* Interactivity3 :
* Demonstrates movement controlled by a joystick.
* http://www.adobe.com/devnet/actionscript/samples/interactivity_3.html
* -------------------
* See 3_joystick.fla
****************************************/
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class Interactivity3 extends MovieClip
{
//*************************
// Properties:
public var initx:Number = 0;
public var inity:Number = 0;
public var tension:Number = .5;
public var decay:Number = .5;
public var xSpeed:Number = 0;
public var dragging:Boolean = false;
//*************************
// Constructor:
public function Interactivity3()
{
trace('Interactivity3 init');
initx = joystick.x;
inity = joystick.y;
// Respond to mouse events
joystick.addEventListener(MouseEvent.MOUSE_DOWN,dragPressHandler);
stage.addEventListener(MouseEvent.MOUSE_UP,dragReleaseHandler);
// Update screen every frame
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
//*************************
// Event Handling:
protected function dragPressHandler(event:MouseEvent):void
{
trace('dragPressHandler');
dragging = true;
}
protected function dragReleaseHandler(event:MouseEvent):void
{
trace('dragReleaseHandler');
dragging = false;
}
protected function enterFrameHandler(event:Event):void
{
with( joystick )
{
if( dragging )
{
// Calculate the angle
// of the joystick
var angle = Math.atan2(root.mouseY-inity,root.mouseX-initx)/(Math.PI/180);
rotation = angle;
with( knob )
{
// Rotate the knob inversely to
// the rotation of the whole joystick
rotation = -angle;
// Drag the joystick but constrain it
// to a circle with a radius of 75
x = parent.mouseX;
if( x > 75 ){
x = 75;
}
}
with( beetle )
{
// Set rotation of beetle equal to
// the rotation of the joystick
rotation = angle;
// Loop to opposite side of the masked
// area when the beetle travels off-screen
if( y < 0 ) {
y = 231;
}
if( y > 231 ){
y = 0;
}
if( x < 231 ){
x = 465;
}
if( x > 465 ){
trace('wrap');
x = 231;
}
// Move the beetle in proportion to how far
// the joystick is dragged from its center
y += Math.sin(angle*(Math.PI/180))*(knob.x/8);
x += Math.cos(angle*(Math.PI/180))*(knob.x/8);
}
// Scale the length of the joystick shaft
shaft.width = (knob.x-shaft.x);
shaft.alpha = 1;
}
else{
// Snap back to center when the joystick is released
xSpeed = -knob.x*tension+(xSpeed*decay);
knob.x += xSpeed;
shaft.alpha = 0;
}
}
}
}
}

Просмотреть файл

@ -241,6 +241,13 @@
],
"type": "stas"
},
{ "id": "3_joystick",
"stas": "swfs/3_joystick.stas",
"filenames": [
"swfs/3_joystick.swf"
],
"type": "stas"
},
{ "id": "MaskTest",
"frames": [1],
"swf": "swfs/MaskTest.swf",