Reff AS3
http://www.puzzlescripts.com/nm-Sliding_Puzzle_AS3_Class-cp-38
http://www.puzzlescripts.com/nm-Jigsaw_Puzzle_AS3_Class-cp-28
flash.events.MouseEvent; Next1.addEventListener(MouseEvent.CLICK, Walk); function Walk(event: MouseEvent): void { addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(e:Event):void { if (currentFrame == 30) { gotoAndPlay(31); } } }
addEventListener(Event.ENTER_FRAME, enterFrame);
function enterFrame(e:Event):void {
if (someAnimation.currentFrame == 30) {
//do this
}
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
var smiley:MovieClip = addChild(new Smiley) as MovieClip; // **ERROR HERE**
stage.addEventListener(MouseEvent.MOUSE_DOWN,toggleSmiley);
stage.addEventListener(MouseEvent.MOUSE_UP,toggleSmiley);
function mousePosition(event:MouseEvent) {
smiley.x = mouseX; smiley.y = mouseY;
}
function toggleSmiley(e:MouseEvent):void
{
smiley.visible = (e.type == MouseEvent.MOUSE_DOWN);
}
++++++++++++++++++++
PuzzleEvent.CONTENT_READY
PuzzleEvent.PUZZLE_START
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="0" emptyJ="0" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="1" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="1" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PIECE_MOVE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="0" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="1" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PIECE_MOVE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="1" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="0" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PUZZLE_DONE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="1" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="0" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
http://www.puzzlescripts.com/nm-Jigsaw_Puzzle_AS3_Class-cp-28
flash.events.MouseEvent; Next1.addEventListener(MouseEvent.CLICK, Walk); function Walk(event: MouseEvent): void { addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(e:Event):void { if (currentFrame == 30) { gotoAndPlay(31); } } }
addEventListener(Event.ENTER_FRAME, enterFrame);
function enterFrame(e:Event):void {
if (someAnimation.currentFrame == 30) {
//do this
}
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
var smiley:MovieClip = addChild(new Smiley) as MovieClip; // **ERROR HERE**
stage.addEventListener(MouseEvent.MOUSE_DOWN,toggleSmiley);
stage.addEventListener(MouseEvent.MOUSE_UP,toggleSmiley);
function mousePosition(event:MouseEvent) {
smiley.x = mouseX; smiley.y = mouseY;
}
function toggleSmiley(e:MouseEvent):void
{
smiley.visible = (e.type == MouseEvent.MOUSE_DOWN);
}
++++++++++++++++++++
PuzzleEvent.CONTENT_READY
PuzzleEvent.PUZZLE_START
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="0" emptyJ="0" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="1" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="1" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PIECE_MOVE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="0" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="1" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PIECE_MOVE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="1" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="0" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
PuzzleEvent.PUZZLE_DONE
<puzzleSliding source="myPicture" sourceRenderAs="Bitmap" splitHorizontal="2" splitVertical="2" emptyCorner="RB" emptyI="1" emptyJ="1" scrollContent="true">
<pieces>
<grp cI="1" cJ="1" iI="1" iJ="1"/>
<grp cI="1" cJ="0" iI="1" iJ="0"/>
<grp cI="0" cJ="1" iI="0" iJ="1"/>
<grp cI="0" cJ="0" iI="0" iJ="0"/>
</pieces>
</puzzleSliding>
+++
const list:Array = new Array();
const xml:XML =
<list>
<label>ALPHA</label>
<label>ALLAN</label>
<label>ANTARES</label>
<label>...</label>
</list>;
const labels:XMLList = xml..label;
for each(var node:XML in labels)
{
trace(node);
var arrayItem:Object = new Object();
arrayItem.label = node.text(); // or node.toString() or .toJSON() or .to...
arrayItem.name = node.name();
// added only for debug-trace:
arrayItem.toString = function():String
{
var result:String = '{', delimiter:String = '';
for(var key:String in this)
if(key !== 'toString')
result += delimiter + key + ':"' + this[key] + '"',
delimiter ||= ', ';
return result + '}';
}
// add item to list:
list.push(arrayItem);
}
trace(list);
XML CODE
<?xml version="1.0" encoding="utf-8"?>
<playlist>
<track>
<title>TestTrack 1</title>
<band>Band1</band>
<file>test1.mp3</file>
</track>
<track>
<title>TestTrack 2</title>
<band>Band2</band>
<file>test2.mp3</file>
</track>
<track>
<title>TestTrack 3</title>
<band>Band3</band>
<file>test3.mp3</file>
</track>
<track>
<title>TestTrack 4</title>
<band>Band4</band>
<file>test4.mp3</file>
</track>
</playlist>
AS3 CODE:
var playlistArray:Array = new Array();
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
xmlLoader.load(new URLRequest("playlistAS3.xml"));
function showXML(e:Event):void
{
XML.ignoreWhitespace = true;
var songs:XML = new XML(e.target.data);
trace(songs.track.length());
var i:Number;
for (i=0; i < songs.track.length(); i++)
{
playlistArray= songs.children();
/*trace(" Name of the song: "+ songs.track.title.text());
trace(" Name of the Band: "+ songs.track.band.text());
trace(" File Location of the song: "+ songs.track.file.text());*/
}
trace(playlistArray[0]);
}
Comments
Post a Comment