HELP WITH AS3 Removing Movie Clip
every code i try in the action script to remove a movie clip off of the stage does not work. HELPPPP.
well this is my code to bring it onto the stage
import flash.events.MouseEvent;
pills.addEventListener(MouseEvent.CLICK, arrest)
function arrest(pEvent:MouseEvent):void{
if(pEvent.target==pills){
var carimage: policecar= new policecar();
carimage.x=0;
carimage.y=0;
this.addChild(carimage);
and the remove is under a different clip
stop();
bars1.addEventListener(MouseEvent.ROLL_OVER, barsout)
function barsout(pEvent:MouseEvent):void{
if(pEvent.target==bars1){
this.removeChild(carimage);
even when i add the latter code into the origininal code above it tells me access of undefined property (carimage)
Similar Messages
-
Help With Swapping A Movie Clip
homerreg.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
homerreg.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
homerreg.buttonMode=true;
function mouseDownHandler(evt:MouseEvent):void{
homerreg.startDrag();
homerreg.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
function mouseUpHandler(evt:MouseEvent):void {
homerreg.stopDrag();
homerreg.removeEventListener(MouseEvent.MOUSE_MOVE , mouseMoveHandler);
function mouseMoveHandler(evt:MouseEvent):void{
if (homerreg.x>pumpkin.x){
homerreg.alpha = 0.4;
homerreg and homerzombie are movieclips. This is from a tutorial and
the last line states if the homerreg movie clip passes the pumpkin
movie clip in the center of the screen it's alpha channel changes.
What I want to do is swap the "homerreg" movie clip and have the
homerzombie movie clip come in when it passed the pumpkin movie clip.
Anyone know how I could do this?
Thanks in advance.If you retained the homerreg movieclip as the main one, having regular homer on frame 1 and zombie homer on frame 2, then the following code should work in place of what you had before...
function mouseMoveHandler(evt:MouseEvent):void{
if (homerreg.x>pumpkin.x){
homerreg.gotoAndStop(2); -
Need help with AS3 to play movies
Here is my what I'm working with: Flash CS3, AS3. I have 4
buttons and 4 movies (each button will be asigned to play one of
the 4 movies).
Not sure if this is the best layout but here is what's
included in my file. I have an Actions layer, 4 buttons (on 4
different layers), 4 embedded movies (on 4 different layers...all
about 5-8 seconds long). I'm sure this is simple but figuring out
the code for AS3 is like learning Chinese....I need major help with
this.
Lets say that my buttons have instance names like button1,
button2, button3, button4, and my movies have instance names like
movie1, movie2, movie3 and movie4. Here's the catch. I don't want
the movies viewable (or seen) until the user selects one of the
buttons. So if the user selects button1 the movie will appear (next
to the button without any contols...just a movie with a border) and
play. If the user hovers off or moves the mouse off the button, I'd
like for the movie to disappear.
Can someone please give me the the code needed so that when I
select button1 that it will play movie1, button2 w/ movie2....and
so on.
Thanks for your help!Here is the link to the fla file.
http://joshhicks.com/flash/flashfile.html
I updated the link to the latest swf
http://joshhicks.com/flash/del2.html
I added stop(); to the 1st frame of each moive and this fixed
the movies from playing in the background unseen. If you can help
me with one last question...then the file will be complete. As of
now when you select one of the movies, it plays once thru and
starts back at frame one (loops) which is the way I want it to
play. But if you hover off one of the buttons while the movie plays
(lets say when the movie is showing the number 2) when you go back
to view the same movie, it will start where you left off (it will
start on the fram showing 2 and not 1). How can this be set up to
play from the beginning of each movie everytime you happen to go
back and click on the button? Thanks -
OK...here's my problem... I am making a portfolio site and I
have my thumbnails being created dynamically through XML...very
similar to the galleries example in the Sample and Tutorials. Only
problem is that I have multiple keyframes with different thumbnails
that need to be displyed through a different XML file. I got it to
work but the thumbnails from the first frame are still showing on
the second frame...How do I remove the dynamically created movie
clips?OK...here's the code...At thebottom of the document, I need
to remove the clips created on the next button. This is the same
code from the gallery sample file; I just added my own XML file.
stop();
import mx.transitions.*;
_global.thisX = 30;
_global.thisY = 70;
_global.stageWidth = 600;
_global.stageHeight = 400;
var gallery_xml:XML = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success:Boolean) {
try {
if (success) {
var images:Array = this.firstChild.childNodes;
var gallery_array:Array = new Array();
for (var i = 0; i<images.length; i++) {
gallery_array.push({src:images
.firstChild.nodeValue});
displayGallery(gallery_array);
} else {
throw new Error("Unable to parse XML");
} catch (e_err:Error) {
trace(e_err.message);
} finally {
delete this;
gallery_xml.load("gallery_practices2.xml");
function displayGallery(gallery_array:Array) {
var galleryLength:Number = gallery_array.length;
for (var i = 0; i<galleryLength; i++) {
var thisMC:MovieClip =
this.createEmptyMovieClip("image"+i+"_mc", i);
mcLoader_mcl.loadClip(gallery_array.src, thisMC);
preloaderMC = this.attachMovie("preloader_mc",
"preloader"+i+"_mc", 5000+i);
preloaderMC.bar_mc._xscale = 0;
preloaderMC.progress_txt.text = "0%";
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
preloaderMC._x = _global.thisX;
preloaderMC._y = _global.thisY+20;
if ((i+1)%5 == 0) {
_global.thisX = 20;
_global.thisY += 80;
} else {
_global.thisX += 80+20;
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function() {
mclListener.onLoadProgress = function(target_mc, loadedBytes,
totalBytes) {
var pctLoaded:Number =
Math.round(loadedBytes/totalBytes*100);
var preloaderMC =
target_mc._parent["preloader"+target_mc.getDepth()+"_mc"];
preloaderMC.bar_mc._xscale = pctLoaded;
preloaderMC.progress_txt.text = pctLoaded+"%";
mclListener.onLoadInit = function(evt:MovieClip) {
evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
var thisWidth:Number = evt._width;
var thisHeight:Number = evt._height;
var borderWidth:Number = 2;
var marginWidth:Number = 8;
evt.scale = 8;
evt.lineStyle(borderWidth, 0x000000, 100);
evt.beginFill(0xFFFFFF, 100);
evt.moveTo(-borderWidth-marginWidth,
-borderWidth-marginWidth);
evt.lineTo(thisWidth+borderWidth+marginWidth,
-borderWidth-marginWidth);
evt.lineTo(thisWidth+borderWidth+marginWidth,
thisHeight+borderWidth+marginWidth);
evt.lineTo(-borderWidth-marginWidth,
thisHeight+borderWidth+marginWidth);
evt.lineTo(-borderWidth-marginWidth,
-borderWidth-marginWidth);
evt.endFill();
evt._xscale = evt.scale;
evt._yscale = evt.scale;
evt._rotation = Math.round(Math.random()*-10)+5;
evt.onPress = function() {
this.startDrag();
this._xscale = 30;
this._yscale = 30;
this.origX = this._x;
this.origY = this._y;
this.origDepth = this.getDepth();
this.swapDepths(this._parent.getNextHighestDepth());
this._x = (_global.stageWidth-evt._width+30)/2;
this._y = (_global.stageHeight-evt._height+30)/2;
mx.transitions.TransitionManager.start(this,
{type:mx.transitions.Photo, direction:0, duration:1,
easing:mx.transitions.easing.Strong.easeOut, param1:empty,
param2:empty});
evt.onRelease = function() {
this.stopDrag();
this._xscale = this.scale;
this._yscale = this.scale;
this._x = this.origX;
this._y = this.origY;
evt.onReleaseOutside = evt.onRelease;
mcLoader_mcl.addListener(mclListener);
next_btn.onRelease= function() {
gotoAndStop(2);
back_btn.onRelease= function() {
gotoAndStop(1);
} -
Trying to remove movie clip with collision?
I am creating empty movie clips and populating them with
movie clips that have "drag and drop" functionality. I can create
the empty movie clip and populate it with an external .swf. I've
even got the drag-n-drop handled. But, I'd like to have them delete
or disappear when they are dropped onto a trash can movie clip. I
just can't seem to figure out the code for this. I would greatly
appreciate any help you could give me.
Thanks.you need to perform a hitTest to determine if the item is
within the bounds of your trashcan, you can also use _droptarget,
but I prefer hitTest with a shapeflag parameter. depending on your
code, when you call stopdrag onRelease, run your test there.
the_mc.onRelease = function() {
stopdrag();
if(_level0.trashcan.hitTest(_xmouse, _ymouse, true)) {
this.removeMovieClip();
} -
Removing movie clips with added children
If I have a movie clip added as a child to another movie clip
on the stage, and I remove it's parent, and null all references to
the parent, will both the parent and child movie clip be deleted by
the garbage collector? If so, will it be done on it's regular pass
or by mark and sweep?OK, so if I add a movie clip like this:
function addMovie()
var toAdd:MovieClip = new Example(); // example extends
movieclip
this.addChild(toAdd);
I'm assuming that toAdd will be nulled when the function is
complete, because it's a local variable. Then if I put code inside
the movie clip at a certain frame or in a function in the class
Example to get rid of it:
this.parent.removeChild(this);
I'm assuming that's all i need to do to get rid of it. I
can't null the instance of the class Example using this = null from
inside it, and the only reference to it is the child reference from
the parent.
Am I right or is there more I need to do to make the instance
of example eligible for GC? -
Hello,
I am creating a program that is going to help students learn to read. In my project are pages of text with each word having a button that when pressed will display a movieclip presentation about that word (its pronounciation and spelling etc..). In the project I am working on now I have over 450 unique presentations of words to deal with. I don't want to have all of these hundreds of movie clips on the stage and tell them one at a time to stop and rewind and then have one play each time a word button is pressed. That seems to be very inefficient to me. So I want to do this with some code in Actionscript 3.
I know I can dynamically add movieclips to the stage using addChild(movieclipname) and remove them using removeChild(movieclipname) but there is a problem. I have hundreds of unique movieclips and I don't want to have to manage hundreds of variables containing the indivudual movieclip instancess. It is a real pain having to figure out what instance is still on the stage before i delete it.
In Adobe Director all I have to do is this:
on mousedown me
sprite(me.spritenum).member = member("somenewmember:)
end
and that was it
But if I do this in actionscript 3:
removeChild(some_mc)
some_mc still exists in memory. And I have to know exactly what variable it is to remove or else the movie will fail with an error. If I try to be brutish about it and try to implicitly remove all 450 movieclip instance variables from the stage I will get at least 449 errors.
What I want to do is this:
removeChild(some_mc)
some_mc = void //or //delete some_mc
var some_mc:MovieClip = new someother_mc();
addChild(some_mc)
but this doesn't work
How am I going to remove one of 450 movie clips and add a new totally different movie clip without the code knowing exactly what the last movie clip was? I suppose if could remove a child from the stage based on a string name then I could hold that name in a variable for later disposal.Can I do this?
Thanks for any help you can give me. I am new to actionscript.Hey I think I may have a solution:
//begin code
var myMC:MovieClip = new ball();
var starMC:MovieClip = new star();
var youpresseeditMC:MovieClip = new youpresseedit();
starMC.name = "star";
myMC.name = "ball";
youpresseeditMC.name = "youpresseedit"
addChild(myMC);
box.addEventListener(MouseEvent.MOUSE_DOWN, replaceball);
press_BTN.addEventListener(MouseEvent.MOUSE_DOWN, replaceballwithtext);
function replaceball(event:MouseEvent):void {
trace(myMC.name)
removeChild(myMC);
myMC = starMC;
addChild(myMC);
trace(myMC.name)
function replaceballwithtext(event:MouseEvent):void {
trace(myMC.name)
removeChild(myMC);
myMC = youpresseeditMC;
addChild(myMC);
trace(myMC.name)
///end code
This works. I see the ball object replaced by the star and I am able to do this by manipulating just myMC. Is there anything I should be concerned with in this approach?
Thanks for your help -
Help with AS3, loading multiple files into a movieclip in specific order in scrollbar
Hello! I am in need of some advice. We are trying to build a site with these features:
Our site will be built in Actionscript 3.
1. A navigation menu that, when a button is clicked, will scroll the site quickly to a specific Y position using swfaddress.
2. The entire site is controlled by a flash scroll bar, which will be scrolling a single movieclip.
2A. The movieclip will load content corresponding to the navigation categories, all which is organized into zipped files (using this to extract the contents of each section, example: about.zip for the about section of the site)
2B. The movieclip will load multiple zipped files one by one that correspond to the navigation, in order, making the site appear to be very tall.
**What we are in need of is understanding how to load multiple zipped files into a movie clip, in a specific order, and having them scroll between one another through the navigation. The separate navigation categories can be in movieclips instead of zipped files if that is easier.
Here is a reference of something that works like this: http://swfc-shanghai.com/#/about/Hello kglad! I have set aside the idea of using zipped files, and am now just using multiple external swfs that I'd like to load into the movieclip in a specific order. Any thoughts?
I'm new to AS3, and I'm attempting to create a scrolling movieclip that will load multiple external files, in order, into that movieclip. I'm using XML as well. At this point, nothing is loading into my movieclip (contentMain) and it's a bit frustrating! Thank you for your help!
Current error: 1180: Call to a possibly undefined method load.
AS3:
//XML Loader
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.load ("master.xml");
myXML.onLoad =function(sucess) {
if (sucess) {
contentMain.loadAll();{
load("1_Overview.swf")
load("2_Webcam.swf")
load("3_Twounion.swf")
load("4_Oneunion.swf")
load("5_Retail.swf")
load("6_Nearby.swf")
load("7_Courtyard.swf")
load("8_Map.swf")
load("9_Conference.swf")
load("10_News.swf")
load("11_Sustainability.swf")
load("12_Contact.swf")
addEventListener("complete",onLoad)
onLoad();{
//load all
}else {
trace("ERROR LOADING XML"); -
Problem with non loading movie clips in CS3
Hi.
I am making an animation ( Trailer for an upcoming handheld
game i am working on ).
And i have encountered a problem when i play back the
animation with Flash player.
There is two movie clips in the animation ( Normal vector
drawing but with effects applied on it ( color adjustment , and
blur ) ) and when i play the published swf back with flash player
the two movie clips are in their normal Vector mode ( without the
filters ) until the middle of the animation when they finally
"load" , the filters finally have an effect on the two vector
drawings.
i use a very high end computer so that couldn't be it.
And when i am going to upload the flash film there's going to
be a loading screen ... i have no clue if it's going to fix this.
But for now this is really odd and looks really awkward.
If this problem persist i will not make the deadline. please
help fast.
Thanks everybody.
-Jimmy Gonzo
EDIT: oh and i also noticed that when the stuff isn't loaded
yet... the animation goes too fast.It seems to me that you need to put a preloader in the first
frame of your whole .fla. It seems that all your assets are not
being loaded before the .swf playhead moves forward.
A simple preloader could be something like:
frame 1 label this as "preloader"
frame 2 (insert the following commands)
if (this._framesloaded >= this._totalframes) {
this.gotoAndPlay("init");
}else{
this.gotoAndPlay("preloader");
} -
Removing movie clips in arrays
Hi there
I have this code in my Flash file:
for(bubble in bubbleArray){
bubbleArray[bubble]._y -= 3;
if(bubbleArray[bubble]._y < 370){
bubbleArray[bubble].removeMovieClip();
I'm wondering, when I remove the movie clips should I also be popping them from the array?
I have an onEnterFrame function that attaches the movie clips and pushes them into the array, so I'm worried that if I don't pop them the array will continue to increase in size and slow down the movie. Is this the case, or will they be automatically removed from the array by the removeMovieClip() method above?Looks like I spoke too soon. I imagined that removing them from the array would be easy, but I'm struggling.
The movie clip that is removed from its parent clip and should be removed from the array will not always be the first element in the array, and I'll need to remove multiple clips at a time. I've put in a trace action to trace the length of my array, and after about ten seconds it contains about 2500 elements, most of which have already been removed using the removeMovieClip() method. I'm worried this will slow down the movie.
So to clarify: How can I remove these elements from my array when I remove them from the stage?
I tried to include something like:
while(bubbleArray[0] == undefined){
bubbleArray.shift();
but it caused Flash Player to freeze up. Also, if I trace bubbleArray[0] it is only "undefined" before something is pushed into the array. Once the clip has been removed from the stage, the trace just returns a blank line, not "undefined".
I'd appreciate any help.
Here is all my code:
stop();
splash.stop();
var i:Number;
var j:Number = 0;
var minBubbles:Number = 10;
var maxBubbles:Number = 20;
var bottomBubbleLimit:Number = 0;
var topBubbleLimit:Number = 1;
var bubbleNumber:Number;
var bubbleX:Number;
var bubbleY:Number;
var bubbleScale:Number;
var bubbleMinScale:Number = 30;
var bubbleMaxScale:Number = 100;
var fewerBubbles:Number;
var ring:String;
var ringArray:Array = [ringAnimation.ring1, ringAnimation.ring2];
var bubbleArray:Array = [];
ringAnimation.onEnterFrame = function(){
for(ring in ringArray){
if(ringArray[ring]._y > 370){
bubbleNumber = (minBubbles + (Math.random() * (maxBubbles - minBubbles)));
for(i = 0; i < bubbleNumber; i++){
bubbleX = ((ringArray[ring]._x - (ringArray[ring]._width / 2)) + (Math.random() * ringArray[ring]._width));
bubbleY = ((ringArray[ring]._y - (ringArray[ring]._height / 2)) + (Math.random() * ringArray[ring]._height));
bubbleScale = bubbleMinScale + (Math.random() * (bubbleMaxScale - bubbleMinScale));
ringAnimation.attachMovie("bubble", "bubble" + String(j), this.getNextHighestDepth(), {_x:bubbleX, _y:bubbleY, _xscale:bubbleScale, _yscale:bubbleScale});
bubbleArray.push(ringAnimation["bubble" + String(j)]);
j++;
for(bubble in bubbleArray){
bubbleArray[bubble]._y -= 3;
if(bubbleArray[bubble]._y < 370){
bubbleArray[bubble].removeMovieClip();
trace(bubbleArray.length);
if(ringAnimation._currentFrame == 6){
splash.gotoAndPlay(1);
}else if(ringAnimation._currentFrame == 12){
splash.gotoAndPlay(1);
fewerBubbles = setInterval(reduceBubbles, 600);
function reduceBubbles(){
if(minBubbles > bottomBubbleLimit){
minBubbles--;
if(maxBubbles > topBubbleLimit){
maxBubbles--;
if(minBubbles == bottomBubbleLimit && maxBubbles == topBubbleLimit){
clearInterval(fewerBubbles); -
Removing movie clip in a frame
Hello,
I have a timeline with 12 frames, in frame 7 I added a movie clip to the stage:
var pContainer:MovieClip = new MovieClip;
addChild(pContainer);
var myLoader1:Loader = new Loader();
pContainer.addChild(myLoader1);
var myRequest1:URLRequest = new URLRequest("flash/products.swf");
myLoader1.load(myRequest1);
pContainer.x = stage.stageWidth/2 - 380;
pContainer.y = stage.stageHeight/2 - 180;
now, when I hit a button and I go back to frame 2 or any other frame in my movie, this movie clip is on top of everything,
I tried in frame 2:
removeChild(pContainer);
but it doesn't remove the movie clip any ideas?Managing things you create dynamically can be tricky business... I don't yet know why.
One way of doing this is to manually plant pContainer as an empty movieclip symbol in frame 7 rather than creating it dynamically.
Another thing to try would be to use the removeChild command before you move away from frame 7. So you might need to have a conditional in your button that tests the currentFrame value and then executes the removeChild command before moving to the destination frame. -
A really annoying problem with a button/movie clip
I am having a problem with a button! its driving me insane
because i managed to do it last week, but that was by chance and
now i can't remember how i did it!
I can get the button (i'm using gelright from the common
libraries panel) and convert it to a movie clip(by pressing F8) and
even attach a behaviour but when i play the movie it doen't work!
when i move the curser over the button it changes into a hand, but
will not act like a button, even though i have set the behaviour to
'on release, go to and play keyframe 2'.
Please help me, for the sake of my laptop goin through the
wall!virgosam20 wrote:
> first, i found the button i wanted in the common
libraries (gelright) and
> added it to the stage. I resized it and converted it
into a symbol as a movie
> clip. Then it got added to my library.
> Then i deleted it from the stage and replaced it with
the movie cip version i
> had just converted it to. so now i have the same object
on the stage, but now
> its a movie clip and not a button.
ok - you are running yourself around in circles - why did you
delete it to the stage only to add it
again? once you converted it to a movie clip, you had what
you wanted on the stage - but then you
deleted it and dragged another instance of the same symbol
back onto the stage - there's no reason
to do that.
> Then i double clicked on it to bring up the movie clip
timeline, but instead
> of saying 'top, down, over, hit' (or whatever it says),
it jsut said 'layer 1'
> (but this was not my original stage as i have a number
of layers on that one).
Right - this is expected because yoyu are now inside the
movie clip timeline - not the button timeline.
> When i double clicked on it again, it brought up the
right headings (top, down,
> over, etc),
Right - because by double clicking the button symbol you were
then brought to "edit mode" for the
button symbol.
but there were about 5 layers that showed the different
layers for
> the original button.
Huh? What "5 layers"? What do you mean "original" button -
per your description there has only ever
been 1 button you have been working with.
> I think i have to add the button to each of the
headings, bt there is no room,
Lost you completely now - what do you mean add the button to
each heading? I have no clue what you mean.
> as when i did it before, there was only one layer for it
and i had to insert
> the key frames myself.
Still losing you here.
> I then added a behaviour to it using the Behaviours
pannel, (selected
> movieclip, then 'go to and play....') and it appears in
the behaviours pannel.
> But when i got to Play Movie, although the curser
changes into a hand, the
> button does not work.
That's because you are applying a behavior for a button to a
movie clip instead.
I think you went wrong when you converted the button to a
movie clip - i have no idea why you did
that or why to think your button needs to be in a movie clip.
>
> Hope that can help you with what i've done and you can
tell me where i've gone
> wrong.
>
I just think you don't understand how timelines, symbols or
buttons work yet in flash.
1. drag a button to the stage.
2. select it and open the Behaviors panel (dont double click
it to edit it).
3. add your actions.
4. test movie.
(no need for a movie clip here.
-chris -
*Class Project - Please help: Why does my movie clip keep playing over and over?
I am desperate for help on this one as its my Final Flash
class project and I just can't get my scenes/movie clips to play in
the order I want them to.
I have Scene 1 (movie clip 1) that plays and then Scene 2
(movie clip 2) plays. The problem is that Scene 2 (or movie clip 2)
repeats itself over and over again. I can't get it to go back to
Scene 1 (movie clip 1) to play that again.
I want it go to to this Scene 1 and actually start at a
certain frame to continue on with the story.
I have named my movie clip instances.
What am I doing wrong? I went into movie clip 2, into
actions, and movie clip control, and I don't really see a way to
tell it to go back and play movie clip 1. Trying to see how to
refer back to the instance name of the movie clip and get it to
play.
Ideas? Please please? I would be forever greatful.
Angiequote:
Originally posted by:
computerkitten
I wonder if I should just take that movie clip out of the
scene completely.... and not have the second scene at all. Maybe I
should just have 1 scene and these 2 movie clips. Wonder if that
would work better?
As Nickels55 said, above, scenes add unnecessary complexity.
So the answer to this is: YES. Scenes are awkward in Flash. Never
use them in any final project. Put everything on a single timeline
in a single scene, and you will have much better control of the
project. -
Need some help with a remove function
Design and code a program that will maintain a list of product names. Use a String type to represent the product name and an array of strings to implement the list. Your program must implement the following methods:
Add a product to the list
Remove a product from the list
Display then entire list
Find out if a particular product is on the list.
You need to create a command command loop with a menu() function. The program must continue asking for input until the user stops.
This is the assignment and this is what I have so far. I need some help writing the remove function.
Thanks
* Title: SimpleSearchableList.java
* Description: this example will show a reasonably efficient and
* simple algorithm for rearranging the value in an array
* in ascending order.
public class SimpleSearchableList {
private static String[] List = new String[25]; //These variables (field variables)
private static int Size; //are common to the entire class, but unavailable
//except to the methods of the class...
public static void main(String[] args)
String Cmd;
for(;;) {
Menu();
System.out.print("Command: ");
Cmd = SimpleIO.inputString();
if(Cmd.equals("Quit"))
break;
else if(Cmd.equals("Fill"))
FillList();
else if(Cmd.equals("Search"))
SearchList();
else if(Cmd.equals("Show"))
ShowList();
else if(Cmd.equals("Remove"))
Remove();
//Tells you what you can do...
public static void Menu()
System.out.println("Choices..................................");
System.out.println("\tFill to Enter Product");
System.out.println("\tShow to Show Products");
System.out.println("\tSearch to Search for Product");
System.out.println("\tRemove a Product");
System.out.println("\tQuit");
System.out.println(".........................................");
//This method will allow the user to fill an array with values...
public static void FillList()
int Count;
System.out.println("Type Stop to Stop");
for(Count = 0 ; Count < List.length ; Count++)
System.out.print("Enter Product: ");
List[Count] = SimpleIO.inputString();
if(List[Count].equals("Stop"))
break;
Size = Count;
//This method will rearrange the values in the array so that
// go from smallest to largest (ascending) order...
public static void SearchList()
String KeyValue;
boolean NotFoundFlag;
int Z;
System.out.println("Enter Product Names Below, Stop To Quit");
while(true)
System.out.print("Enter: ");
KeyValue = SimpleIO.inputString();
if(KeyValue.equals("Stop")) //Note the use of a method for testing
break; // for equality...
NotFoundFlag = true; //We'll assume the negative
for(Z = 0 ; Z < Size ; Z++)
if(List[Z].equals(KeyValue)) {
NotFoundFlag = false; //If we fine the name, we'll reset the flag
System.out.println(List[Z] + " was found");
if(NotFoundFlag)
System.out.println(KeyValue + " was not found");
//This method will display the contents of the array...
public static void ShowList()
int Z;
for(Z = 0 ; Z < Size ; Z++)
System.out.println("Product " + (Z+1) + " = " + List[Z]);
public static void Remove()
}I need help removing a product from the arrayYes. So what's your problem?
"Doctor, I need help."
"What's wrong?"
"I need help!"
Great.
By the way, you can't remove anything from an array. You'll have to copy the remaining stuff into a new one, or maybe maintain a list of "empty" slots. Or null the slots and handle that. The first way will be the easiest though. -
Need help with as3 for popup window
I am nearing the end of the semester in my Flash Animation class. I have learned very simple AS3 things, code snippets etc. I am trying to find the actionscript for coding a very simple popup window, but have not found a clue.
Here's what I want to do...I have a white box with some type on the stage. When a person clicks on the white box, I want a popup to open that is larger, that will contain the same type but larger. That box will have an x so it can be dismissed. I don't want to do this in html, only in Flash CS5. I don't want a browser window, I just want a bigger version of the smaller box. I know how to build both boxes, just don't know how to write the code. I know there will be an on-click mouse event listener, and then I am lost.
Can anyone help with the code I might use? It would be most appreciated.It would be something along the lines of... (using instance names relative to your description)...
popup.visible = false;
whiteBox.addEventListener(MouseEvent.CLICK, showPopup);
function showPopup(evt:MouseEvent):void {
popup.visible = true;
popup.popupX.addEventListener(MouseEvent.CLICK, hidePopup);
function hidePopup(evt:MouseEvent):void {
popup.visible = false;
Maybe you are looking for
-
Installation fail Photoshop CS6
I have been trying to install Photoshop CS6 on my MacBookPro3,1, for weeks now- Installed entire CS6 Suite -Design Web Premium- everything installed except Photoshop. just uninstalled previous Creative Suites (CS4) have updated to LION--- still insta
-
Lightroom 5.4 and 5.5 crash when trying to go to Preferences
Lightroom 5.4 crashes when attempting to go to the Preferences. Today I updated to 5.5 but have the same problem. As soon as I click on Edit > Preferences the program stops working. Windows 7/ 64; 32GB RAM Any solution? Thanks Ronald
-
Duplicate Devices In LMS 3.2
Hi There. I have trolled this forum, and I find issues with LMS 3.1 and Duplicate devices and the engineers say that it is fixed in LMS 3.2, but I have a customer who is experiencing this with LMS 3.2 below is the customers request: This has now been
-
X axis labels. How to reduce information.
Im having trouble finding how to reduce the number of x axis labels, (time), My graph is of temperature every 4 minutes over about 10 hours. I would like to have the x axis in hours, but Numbers seems to insist on labeling all 250 points. Is there a
-
[SOLVED] vi/vim/gvim rebuild from ABS failed
Hi, tried to rebuild vi from source (to get rid of ruby dependence of vim,gvim by modifing PKGBUILD) and got this message. having patch file:7.2.166 having patch file:7.2.001-100.gz Number of patches does not match the patchlevel! Edit the PKGBUILD a