//number that is redefined when the pause button is hit
var pausePoint:Number = 0.00;
//a true or false value that is used to check whether the sound is currently playing
var isPlaying:Boolean;
//think of the soundchannel as a speaker system and the sound as an mp3 player
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("SOUNDPATH/EVENDEEPER/SOUND.mp3"));
//you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons
xstop.addEventListener(MouseEvent.CLICK, clickStop);
xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);
soundChannel = sound.play();
isPlaying = true;
function clickPlayPause(evt:MouseEvent) {
if (isPlaying) {
pausePoint = soundChannel.position;
soundChannel.stop();
isPlaying = false;
} else {
soundChannel = sound.play(pausePoint);
isPlaying = true;
}
}
function clickStop(evt:MouseEvent) {
if (isPlaying) {
soundChannel.stop();
isPlaying = false;
}
pausePoint = 0.00;
}
// http://www.dreamincode.net/code/snippet2563.htm
Monday, November 1, 2010
Thursday, October 28, 2010
dynamic play sound as3
var mySoundReq:URLRequest = new URLRequest("Audio/wissel.mp3");
var mySound:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();
mySound.load(mySoundReq);
play_btn.addEventListener(MouseEvent.CLICK, playSound):
stop_btn.addEventListener(MouseEvent.CLICK, stopSound):
function playSound void {
mySoundChannel = mySound.play();
}
function playSound void {
mySoundChannel = mySound.play();
}
var mySound:Sound = new Sound();
var mySoundChannel:SoundChannel = new SoundChannel();
mySound.load(mySoundReq);
play_btn.addEventListener(MouseEvent.CLICK, playSound):
stop_btn.addEventListener(MouseEvent.CLICK, stopSound):
function playSound void {
mySoundChannel = mySound.play();
}
function playSound void {
mySoundChannel = mySound.play();
}
Monday, October 25, 2010
loading a swf dynamically
var loader:Loader=new Loader();
this.addChild(loader);
trace(loader.name);
loader.x=0;
loader.y=120;
loader.load(new URLRequest("slide0.swf"));
this.addChild(loader);
trace(loader.name);
loader.x=0;
loader.y=120;
loader.load(new URLRequest("slide0.swf"));
Friday, October 22, 2010
As 3 call a funtion from in side movie clip
var parentObj:Object = this.parent as Object;
parentObj.calledFunction();
parentObj.calledFunction();
as3 xml import
trace ("loading xml .. .")
var webControl_XML:XML;
var webControlXMLReq:URLRequest = new URLRequest("webControl.xml");
var webControlXMLLoader:URLLoader = new URLLoader();
var MovieLoaded:int = 0;
webControlXMLLoader.load(webControlXMLReq);
webControlXMLLoader.addEventListener(Event.COMPLETE, webControlXMLLoaded);
trace("funtions")
function webControlXMLLoaded(event:Event):void
{
trace ("loading xml ... ...")
webControl_XML = new XML(webControlXMLLoader.data);
}
var webControl_XML:XML;
var webControlXMLReq:URLRequest = new URLRequest("webControl.xml");
var webControlXMLLoader:URLLoader = new URLLoader();
var MovieLoaded:int = 0;
webControlXMLLoader.load(webControlXMLReq);
webControlXMLLoader.addEventListener(Event.COMPLETE, webControlXMLLoaded);
trace("funtions")
function webControlXMLLoaded(event:Event):void
{
trace ("loading xml ... ...")
webControl_XML = new XML(webControlXMLLoader.data);
}
Thursday, October 21, 2010
Flash As3 Logic
Weird equalities
= vs. ==
| SYMBOL | OPERATION | EXAMPLES | ENGLISH |
| = | assignment | myVar = 17 | Assign the value 17 to the variable "myVar" |
| _x = 17 | "set the value of the property _x to 17" | ||
| == | comparison | if(_x == 100){ myVar = 10 } | if the _x property is equal to 100, set the variable "myVar" to 10 |
more comparisons
| SYMBOL | OPERATION | EXAMPLES | ENGLISH |
| != | NOT EQUAL tests for inequality | if(myVar != 100){ myVar = 100 } | if "myVar" is NOT equal to 100, set the variable "myVar" to 100 |
| >= | greater than or equal to | if(myClip._x >= 100){ myVar = 10 } | if the _x property of "myClip" is greater than or equal to 100, set the variable "myVar" to 10 |
| <= | less than or equal to | if(myClip._x <= 100){ myVar = 10 } | if the _x property of "myClip" is less than or equal to 100, set the variable "myVar" to 10 |
Checking for more than one condition at once:&& (AND);|| (OR)
| if ( (_x < 550) && (_x > 0)) { _x = _x+1 } | If the _x property is less than 550 AND the _x property is greater than zero, then add one to the _x property. note: extra parentheses are used for grouping; they are optional, but they help reading the code. |
| Example Usage: | |
| if ( (_x > 550) || (_x < 0)) { onStage = false } | If the _x property is greater than 550 OR the _x property is less than zero, set the variable onStage to f |
Wednesday, October 20, 2010
add a time to your animation
Add a timer in Actionscript 3.0
_____________________________________________________
var tmrDisplay:Timer; // make a timer
tmrDisplay=new Timer(10); // amout of time that will pass before time .1 of a second
tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay); // add listener for event
tmrDisplay.start(); // start the timer
function updateDisplay(e:TimerEvent):void // ever you want to happen
{
trace ("working")
}
_____________________________________________________
var tmrDisplay:Timer; // make a timer
tmrDisplay=new Timer(10); // amout of time that will pass before time .1 of a second
tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay); // add listener for event
tmrDisplay.start(); // start the timer
function updateDisplay(e:TimerEvent):void // ever you want to happen
{
trace ("working")
}
looping a flv
ns.onStatus = function(info) { // checks the status of a flv named "ns"
if (info.code == "NetStream.Play.Stop") { // if it is stopped of hit the end and stop
ns.seek(0); // it will seek frame 0
}
};
if (info.code == "NetStream.Play.Stop") { // if it is stopped of hit the end and stop
ns.seek(0); // it will seek frame 0
}
};
Subscribe to:
Posts (Atom)