How It's Based The Random() Function In ActionScript?
Hi to all,
This is a little difficult question: I'd like to know how it's based the random() function in actionscript.
In C language I think is based by the frecuency's crystal quartz clock in the computer, but I don't know how it's obtained in actionscript.
Thanks.
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-12-2006, 02:10 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random Mc Based On Array?
I'm trying to create a basic app where you shoot MCs moving at random. That part works but I'm not sure how I can call an Array at random instead of keeping to the basic shape I'm using now, would be fun with a bit of difference..
Any idea how I could achieve that usig the below code?
Code:
var i;
// get sound
var gunfire = new Sound();
gunfire.attachSound("gunfire");
_root.hit1.onPress = function() {
gunfire.start();
i++;
_root.bull.duplicateMovieClip("bulletNew", i);
if (i == 10) {
i = 0;
}
// hit test on target
if (_root.target_mc.hitTest(_root._xmouse, _root._ymouse, false)) {
_root.gun.gotoAndPlay(2);
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
_root["bulletNew"+x].removeMovieClip();
}
};
// initialise stuff
_root.onLoad = function() {
// hide the mouse
Mouse.hide();
};
//loop
_root.onEnterFrame = function() {
//put cross hairs to mouse coords
_root.gun._x = _root._xmouse;
_root.gun._y = _root._ymouse;
// target move
_root.target_mc._x += 10;
if (_root.target_mc._x<0 || _root.target_mc._x>Stage.width) {
_root.target_mc._x = 0;
_root.target_mc._y = random(300);
}
};
Appreciate any kind suggestions!!!
Yossi
Help: Looking For XML-Based Quiz (Random)
I'm looking for advice for direction. I need to put together a Flash quiz for a course. The questions need to be randomly selected from an XML file. As of right now, I only need multiple choice and true/false. And obviously, I need score tracking.
Can anyone make a recommendation on how to move forward? Anything already existing out there? Thank you for your advice!
Scenes Based On Random Variables
I'm trying to build a program where specific scenes are played depending on a randomly generated number. So far the number is generated, but the movie doesn't play the right scene.
This is the code I have now;
var score:Number;
score = random(100)
if (score >= 95) {
gotoAndPlay("Scene 3", 1);
}
else if (score >= 80) {
gotoAndPlay("scene 4", 1)
}
else if (score >= 65) {
gotoAndPlay("scene 5", 1)
}
else if (score >= 50) {
gotoAndPlay("scene 6", 1)
}
else if (score >= 25) {
gotoAndPlay("scene 7", 1)
}
else if (score >= 0) {
gotoAndPlay("scene 8", 1)
}
Random Selection Based On Frequency?
I have an array of 20 strings.
I have to randomly select 1 of them, the problem is that it needs to be based on it's frequency...
Each string has it's own frequency, which is a value out of 10000, that it should appear.
(More than 1 value can have the same frequency, though.)
The lower the frequency, the less likely it is that it will be chosen.
Eg:
some of the values would have a frequency of 1/10000 (so not very likely to be chosen)
some would have a value of 1000/10000 (more likely to be chosen)
So there are only 20 values, I can hardcode the string values and frequency for each one in my app.
I can easily select a random one, but I have no idea how to start with the frequency issue.
The frequencies for each string will all add up to the total frequency amount (10000).
So, I need to select a random string, but the decision has to lean more to a certain values.
[as] Determining Random Movie Based On Time
This is some code that I'm trying to use to determine what kind of background theme to use/load based on the hour of the day. Does it look right to you? I'm getting syntax errors somewhere, as best as I can determine it's where I add the + x in the middle of a file path.
Is that fine, should it work? I'm going to test it out here after I get back, thought I'd post it and see if there are any suggestions.
ActionScript Code:
hour = getHours();
if (hour >= 8 && hour <= 19) //day
{
// Math function determining random daytime .swf to load
Math.rand = function(low, high) {
if (low <= high) {
return Math.floor(Math.random() * (high - low + 1)) + low;
} else {
return null;
}
};
x = Math.rand(1, 6);
if (x = Math.rand(1, 6)) {
loadMovie("day" + x + ".swf", "theme");
}
}
else if ((hour >= 7 && hour <= 8) || (hour >= 19 && hour <= 20))
{
// Math function determining random twilight .swf to load
Math.rand = function(low, high) {
if (low <= high) {
return Math.floor(Math.random() * (high - low + 1)) + low;
} else {
return null;
}
};
x = Math.rand(1, 6);
if (x = Math.rand(1, 6)) {
loadMovie("twilight" + x + ".swf", "theme");
}
}
else
{
// Math function determining random daytime .swf to load
Math.rand = function(low, high) {
if (low <= high) {
return Math.floor(Math.random() * (high - low + 1)) + low;
} else {
return null;
}
};
x = Math.rand(1, 6);
if (x = Math.rand(1, 6)) {
loadMovie("night" + x + ".swf", "theme");
}
}
Has Anyone Tested How Random Is The Math.Random() Function?
Just wondering whether anyone out there has ever run any tests on how random the Math.Random() function is as a random number generator?
I've been asked me to test it to prove that it is random and it seems a pointless waste of time, so I'm hoping to get evidence from elsewhere to convince the powers that be that there's no need to run the tests.
I've googled for it but come up with nothing so I'm hoping there might be someone out there who has already done the research?
Random Function & Unique Random Numbers
Hello, after some searching i can't seem to find any good explanation to how and why i should use the Math.random() function so maybe i should explain how a function i need should work and someone maybe has some ideas.
I'm making a guessing program where you guess the right answer.
The function i have now randomly selects a number from 0 to 5 and then put's these five numbers into an array, the thing is that i need the numbers to be unique and i have no idea on how to make this.
Another thing i need to do is between these numbers that the random() function gets one is to be removed and instead i put the right answer there so now i also need one of the randomizes numbers to not be the right answer.
Also, how should a Math.random() function call look like so i can edit the range of numbers to randomize from?
Is There A More Efficient Way To Define A Variable Based On A Random Number?
When my flash document loads, I have a target_mc to which I attachMovie a movieClip called start_mc. The _action layer of start_mc in frame 1 looks like this:
var randomNumber:Number = random(3);
if (randomNumber == 0) {
var imageName:String = "acrylic"
trace(imageName);
}
if (randomNumber == 1) {
var imageName:String = "early"
trace(imageName);
}
if (randomNumber == 2) {
var imageName:String = "mixed"
trace(imageName);
}
if (randomNumber == 3) {
var imageName:String = "monotypes"
trace(imageName);
}
Also defined in frame one is a fade for a loadMovie(image.jpg) where the path to the image is defined by the value in the above variable imageName.
loadMovie("../images/" + imageName + ".jpg")
The end result? Of 4 image sub folders nested inside /images/, each represented by the type of artwork (acrylic, monotypes, mixed, early) I want the initial screen that is seen to attach a movie that loads random images from those folders, fades them in and out, and simply waits for user input on one of the menu selections on the left.
My current progress is located at http://www.laceyart.com.
Load Random Movie Based On Interval Time
Hey all, Does anyone know how to correctly load a random movie into an MC based on an interval time? For example: I have three movies. 1.swf, 2.swf and 3.swf that will load into an MC every 10 secs. It should be a completely random event not based on a page refreash. I have attached the code that I'm working with below. The issue that I'm having is that sometimes a movie will load in repeatedly (2-3 times). The movies are roughly the same size.
function randommovie() {
filename = ["1.swf", "2.swf", "3.swf"];
path = "banners/champions/";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], _root.championStage);
}
randommovie();
setInterval(randommovie, 10000);
Load Random Movie Based On Interval Time
Hey all, Does anyone know how to correctly load a random movie into an MC based on an interval time? For example: I have three movies. 1.swf, 2.swf and 3.swf that will load into an MC every 10 secs. It should be a completely random event not based on a page refreash. I have attached the code that I'm working with below. The issue that I'm having is that sometimes a movie will load in repeatedly (2-3 times). The movies are roughly the same size.
function randommovie() {
filename = ["1.swf", "2.swf", "3.swf"];
path = "banners/champions/";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], _root.championStage);
}
randommovie();
setInterval(randommovie, 10000);
Run Function Based On Text Input AS3
I have a input text field that receives its contents from a bar code scan. I want flash to automatically read the input and run function with no user interaction.
Any ideas on how to do this via AS3?
Call A Function Based On XML Data
Hi All,
I am using AS3 ( and not the Flex environment) to call and setup external swf files. I basically have a parent swf file that will call a secondary (child) swf file based on the xml that is loaded. Here is an example of the xml that might be called, defining a TextInput that would change a certain attribute to that secondary (child) swf file:
<item type="TextInput" label="Altitude" restrict="0-9" rangeMin="-500" rangeMax="100000" function="setAltitude">2000</item>
Question is...How do I set up the function="setAltitude" attribute from the XML to be a callable function on the child movieclip when that data is brought in as String or XML type data? So, I basically want it to be something like:
child_mc.setAltitude( TextInput.value );
The child would have a class with the same function or setter to handle that input, ie:
public function setAltitude( _value:Number ):void
{
}
Call A Function Based On XML Data
Hi All,
I am using AS3 ( and not the Flex environment) to call and setup external swf files. I basically have a parent swf file that will call a secondary (child) swf file based on the xml that is loaded. Here is an example of the xml that might be called, defining a TextInput that would change a certain attribute to that secondary (child) swf file:
<item type="TextInput" label="Altitude" restrict="0-9" rangeMin="-500" rangeMax="100000" function="setAltitude">2000</item>
Question is...How do I set up the function="setAltitude" attribute from the XML to be a callable function on the child movieclip when that data is brought in as String or XML type data? So, I basically want it to be something like:
child_mc.setAltitude( TextInput.value );
The child would have a class with the same function or setter to handle that input, ie:
public function setAltitude( _value:Number ):void
{
}
Call A Function Based On XML Data
Hi All,
I am using AS3 ( and not the Flex environment) to call and setup external swf files. I basically have a parent swf file that will call a secondary (child) swf file based on the xml that is loaded. Here is an example of the xml that might be called, defining a TextInput that would change a certain attribute to that secondary (child) swf file:
<item type="TextInput" label="Altitude" restrict="0-9" rangeMin="-500" rangeMax="100000" function="setAltitude">2000</item>
Question is...How do I set up the function="setAltitude" attribute from the XML to be a callable function on the child movieclip when that data is brought in as String or XML type data? So, I basically want it to be something like:
child_mc.setAltitude( TextInput.value );
The child would have a class with the same function (or setter) to handle that input obviously, ie:
public function setAltitude( _value:Number ):void
{
// do something with the data
}
Thanks! Sorry for the multi-post. Tab + Space != Good
Edited: 06/26/2008 at 07:34:32 AM by gpimpler2
Call A Function Based On XML Data
Hi All,
I am using AS3 ( and not the Flex environment) to call and setup external swf
files. I basically have a parent swf file that will call a secondary (child)
swf file based on the xml that is loaded. Here is an example of the xml that
might be called, defining a TextInput that would change a certain attribute to
that secondary (child) swf file:
<item type="TextInput" label="Altitude" restrict="0-9" rangeMin="-500"
rangeMax="100000" function="setAltitude">2000</item>
Question is...How do I set up the function="setAltitude" attribute from the
XML to be a callable function on the child movieclip when that data is brought
in as String or XML type data? So, I basically want it to be something like:
child_mc.setAltitude( TextInput.value );
The child would have a class with the same function or setter to handle that
input, ie:
public function setAltitude( _value:Number ):void
{
}
Calling A Function Based On Variable's Value
say I want to declare a global variable in my main movie on a mouse event (button) and give it a value "functionA".
then I want to load an external .swf into a clip (with the same mouse event)
then I want some code in the loaded .swf to execute a function of the same name "functionA"
how would I code this?
this way I could load the same .swf but execute different functions depending on which button triggered the load... comprende?
hope that makes sense... once I figure this out i will feel like i can actually make some stuff happen...
Class Based Function Hiccup
Hey all, This one is going to take some setup, so bear with me,
I have built an actionscript file to be used as a class library (i think that is what i would call it), it looks like this:
ActionScript Code:
class Effects extends MovieClip { var this_mc:MovieClip; var Dx:Number = 0; var Dy:Number = 0; var Px:Number = 0; var Py:Number = 0; public function Effects(passed_mc:MovieClip) { this_mc = passed_mc; } function mouseFollow(centerx:Object, centery:Object, inertia:Number, k:Number) { Dx = -this_mc._x+centerx; Dy = -this_mc._y+centery; Px = Px*inertia+Dx*k; Py = Py*inertia+Dy*k; this_mc._x += Px; this_mc._y += Py; }}
A not so simple chunk of code that i use to create a "mouse follow" effect when it is used.
Speaking of, i use
ActionScript Code:
var LINE:Effects = new Effects(lineA);//_root.onEnterFrame = function(){LINE.mouseFollow(_root._xmouse, 0, .7, .9);}
to reffer to the code above. Everything works up to this point.
Trouble is when i try to use the code on more than one object on the stage. I have code that listens for keyboard input and when you press a certain key it creates and new blank movie and then loads the appropriate content for that key. It looks like this
ActionScript Code:
createEmptyMovieClip("collage", 1);createEmptyMovieClip("const", 2);var k:Number;k = 1;//keyLoad = function (key) { //trace ("key load activated"); //trace ("key pressed is : " + key); collage_holder.attachMovie("anim"+key, "a"+(k++), k); collage_holder["a"+(k-5)].removeMovieClip();};
That is to say, when i press a key on the keyboard once, the loaded movie follows the mouse. But when i press the same key again, the first loaded movie stops, and the new one loaded follows the mouse. What happens.
I should note that when i use and #include to call the same chunk of code, the problem vanishes.
Thoughts?
Calling A Function Based On Variable's Value
say I want to declare a global variable in my main movie on a mouse event (button) and give it a value "functionA".
then I want to load an external .swf into a clip (with the same mouse event)
then I want some code in the loaded .swf to execute a function of the same name "functionA"
how would I code this?
this way I could load the same .swf but execute different functions depending on which button triggered the load... comprende?
hope that makes sense... once I figure this out i will feel like i can actually make some stuff happen...
Animation Utility/function 4 U (trig Based)
I think that this is an indespenable utility for generating certain trig based motion effect.
http://www.alpha8.com/FLA/screwball_wkbench.swf
Use the above .swf as a workbench, when you have your effect and coordinates as you like them, plug the values into the "stand alone" version. (Download both versions below).
Move the red and green dots around to set the desired origin and destination coordinates for your object.
Use the start button to see the effect.
Note: The only value that may be misleading in the input controls is the "axis speed",.. larger numbers make the axis move slower.
NEW! Control "ease in - ease out" type behaviors with the Friction2 & Friction2Range parameters,
The Range is the distance in pixels at which the Friction2 parameter kicks in.
http://alpha8.com/FLA/screw_ball.zip
Peace to all,
G$ .... Garth
http://www.modiphonic.com
Set The Paramters Of A Function Based On User Input
can you set a function's parameters equal to a variable?
for example
var number:Number = 3;
function args(.....)
{
blah, blah, blah;
}
but i want the arguments to adjust based on the value of the variable number. is this possible?
[resource] Frame-based Function Delay
I've just added the following functionality to my component framework and I thought that some of you guys may find them useful.
What the functions do is to create a frame-based delay for function execution. This means for example that you could execute myFunctionA() twice with a 10 frame delay between each function call... or you could execute myFunctionB() ten times with a 2 frame delay... and so on.
I've just pulled the functions and comments straight out of my class, so if anyone needs any extra info just let me know. I've added a quick example of how to use the functions at the bottom of this post (check it out because you will need to create a movie clip named "__functionBuffer" for these functions to work).
Function Buffer
ActionScript Code:
/**
* Creates a wrapper so a function can be scoped to any object.
*
* @param - obj - The object that "this" will referer to in the function.
* @param - func - The function to be wrapped.
* @param - args - An array of arguments to be passed to the wrapped function. (optional)
*/
function rewire(obj:Object, func:Function, args:Array):Function {
return function() { return func.apply(obj, (args == undefined ? arguments : args)); }
};
/**
* Adds a function to the functionBuffer for delayed execution.
*
* @param - id - An ID for the function while it's in the buffer.
* @param - scope - The object the "this" will referer to in the function.
* @param - func - The function to be executed.
* @param - args - An array of arguments to pass to the function.
* @param - delay - The delay (in frames) before the function is executed.
* @param - total - The total number of times the function should be executed.
* @param - fireOnNext - Can be used to force the function to execute on the next frame regardless
* of the delay time. The default value is "false".
* Forcing a function to execute on the next frame will not affect "total". (optional)
*
* @note - Any function in the functionBuffer with the same ID will be replaced.
* If the value of "total" is set to 0 (zero) or lower then the function will
* not stop executing until it is manually removed from the buffer.
*/
function addToBuffer(id:String, scope:Object, func:Function, args:Array, delay:Number, total:Number, fireOnNext:Boolean):Void {
removeFromBuffer(id);
var timer:Number;
total = (fireOnNext === true ? total + 1 : total);
timer = (fireOnNext === true ? 1 : delay);
__functionBuffer.lib.push({id:id,scope:scope,func:func,args:args,delay:delay,total:total,timer:timer});
__functionBuffer.onEnterFrame = rewire(this, walkFunctionBuffer);
};
/**
* Removes a function from the functionBuffer.
*
* @param - id - The ID of the function to remove.
*/
private function removeFromBuffer(id:String):Void {
var i:Number = 0;
while(i < __functionBuffer.lib.length) {
if(__functionBuffer.lib[i].id == id) {
__functionBuffer.lib.splice(i, 1);
break;
}
i ++;
}
};
/**
* Clears all functions from the functionBuffer.
*/
function clearBuffer():Void {
__functionBuffer.lib = [];
delete __functionBuffer.onEnterFrame;
};
/**
* Walks through the functionBuffer and does what it needs to do.
*/
function walkFunctionBuffer():Void {
var i:Number = 0;
while(i < __functionBuffer.lib.length) {
__functionBuffer.lib[i].timer --;
if(__functionBuffer.lib[i].timer == 0) {
__functionBuffer.lib[i].func.apply(__functionBuffer.lib[i].scope, __functionBuffer.lib[i].args);
__functionBuffer.lib[i].total --;
if(__functionBuffer.lib[i].total == 0) {
__functionBuffer.lib.splice(i, 1);
} else {
__functionBuffer.lib[i].timer = __functionBuffer.lib[i].delay;
}
}
i ++;
}
if(__functionBuffer.lib.length == 0) {
__functionBuffer.lib = [];
delete __functionBuffer.onEnterFrame;
}
};
Example Usage
ActionScript Code:
this.createEmptyMovieClip("__functionBuffer", this.getNextHighestDepth());
//
function testFunctionA(argA:String, argB:Number):Void {
trace("testFunctionA -> " + arguments);
};
var id:String = "myID";
var scope:Object = this;
var func:Function = testFunctionA;
var args:Array = ["abc", 123];
var frameDelay:Number = 10;
var total:Number = 2;
addToBuffer(id, scope, func, args, frameDelay, total);
//
function testFunctionB():Void {
trace("testFunctionB");
};
var id:String = "mySecondID";
var scope:Object = this;
var func:Function = testFunctionB;
var args:Array = null;
var frameDelay:Number = 15;
var total:Number = 1;
addToBuffer(id, scope, func, args, frameDelay, total);
Custom Clip Aiming Based On Function Variables
I'm assuming that this is somehow possible through string concatenation, but I can't seem to figure it out.
I have a number of movie clip instances with each instance named uniquely (clip1, clip2, clip3, etc.)
I have a number of functions that need to be performed within a given clip, but want to avoid redundant code by creating a function that will automatically run on the proper clip based on an integer that's passed to it. Is this possible?
For example, I want to know how I would pass a command that tells clip1 to set alpha in a manner similar to this:
function setalpha (clipnumber, value) {
"clip" + x + "._alpha" = value;
}
thus
setalpha (1, 0);
would find clip1 & set its alpha to 0.
I've tried above but can't figure out the correct syntax (if there is any). Any suggestions?
Thanks!
Changing A Buttons Function Based On Dynamic Text
Hi, im new to the forum, and semi-new at flash, i have experience doing the 'pretty' side of flash, but little in the action script side, and was wondering if anyone could help me.
What i am trying to do, is inside a quiz have a 'next' button, which directs the user to either the next frame or a specific scene based on the response to an answer the user got for the last question.
To explain in a more simplified fashion, if there is a question such as 'The sky is blue' True/False (to use on of the examples from macromedia) if they get it correct, the next button will take them to scene 2 frame 1, if they get it wrong the button will take them to the next frame in the same scene.
Got any ideas of how i can achieve this?
Thanks, Sam
A Mouse-focus Based Pause Function For A Game?
Okay, the title sounds cryptic, but here's what I mean -
So your playing a flash game that's fast paced and mouse-based (hey that rhymes somewhat)... And then you accidentally move your mouse outside of the area of the swf... And then it pauses automatically with a "Continue" button, instead of you just dying or whatever. I've thought you could have a huge button the size of the stage and make it do something when the frame isn't 'mouseover' or whatever, but there's gotta be a better way. Also setting limits on the _xmouse and _ymouse wouldn't work cos sometimes the mouse moves too fast for them to accurately get the last mouseposition... So how would I do it? Any clues?
Actionscript Based Drawing
im looking for resources and or books on creating lines.. drawn by flash.. example.. i would like to be able to process an equation.. over a certain range of numbers and have it displayed on the screen..
Now, i know that this could be done just by replicating mc's at every interval.. but i would like to be able todo it another way.
Pop-up Error In IE6 (based On Actionscript.org Tut)
Hi,
I followed the little tut here:
http://actionscript.org/tutorials/be...er/index.shtml
And it works perfect in Safari.
But IE6 is giving me this error: "Invalid argument."
Its saying this line of code is the "invalid argument"
window.open(URL,Name,features);
here is what I have for the javascript:
<!--
function spawnWindow(URL,Name,features) {
window.open(URL,Name,features);
}
//-->
I dont get it?
To test out what Im talking about, please go here: http://www.alphateck.com/vr3/index2.htm
And click on one of the two "latest pieces" either the koi or the a-neg logo. And see if you get the same thing?
Thanks a mill.
Help Need With ActionScript-based Menu
Last edited by boonhoofd : 2002-10-11 at 05:20.
I need some help.
I've downloaded a Fla from this site.
It contains a menu that uses actionscript.
And now I want to improve it a bit. The situation right now is that the menu reacts on the mouse no matter where it is. I want to alter the code so the menu only reacts when the mouse is over the menu or the area around.
-the menu I use-
So can anybody help me?
EDIT: I don't need help anymore...Thread can be closed now.
My Function Isn't Functioning/Actionscript To Call A Function Flash MX 2004
Hello,
Well in theory I know how to create a function but for some reason I am unable to call it.
Can someone take a look at it and tell me what went wrong. Basically when I go to "a certain page" I want to click on a button and have it go to another page known as "pics" it then will load a jpeg there known as jpeg loader. Now I know it works properly without a functin, but because I am lazy I do not want to write more code than I have to, there are like 300 differnt jpegs I have to load. Thus I need to create a function.
here is my AS
ActionScript Code:
//this is on frame one of my root timeline
//I am trying to call the function "display" on release of my button
omnihotelButton.onRelease = display ("J010 Omni Hotel.jpg");
//this is my function that I set up it is also on my root, but on a different frame
//this function is named display and it goes to the "pics" page and stops
where it then loads a jpeg which is et up as my variable.
//the xscale and the yscale are just setting up my size of the jpeg.
function display(jpeg){
_root.gotoAndStop("pics");
jpegLoad_mc.loadMovie(jpeg);
jpegLoad_mc._xscale=90;
jpegLoad_mc._yscale=90;
}
Actionscript-based Text Animation In MCs
i used the script that's the template in flashtyper, it works when i use the same script and names in the main scene, but when i put it into a movie clip, it no longer loads the text, does neone know if i have to change some variables because it's a movie clip?
Using Actionscript To Load Mc's Based On Frame
hello
i have say for instance a main movie that has frame labels 1-10...say i have three movie clips names mc1, mc2 & mc3...i need mc2 diplayed at frame 3 and mc3 displayed at frame 7 with mc1 being displayed at the rest (1, 2, 4, 5, 6, 8, 9, & 10)...how would i go about using actionscript to do this...thaks a bunch
regards,
mark
Importing A Pic Based On User & Actionscript
I was wondering if anyone knew how to let the user enter a loctation of a picture (on their hardrive, like C:My Documentspic.jpg) and Flash 5 would take that pic and put it into a movie clip. And would it have the regular properties (_xscale, _yscale,etc.)?
Thanks for your help.
Actionscript Based Scaling Effect?(MX)
Can someone give me a quick tutorial on how to create a scaling effect with just actionscript in Flash MX? I can change the _xscale and _yscale properties of MCs but the change is instantaneous. I need something that would create a tweened scaling effect with just the script on the rollover of a button or movieclip. Any help would be appreciated.
Actionscript Based Alpha Tweening
I'm trying to create a menu that uses actionscript to control the alpha of a background image behind the menu-text. I'm new to actionscript 3, but I imagine it will go something like this:
Set up a listener to know when the mouse hovers over the movie clip:
Code:
buttonHome.addEventListener(Event.ENTER_FRAME, buttonAlpha);
Set up the function buttonAlpha:
Code:
function buttonAlpha(e:Event):void {
var buttonMC:MovieClip = MovieClip(e.target);
// magic happens here to the alpha of the button
}
Am I going in the correct direction? Is this called something in particular that I could google and read more about? I'm looking for a solution that would fade the alpha back down to zero, even if the mouse leaves the movie clip before it's been tweened up to 100%. I appreciate any insight or advice anyone can give.
Actionscript Cancels IDE Based Animation?
I have an animation that I created using the IDE and tweens.
I need to flip the mc that is moving, so I have one single line of actionscript at the start:
mc._xscale = -100;
However, putting this line seems to cancel any tweens I've created
Horizontal Menu Based On Actionscript
hi there,
is there anyone tha can help me with horizontal menu sample that already exists as an example in the ultrashock site??
i tried to manage with the script:
on(rollover) {
this._x=_root._xmouse;
please help!!!
Help Needed With ActionScript-based Menu
Last edited by boonhoofd : 2002-10-11 at 05:19.
I need some help.
I've downloaded a Fla from this site.
It contains a menu that uses actionscript.
And now I want to improve it a bit. The situation right now is that the menu reacts on the mouse no matter where it is. I want to alter the code so the menu only reacts when the mouse is over the menu or the area around.
the menu I use
So can anybody help me?
I guess I'm a bit of newbie when it comes to actionscript, so don't get mad ok?
EDIT: I've got it working now...Thread can be closed by mods.
Actionscript Function Similar To PHPs Explode Function?
Hello everyone, first off, I'd like to say hi to everyone as this is my first post and I have joined very recently! So yeah, I'm glad to be here and yeah, hope I find what I need.
Right, well for those of you who know PHP there is a function known as explode(), which basically splits a string apart by a certain character and throws it into an array.
For example, in PHP.
PHP Code:
$string = "lol,text,omfg,wow,hi";
I can explode that string by the , character and it would split up everything and throw each little "section" into an array.
PHP Code:
$bits = explode( ',', $string );
I can now access access the bits by $bits[0], $bits[1], $bits[2], $bits[3], and $bits[4].
Now, is there anyway you can do this in Actionscript? Say I have a string in actionscript and I've datatyped it to a string.
PHP Code:
var myString:String = "text1|text2|text3|text4";
How can I explode, or break apart, the string by the | character and get the "text1", "text2", etc, strings?
Actionscript Gods...PLEASE HELP (Center MC Based On XY Coordinates)
I have an MC on the stage that contains a large map (approx 4 times the stage size). I have a navigation that when a button is clicked an X/Y coordinate is retrieved. I need the map within the MC to center the passed X/Y coordinate.
I have been coding this application for days and need to get this working ASAP but cant figure it out. Im sure its something so stupid that Im missing.
Thanks in advance!!
Simple Actionscript Based Ticker Question.
I threw together this exceedingly simple script:
Code:
onClipEvent (load) {
this.main.text = "Planning & Design";
this.sub.text = "lasting solutions through best technology";
this._x = 300;
this._y = 700;
}
onClipEvent (enterFrame) {
if (this._y > 100) {
this._y = this._y-2;
} else {
this.main.text = "Business Process Improvement";
this.sub.text = "building value through efficient operation";
this._x = 300;
this._y = 700;
}
}
It drops text into dynamic text fields and vertically scrolls the movie clip that contains them. I use a gradient at the top and bottom to effectively make the text disappear and reappear. Check this directory for the FLA:
http://sour.org/flash
My question is, how do I continue the loop to insert more phrases? I have about 10 I need to put in. Is there any way to set up an array or a more effective nested loop?
Thank ya.
Actionscript Based Slide Show For Flash 5?
Hey there guys...
I'm looking for something that I would think would be fairly simple. I've got 6 images that I need to flip through in a Flash ecard that I'm building.
I do this fairly often and each time until now it's been manual. I'm getting tired of manually setting keyframes for each of these images so what I'd like is to automate this somewhat.
A great way to do it would be to set each image on a keyframe, then code some sort of time function that would jump to the next frame after a preset amount of time had elapsed.
Does anyone have something like this or can you point me in the right direction?
andy
Slide Based Screen Visibility Via Actionscript
I’m new to all this and since it just took me two hours to figure out how to do this I thought I’d drop a note in here to see if it helps anyone else.
If you are combining “slide” and “form” based screens in the same application and need to make a slide or a set of slides invisible you can use the following method:
yourSlideName.setVisible(false);
Obviously, the “form” has its own “visible” property but if you want to hide a slide when you have it nested under a form you can use that setVisible method.
Good Luck,
R. Sparrow
Timeline Based Navigation Dropdown To Actionscript
Hi everyone,
I have a dropdown navigation right now that relies on the timeline to show or hide the submenu's. For example, each button has code attached to it that tells it where to go on a rollover. I made the sublinks visible on, let's say frame 50, then the button on(rollOver) would be
Code:
gotoAndPlay(50);
.
My problem is, is that I'm adding this navigation to a timeline based animation, and if I tell it to go to a frame at the end of the animation, the whole animation will be skipped.
I'm wondering if there is a way to show or hide those submenu's using actionscript, so I don't mess with the original animation.
Any help would be great!
Brian
|