ActionScript 3.0 :: Press Button To Show Random Image?
Mar 30, 2012
I'm used to working with the timeline and don't often go into the actionscript side of things.
I've created a 60 second animation of an hourglass timer counting down, and next to it, is a card showing a word. I need this whole animation to play when you hit a 'start game' button and also I need the word on the card to be a random word. All of the words are saved as separate vector files for now.
What is the best way to manage this on the timeline, and what would be the code to make a random image appear?
im currently trying to make a game for a college project, im using flash professional 8, the game rquires a random sound to be played on a button click, but i have no idea how to do that? all my sounds have instant and libary names of sound_1, sound_2 ect and i currently have this actionscript in place on the button, the button is called play_sounds.
play_sounds.on(mouseDown) = function(){ var randNum = Math.ceil(Math.random() * 10); var mySound = new Sound();
I am making a navigation menu in that I want a curtain to show up on the same page. In other words the user just stays in the same page and different curtains show up according to which menu button he presses with the corresponding content showing up in a curtain. I've given diferent names for each menu button which i converted to Movie Clips: bt_eol; bt_mar; bt_hid; bt_amb; bt_who. Then I created a Movie clip for the curtain and put it on frame 40 so that I can load a .doc file that has the content for the Menu button bt_eol.
Code: function bt_eol(e:Event) { mc_conteudo.gotoAndStop(40); mc_conteudo.source="Conteudos/eolica.doc"; } bt_eol.addEventListener(MouseEvent.CLICK,bt_eol);
The mc_conteudo is the curtain. But I get this two errors: Incompatible override and Duplicate function definition. Or is it better to use a UILoader? This is probably easy to do as I've saw this on other websites,the user just presses a menu button and a frame/curtain/window whatever shows up with the content.
I wanted that, when I place the mouse on the button, a movieclip appears, but in a random place in the screen, with a random size and a random color and plays until all its animation is complete, and then disappear.How can I do that? I don't know even where to start!
I have a image gallery but when I put the whole thing into its own new movieclip and THEN insert it on the main timeline it doesn't work. It only works when its scripted on the main timeline but I don't want it on the main timeline because I want my gallery to appear after I press my button.
I want to make a button that makes you got to a random frame within a certain range (eg frame 41-50) when you press it. I have tried various codes but so far no luck. Im using AS 2 and the button is within a couple of movie clips, but you can still click it when you test
I have made a bitmap image into a rollover button - reason - so that when the mouse rolls over the hit area of the button/image/thumbnail - it becomes larger on the stage and when the mouse moves outside the paramaters of the larger picture it goes back down to the original button/image/thumbnail size.That works fine.However . . . there is always a however. When I implemented the same functions to the other thumbnails on the stage - if I rollover the second thumbnail- the other thumbnails show up (through) on top of that enlarged image.
This is the great slideshow from Noponies and I wanted to add a url link by XML to the whole image. I'm pretty close by now but I just can't seem to link it to the xml
I'm trying to put together a sideshow using a modification of load_images.fla (a sample file supplied with Flash) combined the the 'Kirupa Menu with Slider' tutorial ([URL]) The slideshow uses a 'next' & 'previous' button to click thought the images. In addition to this I have a separate slide menu navigation (currently just numbers 1-7), with a rectangle highlighting the number of the image being viewed. I would like to move the rectangle to show which image is being viewed, when the 'next' or 'previous' button is pressed. The follow code shows the actionscript for the 'next' & 'previous' buttons....
ActionScript Code: **Error** Symbol=movieclip, layer=Layer 1, frame=1:Line 3: Statement must appear within on handler movieclip.gotoAndStop ("framelabel",random(4)+2); **Error** Symbol=movieclip2, layer=Layer 2, frame=1:Line 3: Statement must appear within on handler movieclip2.gotoAndStop ("framelabel"random(10)+2);
. The AS is on said button within the MC, and the MC has an instance name.This is the AS I'm using. I'm trying to make a randomize button that generates a random frame in my flash file instead of one MC..
ActionScript Code: on (release) { movieclip.gotoAndStop ("framelabel"random(4)+2); movieclip2.gotoAndStop ("framelabel"random(10)+2); }
I can't sort out what's wrong with my code (see below). Basically, I have two mc and two buttons in the library. One movieclip linked to "Card" class and has multiple frames with images in it. The other mc is empty and linked to "CardObject" class. The goal through button clicks, user can keep flipping the card and getting new image each time (or prevBtn to go back to prev frame).OOP is new to me, I've done mostly timeline animations and simple coding right on the timeline, so excuse the mess LOL
public class CardObject extends MovieClip { //add variables for card and buttons public var thisCard:Card = new Card();
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
I want the press button to detect the last button pressed and if the shapes match, make them do something...obviously. I think I'm going at it the wrong way. I need to stick a "triange" id into the button/mc then if compares that and then if there is a match works then... right?
i'm designing a website in flash8... now i have created some buttons, and i want that when i click on the button stars will fly from them and there will be a sound... i have already created the animation of the stars seperatly and it's in the library, i have also the sound file.... i just can't remember how to put everything together.... when i'll press on the button the stars will be flying from the button and the sound will play?
i have a set of buttons cranked out from and XML file. how can i emulate, in code, a press on one of those buttons? i'd like to 'press' one of them for an initial state so that the list it controls will load first off instead of waiting for the person to click it manually and THEN show the list it's connected to. thing is, the first loaded list is going to be random, so i need to 'press' what on another day/load would be a button that the user would press themselves.
in other words, i have 3 buttons. on random, i have to 'press', say button 2, to start. users can press 1 or 3 and then 2 again if they like. another time, it's button 1 that gets 'pressed' on load, etc. make sense? i have a sneaking suspicion it might be easy... or stupidly convoluted.
I have 6 button call m1-m6...ok my problem is how to disabled button when one of the button being press...and also stt.text will display crrently selected button...coz currently when I press the button it never stated and also 'stt.text ' also show nothing.
I have an image on the stage which is bigger than the stage itself:
The stage is 700x550
The image is 2100x1650, and it's registration point is at its center, if I remember correctly.The initial location of the image on the stage is 350,75.I want to make sure that the user will be able to drag the image, as long as the edges of the image doesn't show.here's what I did:
mapRect = new Rectangle(0-mapMC.width/2, 0-mapMC.height/2, mapMC.width, mapMC.height);
and later on:
mapMC.startDrag(false,mapRect);
The the top and the left of the image are bounded well, but as far as the bottom and the right side of the image.
How can I show an image that I have just captured with the webcam?I am able to save that image using PHP but before I save it, I want to show a preview. How can I do this? Here is a snippet of the code that I think can be used to do this:
ActionScript Code: foo = new BitmapData(640,480); foo.draw(myvideoobject, scaleMatrix);
Flash in general so this is probably above my skill level. Basically I have 3 movieclips, called random1, random2 and random3 for the sake of this.I want, at the start of the frame to pick one of the three objects at random, keep that object visible, and hide the other 2
I have 3 separate movieclips, called random1, random2 and random3 for the sake of this.I want, at the start of the frame to pick one of the three objects at random, keep that object visible, and hide the other 2.