Reputation: 1317
I was building an beginner application with Flashdevelop, when I met the following problem.
I would like to create a MovieClip type Table.as class:
public class Table extends MovieClip { ... }
which should contain two frames: the first should be a red rectangle, the second a blue one. So created two sprites for both of the rectangles:
var table:Sprite = new Sprite();
table.graphics.beginFill(0xff0000);
table.graphics.drawRect(this.xCoord, this.yCoord, 150, 50);
addChild(table);
var table2:Sprite = new Sprite();
table2.graphics.beginFill(0x0000ff);
table2.graphics.drawRect(this.xCoord + 200, this.yCoord + 100, 150, 50);
addChild(table2);
What should I do to get the table
and table2
variables on different frames? So to receive to the trace(totalFrames)
2 as answer?
Upvotes: 1
Views: 1471
Reputation: 23652
MovieClips and Sprites that are generated outside of Flash IDE function more or less identically. Only a MovieClip created inside Flash IDE can have multiple frames, and you can't add or remove frames at run time. However, you can create a simple class to switch between your two tables fairly quickly
public class Switcher():void {
function showTable1():void { table1.visible = true; table2.visible = false; };
function showTable2():void { table1.visible = false; table2.visible = true; };
}
var switch:Switcher = new Switcher();
switch.showTable1();
Upvotes: 1