Buttons Reacting Randomly.
This is not something I'm trying to do, but rather something that is happening for some reason, which I don't want to happen.
Here is a link to the file:
http://sharkfart.pandhosting.com/doo...toGallery.html
In the bottom, you will see 5 squares with different colors, when you click those colors you will see the backgrounds for the different squares changes. For some reason, you have to double click on some, and some not. Here is the code that controls those buttons:
ActionScript Code: //*** Main Function ***function convertColorString(colorName) { if (colorName == "Red") { myColor = "Re"; return myColor; } else if (colorName == "Orange") { myColor = "Or"; return myColor; } else if (colorName == "Grey") { myColor = "Gy"; return myColor; } else if (colorName == "Blue") { myColor = "Bl"; return myColor; } else if (colorName == "Green") { myColor = "Gr"; return myColor; }}function transferColors(color) { firstColor = convertColorString(_root.bg_mc.blueBg_mc.currentColor); secondColor = convertColorString(color); var colorFrame:String = firstColor+secondColor; _root.bg_mc.blueBg_mc.gotoAndPlay(colorFrame); _root.PG_mc.PGsub1_mc.blueBg_mc.gotoAndPlay(colorFrame); _root.PG_mc.PGsub2_mc.blueBg_mc.gotoAndPlay(colorFrame); _root.PG_mc.PGsub3_mc.blueBg_mc.gotoAndPlay(colorFrame); _root.PG_mc.PGmain_mc.blueBg_mc.gotoAndPlay(colorFrame);}//--- Red ---CMred_mc.invis_btn.onRelease = function() { transferColors("Red");};//--- Green ---CMgreen_mc.invis_btn.onRelease = function() { transferColors("Green");};//--- Grey ---CMgrey_mc.invis_btn.onRelease = function() { transferColors("Grey");};//--- Orange ---CMorange_mc.invis_btn.onRelease = function() { transferColors("Orange");};//--- Blue ---CMblue_mc.invis_btn.onRelease = function() { transferColors("Blue");};
Ultrashock Forums > Flash > Flash Professional
Posted on: 2006-10-07
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help-buttons Not Reacting Until Reverse Completed
Hey everyone,
I'm a newbie and am having a problem getting my buttons to do what I want them to. You can view the actual SWF at:
http://home.comcast.net/~jasonschaeffer/
What I want is for the knobs to rotate on rollover, tell the lcd to display whatever that button is for, and rotate back on rollout. They work fine except for they have to finish rotating back until they are reactive again.
I'd like them to be reactive at any point in their rotation.
I am using invisible buttons to call up the MovieClips. The MovieClips instance name is: knob1. Frame 1 of it's timeline has a stop command, as well as it's last frame.
The LCD is also a Moviclip (instance name: LCD) that is instructed by the invisible buttons to navigate to different frame labels to display different words.
Here is the script that I have assigned to the invisible button over the first knob.
ActionScript Code:
on (rollOver) {
knob1.play();
tellTarget ("LCD") {
gotoAndPlay("band");
}
}
on (rollOut) {
knob1.onEnterFrame = function() {
if (knob1._currentframe>1) {
knob1.prevFrame();
tellTarget ("LCD") {
gotoAndPlay("sonic");
}
} else {
knob1.onEnterFrame = null;
}
};
}
Thanks to all in advance, any help is greatly appreciated.
Randomly Moving Buttons
can anyone tell me how to make objects move slowly and randomly around the screen. I want to use them as menu buttons.
thanks
Randomly Clicked Buttons
lets say i have about 6 buttons..
what i wanna do is... after they're ALL clicked (in no specific order) to give me a screen sayin (picture 2) or sth... and jump to the next frame...
so.. how can i do that?
How To Make Buttons Appear Randomly?
If anyone can help,
I'd like to add an effect to buttons on my home page. When the page loads, I'd like the buttons to be invisible, then the alpha would be raised randomly on each button until they are all fully visible. Kind of an off/on kind of thing.
Anyone know what I mean? I cant find an example anywhere,I'll keep looking.
But if someone can help, I'd greatly appreciate.
Moving Buttons Randomly/ I.e. Fish
I need to make a flash movie where I have randomly moving/floating buttons (fish), which upon clicking, will animate (i.e. blowfish will puff up and make a sound). I figured out the bubble element in the background, but the fish element is giving me trouble.
I've found different sample movies (even aquarium samples) to help serve as examples, but am having trouble tweaking and combining them into my specific needs. They either have -just- randomly moving objects (no mouse events), or if they do have mouse events, they have other additional stuff (i.e. a start button and toggles between different shapes) that I don't need.
What would be the easiest way to move a button on random paths across the screen, and still integrate a mouse-event? Is there a good sample somebody could show me, or point me to a good tutorial?
thanks so much!
OnRollOver Randomly Position Buttons...
I'm trying to create 3 empty movieclips (that act as buttons) through actionscript, then whenever I rollOver one they all reposition to random _x and _y values.
The script works fine all the way to repositioning them.
My code looks like this:
code:
buttonAmount = 3;
for (i=0; i<buttonAmount; i++) {
createEmptyMovieClip("button"+i, i);
buttons = _root["button"+i];
//I added the drawing script so
//I can momentaryly see the buttons
buttons.lineStyle(5, 0xff00ff, 100);
buttons.moveTo(0, 0);
buttons.lineTo(30, 30);
//random position function
randomPos = function() {
buttons._x = random(Stage.width);
buttons._y = random(Stage.height);
}
//and event handlers
//on rollOver calls the sound function, randomSounds
//and on rollOut calls the random position function, randomPos
buttons.onRollOver = harmonySounds;
buttons.onRollOut = randomPos;
buttons.useHandCursor = false;
}
When I test it I see only two movieclips, the third ran off the stage somewhere, one of them is stuck in the top right corner and wont move, and the third works...well, fine...
What mistake am I making?
Thanks in advance for any help.
Start Floating Buttons Randomly On Stage...
Hi again
I have 5 buttons on my stage which float about but I would like to have the start up floating at random whenever they are loaded. I'd appreciate some help with this as I have modified someone elses code and do not have a firm grip on how "random" works in code...
Here is the code
PHP Code:
onClipEvent (load) {
ydirection= -1;// I am guessing this is where I would make the change?
xdirection=1; // Same as here?
top = -142;
bottom = 185;
left = -20;
right = 500;
}
onClipEvent (enterFrame) {
if(this._x >= right){
xdirection=(random(1)+1)*-1;
}
if(this._y >= bottom){
ydirection = (random(1)+1)*-1;
}
if(this._x <= left){
xdirection=random(1)+1;
}
if(this._y <= top){
ydirection = random(1)+1;
}
newx=this._x+xdirection;
newy=this._y+ydirection;
this._x=newx;
this._y=newy;
}
Reacting To PHP
HI all...
I was wondering how I'd be able to make my flash navigation movie (the long bar at the top of the page at http://www.magic2k.com ) react to a PHP variable.
At the moment it's done with different versions of the same movie, but i'd like it to be the same one, but react to a php variable, which then moves the time line dynamically.
Any idea how to do this?
like an onload command or something?
Thanks.
Movieclips Reacting To Each Other
Hi Guys
Can anyone please help me or point me to a tutorial that can help me!
On my main stage, I have a navigation MC named NAV. Depending on where you click, the NAV MC loads various SWF files of varying widths (rectangles) into the main stage. What I want to do is get the loaded SWF files to move/reposition the NAV MC along the x axis in relation to the SWF size and then when unloaded the NAV MC must go back to its initial position. The thing is that I want the NAV to 'slide' into its new position, decelerate and then stop. Please see attached visual.
Any help will be greatly appreciated.
MovieClips Reacting Off One Another...
hey guys...
PLEASE HELP!!
I have a mc named NAV that I am using as my navigation... it loads various sized swf's... what I am trying to do is get the NAV mc to reposition itself in relation to the physical size of the loaded swf and then move back to its original position. I want the NAV mc to move as if it is being repelled by the loaded swf like two positives on a magnet, and then come to a gradual stop. Is this possible? Can anyone help me out??
Please see
Thanks guys
Mc Not Reacting To OnRollover
hello
if you put a movie clip by hand on stage and give it an instance name you can easely rollover it but it seems not to work with a dynamicly created mc
This is what i'm trying to do (code below):
1) creating a movieclip instance on the stage (no problem)
2) loading an image in this movie clip (no problem)
3) having it react like a button with onRollover
and this where it does not work .
Code:
this.attachMovie ("thumb_mc", "newThumb_mc" , 1)
//newThumb_mc = this ["newThumb_mc" + i];
//trace (this ["newThumb_mc" + i])
newThumb_mc.loadMovie ("images/small/flo_doelac_0001.jpg");
newThumb_mc._x = 20
newThumb_mc._y = 20
newThumb_mc.onRollOver = function (){
trace("touch it")
}
Thhanks for any help
Regards
Flash Reacting With Html
Hey all,
Okay I am trying an experment using flash and HTML. Basically what I want to do is have one swf movie on my web page but when you click on a button a square changes but the flash doesn’t re-load even though it goes to a new html page.(I know I can make it work with frame but I don’t want to use frames)
Any insight would help.
Cheers.
Reacting To An External XML String
Hello all.. humble designer here posting a question as my technical pal is on leave...
Next week we're adapting a demo of ours.. the change is to react when the attractor loop receives an XML string from an external feed. Currently the attractor loops until a user clicks the screen, then the demo branches off; now we want it to also jump out when the XML string is sent over. Unsure of the technology being used to send it .. or anything technical really..sorry
Is this possible
Huge thanks everyone !!!
Ed
MC Reacting To Mouse Movement... Please Help
Hi guys
Please go here: www.utr.co.za.
I am trying to get that effect where the mc's move subtly in opposite directions to the mouse's movement.
Can some please help me find a SIMPLE script or example that a novice like me can follow. Pleeeeeeease. I have flash MX ver 6.
[MX] Please Help With My Script - MC Reacting To Mouse
Hi Guys, please help a newbie out.
I want to do this: www.utr.co.za ( the way the mc's react to the mouse)
and my script looks like this but it aint working:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*0/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/-1000);
_root.xMove = Math.round(_root.xChange/-1000);
this._y += _root.yMove;
this._x += _root.xMove;
this._rotation = myDegrees += 0;
}
I have attached my fla for you to look at.
Any help would be greatly appreciated!
Please Help With My Script - MC Reacting To Mouse
Hi Guys, please help a newbie out.
I want to do this: www.utr.co.za ( the way the mc's react to the mouse)
and my script looks like this but it aint working:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*0/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/-1000);
_root.xMove = Math.round(_root.xChange/-1000);
this._y += _root.yMove;
this._x += _root.xMove;
this._rotation = myDegrees += 0;
}
I have attached my fla for you to look at.
Any help would be greatly appreciated!
Reacting To Stage Resize?
Is it possible for me to execute events once the stage is resized to below a certain width and/or height when my flash movie fills the browser 100%?
I know its possible. I've seen it done. Resize the browser smaller here and watch what happens:
http://ff0000.com/
Granted, these are the geniuses at Red Interactive, but I figure that part can't be too difficult can it?
I took Lee Brimelow's tutorial here:
http://www.gotoandlearn.com/player.php?id=31
and tried to adapt it a bit, improvising my own code but its not working, obviously (with apologies to Mr. Brimelow...).
function ahem() {
if (Stage.width<=300 || Stage.height<=200) {
setProperty(this.ahem, _visible, true);
} else {
setProperty(this.ahem, _visible, false);
}
}
ahem();
var stageL:Object = new Object();
stageL.onResize = function() {
ahem();
picture._x = Stage.width/2;
picture._y = Stage.height/2;
};
Stage.addListener(stageL);
Is this the right way to go about this? I completely new to listeners, so maybe its just something that I'm unaware of?
Not Reacting To Keyboard Event..
Ive had some succes now, learning AS3.
But i cant figure out why this code is not letting my keydown function execute.
I do this in the FLASH ide, I use a document class as my main class. Which then creates a instance of a Player class, where it has a keyboard eventlistener, but when i press a key nothing happens.
Code:
package classes
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class Player extends MovieClip
{
public function Player()
{
trace("Hero!");
addEventListener(KeyboardEvent.KEY_DOWN,checkKeysDown);
//this.setFocus();
}
private function checkKeysDown(event:KeyboardEvent):void
{
this.x++;
trace("kgkl");
trace("You pressed key: "+event.keyCode);
}
}
}
I have disabled the keyboard shortcuts in the flash player, but it is not reacting at all :.
I'd really appreciate it if someone can tell me what is going on here.
Animation Reacting On Sound
Hi, i'm trying to make an animation that reacts on sound-input (sort of like an equalizer), but i have no idea where to start. is it possible to have 'live'-soundinput as a source for this animation? how can i process the different soundlevels of different frequencies of for example music coming in from the line-in?
thanks alot in advance!
Slow Reacting Rollovers
View the attached SWF. I used kirupa's telltarget tutorial. When you roll your mouse over the rollovers too fast, they don't play the roll-off animation. while using a slow mouse speed, they work. How do I fix this?
Animation Reacting On Sound
Hi, i'm trying to make an animation that reacts on sound-input (sort of like an equalizer), but i have no idea where to start. is it possible to have 'live'-soundinput as a source for this animation? how can i process the different soundlevels of different frequencies of for example music coming in from the line-in?
thanks alot in advance!
Reacting To Events Problem
G'day
I am trying to build a learning game for my final assessment and have hit a big snag.
I have enemy moving randomly on stage (in a confined space), I have a player who must move past the enemy (defence) to score a try (touchdown) when the player touches a defender the defender will then give chase.
The problem is only one defender is recognized and it only chases when the player is in actual contact. This is due to it being within the hit test function but I have tried reason to place the function then tried it everywhere with no success.
As you see the enemy is attached in a for loop set to a variable I thought if I target the variable all would be affected, wrong. I would have been happy if they were all affected, even though my goal was to affect them individualy.
Can anyone help.
Code:
base = this;
var numOfItems:Number = 8;
//---------------------------SETTING UP THE ENEMY ON THE FIELD AND SETTING THEM TO MOVE RANDOMLY-----------------------------------------
function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
//trace("this is" +_root.hyp);
}
function hyp(a, b) {
return (Math.sqrt(a*a+b*b));
}
MovieClip.prototype.reset = function() {
//specify the width and height of the movie
width = 300;
height = 280;
//-------------------
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*.5+1;
this.targx = 200+Math.random()*width;
this.targy = 20+Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)*norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.f) {
this.f = getTimer();
}
if (getTimer()-this.f>1000) {
this.reset();
this.f = 0;
}
}
this._x = this.x;
this._y = this.y;
//trace("this"+this._x);
/*if (t.hitTest(oz)) {//this has unusual results
trace("you hit the oz");
delete move();
}*/
};
for(i=0;i<numOfItems;i++) {
var t = this.attachMovie("enemy","enemy"+i,i+1);
t._x = Math.random()*200;
t._y = Math.random()*100;
t.onEnterFrame = move;
}
onEnterFrame = function() {
if (t.hitTest(oz)) {
delete t.onEnterFrame;
chase(t, oz._x, oz._y, 0.01);
trace("you hit the oz");
}
}
//--------------------------PUTTING OZ ON FIELD AND CONTROL OF MOVEMENT-----------------------------------------
var speed = 5;
var oz = this.attachMovie("player", "player", this.getNextHighestDepth(), {_x: Stage.width-40, _y: Stage.height/2});
oz.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this.play();
this._rotation = 90;
this._x+= speed;
}
if (Key.isDown(Key.LEFT)) {
this.play();
this._rotation = 270;
this._x-= speed;
}
if (Key.isDown(Key.UP)) {
this.play();
this._rotation = 0;
this._y-= speed;
}
if (Key.isDown(Key.DOWN)) {
this.play();
this._rotation = 180;
this._y+= speed;
}
if (Key.isDown(key.RIGHT) && Key.isDown(Key.UP)) {
this._rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
this._rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
this._rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
this._rotation = 225;
}
}
//------------------------------------SETTING UP THE CHASE & kill OF ENEMY ON OZ---------------------------------------
function chase(mc, xPos, yPos, speed) {
targetx = xPos;
targety = yPos;
xdif = targetx-(mc)._x;
ydif = targety-(mc)._y;
if (xdif>=-1 && xdif<=1) {
(mc)._x = targetx;
} else {
(mc)._x += xdif*speed;
}
if (ydif>=-1 && ydif<=1) {
(mc)._y = targety;
} else {
(mc)._y += ydif*speed;
}
}
function endGame(mc, xPos, yPos, speed) {
targetx = xPos;
targety = yPos;
xdif = targetx-(mc)._x;
ydif = targety-(mc)._y;
if (xdif>=-1 && xdif<=1) {
(mc)._x = targetx;
} else {
(mc)._x += xdif*speed;
}
if (ydif>=-1 && ydif<=1) {
(mc)._y = targety;
} else {
(mc)._y += ydif*speed;
}
}
Thanks Easy
Stacked Instances Reacting Independently: How?
One remaining conceptual/technique question which I think will get me most of the way through a project...my deepest gratitude to anyone who can help.
I have multiple, mixed instances that are layered (stacked), one on top of the other. I'm having trouble getting them each to react to mouse events.
For example, I have a button instance that reacts normally to a mouseOver event. When I put another, different button instance (or a movie clip) over the first one, the first one no longer reacts to the mouseOver event. Now, only the second (topmost) instance reacts.
Is there a way to tell them *both* to react to the mouseOver event?
I thought perhaps the (enterFrame) code might work, but again, can you apply the "enterFrame hit test" to multiple movie clip instances that are stacked (layered) one on top of the other?
Conceptually, it's the "multilayered" thing I'm having trouble with.
Could I simply instantiate (name) each button or movie clip instance, then refer to those named objects in an enterFrame script?
I feel like I'm circling around this problem, possibly close to getting it, but still not there!
Thanks,
Scott
Movieclip Reacting To Another Movie Clip.
I have a scene in my flash movie where the user has to click on a "forward" button to move the character across the screen: fwd_btn.onPress = function(){
knight_mc._x +=15;
};
we also have a continue button to switch the user to another frame that contains a scene.
cont_btn.onPress = function() {
gotoAndStop (4);
};
My question is, is it possible to get rid of the continue button (keep the forward button) and replace it with a blank movieclip?
Id like to have the knight_mc move with the forward button but once it touches the blank movie clip gotoAndStop(4). Anyone know the code on how to do this? Help would be extremely awesome.
X+Y Axis Scroll, Reacting To Mouse?
Hi there
To make a long story short, i have a scene, with a huge movieclip on it, lets say that movieclip is called "box". Now i want to be able to navigate around with my mouse... Not by clicking, or dragging scrollbars or the actual movieclip, but like any other scrolling image gallery, when i move my mouse to the left of center, the movieclip moves to the right. If i move up, the movieclip moves down.
I am able to make this work on either the Y or the X axis, but when i try to combine those two, i doesnt work as intended.
If you dont know what i mean, here is a link of the behavior i want
http://www.flashimagegallery.com/pics/artwork/
Click on the sketch of a guy who is number two, in the second row.
Actually it moves the wrong way when you move the mouse, but that should be easy to change with some minus characters.
Can anyone help me out figuring this code out? Ive searched for days, trying to find what im looking for, and ive even posted on 2 other forums before i found this one, but i havent got a reply yet, which im hoping to get here, cause this forum seems to be a bit more pro, that the others ive used.
Thanks in advance
Menu With Submenu Reacting On Mouse
Hi guys, can someone point me how the menu of this site is done? http://www.richhonour.com/ go to the what we do section and you will see what im talking about, it reacts on mouse mouse and has a submenu, i really need this kind of menu and no clue where to start, thnx anyway
Reacting To Events In The Browser Window
Hi all,
I know how to send & receive data between flash & PHP, but only for events that come within flash itself. Is it possible to listen for events outside of flash that occur in links/buttons on the browser page & make flash react to them? I just need to know what subject areas I need to be learning & a few links to get me started would be really helpful.
Thanks,
PMF
Menu With Submenu Reacting On Mouse
Hi guys, can someone point me how the menu of this site is done? http://www.richhonour.com/ go to the what we do section and you will see what im talking about, it reacts on mouse mouse and has a submenu, i really need this kind of menu and no clue where to start, thnx anyway
Flex Reacting To MOUSE_MOVE Outside App's Boundaries
I'm finding that when adding a MOUSE_MOVE event handler at the root level of a script in the mxml file that mouse events aren't generated when the mouse is moved outside the application area, even if the flash app still has the focus.
For example, a custom vertical scroll bar. Dragging the scroll bar is fine, but a small horizontal shift of the mouse, taking the cursor outside the flash app's boundaries, will cease movement until the mouse is brought back in.
It doesn't appear to work this way when adding the MOUSE_MOVE event to the Stage when I tried it in Flash CS3.
Should I be prefixing the addEventListener with a different object?
Reacting To Sound Output Via SoundMixer.computeSpectrum()
I wanted to design a pesudo-visualizer of sorts, so I looked up the computeSpectrum method...
I can get a ByteArray out of it, but I don't know how to read the data out of it properly (I know the format 512 bianary numbers, but I don't know exactly what I should do with them...
Movie Clip Reacting To Mouse Distance
Hi There.. i want to create an effect so that if the mouse is 100 pixels or more away to the left (_x >100) a MC goes to frame 5 whilst animating towards the mouse but when it gets to within 30 pixels (_x >30) it goes to frame 4, then when it is matching the _x of the mouse + or - 5px it will goto frame 3.
I kinda have some garbled code which i kinda understand:
This sets the motion when in a 2 frame loop only for the X:
setProperty (eval("myMC"), _x, myMC_x+((getProperty(eval("myMC"), _x)-myMC_x)/1.2));
///////then this tells it that if its within 5 pixels gotoAndStop(3);
if ((myMC_x-eval("myMC")._x)<5 and (myMC_x-eval("myMC")._x)>-5) {
eval("myMC").gotoAndStop(3);
}
///////and if its within 30 pixels gotoAndStop(3);
else{
if ((myMC_x-eval("myMC")._x)<30){
eval("myMC").gotoAndStop("4");
}
}
/////////////////////////////////////////////
but nothing happens do i need to define something else??
Cheers for any help and if you need anything let me know.
Cheers. Rob.
MCs Appear Randomly From The Library And Move Around Randomly
Hi
Onmy stage I have a MC, and when I click it a random MC from the Library should appear and move around randomly.
I'm using this to make it move around randomly http://www.kirupa.com/developer/acti...dom_motion.htm
But I can't figure out how to make the random MCs appear from the library.
And should I put the random moving script on each of my ten MC?
Hope somone can help.
Best regards
Jost
Attaching A Movieclip And Reacting To A Mouse Click. Once So Easy - Now Not So Much.
This is my first as3 project and it's fairly simple: read in values from an xml file (love that), and then loop through the results. For each result, I want to:
1. Attach a movieclip
2. Change the text in the clip to match the text in the xml
3. Be able to click on the clip and have it echo back the text I just added.
I've got this code so far
[php]
function boxClick(event:MouseEvent):void {
trace("box clicked");
}
function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
var slideList:XMLList = xml.slides.slide;
var newX:int = 50;
var newY:int = 25;
var slide1:XMLList = slideList[0].options;
//for (var i:int = 0; i < slide1.length(); i++) {
//trace(slide1.option.optionlabel.text());
//}
for (var i:int = 0; i <slide1.option.length(); i++) {
var box:mcAvatar = new mcAvatar();
box.x = newX;
addChild(box);
newX += 100;
trace(slide1.option[i].optionlabel.text());
box.gender.text = slide1.option[i].optionlabel.text();
trace(box.gender.text);
box.addEventListener(MouseEvent.CLICK, boxClick);
}
}</PHP>
but, although I draw the boxes out and I get the right value in each box's test field, it won't respond to any mouse clicks. What am I doing wrong?
Movie Clip Inside A Movie Clip Not Reacting When Pressed
Hi,
I am a beginner and I don't know how to make a movie clip that I attached to another movie clip become activated. I am not sure if it has to do with the depth issue, which I don't completely understand.
But this is what I want. I have placed a movie clip (a rectangle shape) on the stage and linked that movie clip to an actions script file. In that file (Button_group.as) I dynamillycally place another movie clip (Email_btn) which is linked to another actionscript file called "Email_btn.as" inside the area of the rectange movie clip (Button_group).
Inside the "Email_btn.as" class I specfied an "onPress " function that prints something. Now when I play the movie and I press inside the "Email_btn" movie clip nothing happens.
So the question is how do I specify that I am "pressing" the "Email_btn" (inside clip) area and not the parent "Button_group" area?
This is snippet of the code of Button_group that dynamically places the inside movieclip "Email_btn":
class com.macromedia.flashvideogallery.Button_group extends MovieClip
{
var email;
function Button_group()
{
init();
}
private function init():Void
{
trace ("MALENA");
this._alpha = 0;
email = attachMovie("Email_btn", "Email_btn1", this.getNextHighestDepth(), {_x: _parent._x , _y: _parent._y } );
email._visible = false;
//_parent.email_btn.onPress = function () {
//trace ("send email");
//}
}
thank you
-Malena
Randomly Placed MC?
I am trying to create an image that is masked by multiple instances of a circle that is randomly placed throughout the image.
Therefore, the masks expand, resulting in showing the image underneath.
Is this possible to do in Actionscript? My problem is that I don't know whether or not the whole image is being shown, and when to stop duplicating the Movie Clip (cirlce).
Is there a way to find these out?
Thanks
Randomly Come In
Hi, I saw some of the effect is that lots of lots of dots move in from outside of the stage and then become some sort of picture, how did they do that? is it like you have to set all the dots to specific position? so if you have a huge tank picture, and you have to use 10000 dots, do you have to set its position one by one?...so curious about it, any tutorial or theories?? thanks for your help!
Randomly Moving MCs In A Box.
i have about 4 MCs that i want to randomly move inside a box on my page. on mouseover, i want the MC's to Slowly fad out... how could i achive this ?
Using Array Randomly?
I am using an array for generating the _x positions of multiple duplicate MC's. I want the MC's to take their _x value randomly from the array but I want the MC's to only take a value that has not been used from the array. When I try and do this I seem to be using endless loops that don't work. Does anyone know a way to do this?
Thanks
e.g.
// x positon array
xpos = new Array();
for (i=0; i<20; i++) {
xp = i*20;
xpos.push(xp);
}
// duplication loop
ccount = 1; // clip counter var
while (ccount<20) {
_root.rantxt.duplicatemovieclip("graph"+ccount, ccount);
// x placement (cannot make this random and unique)
_root["graph"+ccount]._x = xpos[ccount];
ccount += 1;
}
Randomly Dissapearing MC's
I'm working on an Invaders style game. Each enemy is a duplicated MC. For some reason, they dissapear at random. I've checked everything that I can possibly imagine would have anything to do with this--visibility, position, removeMovieClip, etc. However, none of these is the cause of the dissapearances. Is it possible that flash is deleting them because there's not enough processing power? (I'm forced to work on my dad's PI laptop). Can anybody explain why this is happening?
Many thanks for any help that you can offer.
Randomly Happening
Greetings:
I need help on a small problem. I have a movie clip instance called lighting, which shows a bolt of lightning in the stage blinking in and out. Now what I want that movie clip to do is to randomly do it without having me telling it where to strike. I want it to strike in different places on the stage. I hope this is a clear question of what I ask.
Thanks
Randomly Loop MC ?
is there a way to have a movie clip go back and play itself from a random frame number? (Does that make sense?)
I have a sequence of .gif files that create an orbiting 3D floor plan that i would like to have continualy orbiting but i want it to start at a different point during the clip everytime.
Is it possible? I am VERY NEWBIE to actionscript, so be gentle
Thanks.
Randomly Loading Swf's
I have a flash file that includes an ad but the ad needs to rotate between 3 different files. This should happen randomly, so when the main flash file is loaded, a random ad is loaded into flash. Can someone help me get started, as I don't know really where to go from here. This has to be in Flash 5, by the way.
Thank You!
Load An Swf Randomly
I'm using the loadMovieNum action to load a series or four external swf's, one at a time, into level 1 of my project.
I'd like to set it up so that each time the level 0 page loads, the action on its first frame randomly chooses one of the four swfs to drop into level 1.
I've written a function that randomly generates a number from 1-4 but I haven't quite figured out how to apply it to randomly choose an swf from my directory.
Any suggestions?
How To Move A Mc Randomly?
how do i make a movie clip move in a fly-like or bee-like fashion? but it has got to be a random movement. i'm kinda new to action scripting, you see.. help!! thanks!
Randomly Fading In And Out...
i've got this on a movieclip:
PHP Code:
onClipEvent (enterFrame) {
if (alphatarget == undefined) {
alphatarget = Math.random()*25; // sets the alpha it will fade to (0-25)
timetotake = Math.round(Math.random()*100)+25; // sets the number of frames it will take to do this (25-125)
time = 0; // resets counter
alphaperframe = (alphatarget-_alpha)/timetotake; // looks at the target and time to take, and finds out how fast it will have to go, and if it's fading in or out
} else {
time++; // tick the time
_alpha += alphaperframe; // change the alpha
if (time == timetotake) {
delete alphatarget; // if the time's up (and so it's finished fading) start over
}
}
}
it's supposed to make it randomly fade in and out. only when i debug and look at the alpha of the thing it seems to fade a bit, then stick at 0 for ages even though the target is more than 0.
can anyone see what's wrong?
thanks
-bart
Playing An Mc Randomly
I've got an mc that is a short animation that gives a glimmer effect on a logo. It plays once as the site opens using a tween on the timeline. If i make this animation within one mc (the mask and the glimmer) how can i make it so that the mc randomly plays its animation?
in other words how can i trigger an mc to randomly play its animation?
Thanks.
Randomly Loaded Swf ... How Is It Done?
Hi guys, I wanted to get help on one thing! I already am maintaining several web sites, but I want to make changes so that they don't become boring! I had an idea but I don't know how to program it! I don't know if is it done but some scripting on the html, or with some actionscript! One of the websites at the homepage contains a swf which includes photos! Lets imagine that it is a web site of a public swimming pool! And that on the homepage there are several photographs of different views of the pool! But I only want to have 2 photos of the different views of the pool, on the same swf! I wanted to make 5 or 6 equal swfs, with only one difference, the photos that which one would contain! How can I tell the user/viewer browser to ramdomly load swf1 and the next time it acesses the site it would load swf2, so that the photos would ALWAYS be different each time it loaded for the user/viewer? I hope I could make myself clear, and that someone helps! Many thanks in advance for any help of anyone, and for the chance of posting here! Keep up the good work guys, and THANK YOU for existing to all the Flashkit team! =)
Regards
David
|