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();
}
Thursday, October 28, 2010
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)