Code:
stage.addEventListener(MouseEvent.CLICK, addBullet);
function addBullet(event:MouseEvent):void {
var bullet:MovieClip = new bshot();[code]....
bshot is a movieclip in my library with the class name of bshot as well.i do not understand when i click i do not get a bullet being added to the stage?
normally when i want to add a movieclip to the stage I would do this:[code]but I have an array of linkage ID's that I select from randomly at runtime so how do I code it to place it on stage?[code]
//This small class add the same movieclip to the stage with random scale and position // Garden represents a movieClip in the library //attached fla and document class
Why using the same name garden for all instances of Garden is not a problem? Can I track each individual instance of Garden on the screen or recall it for something else?
I'm having some issues trying to add a movieclip to the stage through actionscript. Moving from AS2 to AS3 and it's a little daunting to get this concept.
So I want a dialog box (this is the movieclip) to pop up when I click a button and then go away when I click another button. This is what I came up with...
ActionScript Code: eyebtn.addEventListener(MouseEvent.CLICK,popUp); function popUp(event:MouseEvent):void
I am attempting to push an object into an array based on its instance name on the stage...how do I do this?
On my stage I've simply made a box, turned it into a movie clip named "mcBox" and have given it an instance name of "box_mc" on the stage. Here is my current test code:
Code: var energy:Number = 0.75; var boxArray:Array = new Array; box_mc.addEventListener(MouseEvent.CLICK, onClick);
[Code]....
Since the default amount of energy satisfies the if statement I push the movieClip into the array and then trace it. In my output I receive "[object MovieClip]"...is there anyway to distinguish it by its instance name?
I have created a movie clip on the stage and in symbol properties I have checked "Export for ActionScrip" the MC name is "slide" and the class is "slide" base class is flash.display.MovieClip.
When I test the movie I get this error. TypeError: Error #1009: Cannot access a property or method of a null object reference. at main_fla::MainTimeline/frame1()
Here is my code: PHP Code: var slide = getChildByName("slide"); //add instance from library? function slideRollOver(event:MouseEvent):void { // trace("OK"); } slide.addEventListener(MouseEvent.ROLL_OVER, slideRollOver);
Does flash have an equivalent to Flex'sApplication.application.[insert application method or propertyI want to get access from an as3 class file to the mainstage. a call to this.root from the stage to the class will notwork because I need the root object stage to execute an addChild
I'm adding several similar movieclips to the stage with a 'for' loop. However, I'd like to increment the position of each movieclip when added on to the stage. I know exactly where I want each movie clip positioned as well. At the moment I just have a small 'for' loop which setups the movieclip. Like so...
I am new to AS3 and only recently have been able to understand the display list.I am trying to run this code in my file.I made two movie clips in my library. Gave them class name as "One" and "Two"Now, this is the code that I run:
Code: var one:One = new One(); var two:Two = new Two();
How to add random movie clip to stage from many different movie clips in library? If I wanted to add one movie clip to stage I would do liko so:
Code: stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); function onMove(e:MouseEvent):void { var mc:MovieClip = new Ball(); mc.x = mouseX; mc.y = mouseY; addChild(mc); }
Code above works perfect but I tried following but with no success, no errors, but nothing happens - no mc's are added to stage. I have 6 movie clips in library and they all are linked, exported for actionscript. On MouseOver I want to add random movie clip from those six movie clips to the stage.
Code: var myArray:Array = [mc1, mc2, mc3, mc4, mc5, mc6]; stage.addEventListener(MouseEvent.MOUSE_OVER, onLoop); function onLoop(e:MouseEvent):void { for (var i:int = 0; i< myArray.length; i++) { var randomMc:Number = Math.floor(Math.random()*i); var mc:MovieClip = new myArray[randomMc]; addChild(mc); mc.x = mouseX; mc.y = mouseY; }}
I'm adding several similar movieclips to the stage with a 'for' loop. However, I'd like to increment the position of each movieclip when added on to the stage. I know exactly where I want each movie clip positioned as well. At the moment I just have a small 'for' loop which setups the movieclip. Like so...
ActionScript Code: for (var i:uint = 0; i<=8; i++) { zone[i] = new Zone(); }
I then have a long list adding and setting each mc position on the stage...
Although I've just had a thought as I was typing that last bit of code. Will I need to setup a for loop for each row...so the y position remains constant and I just increment the x value for each movie clip, and then repeat this for loop for the next row with the new y coordinate?
I have a movieClip button in my library that I dynamically add multiple instances of to the stage using code (so each instance has a unique name). The button has two frames, so it has a basic rollover effect (just changes color. To make the rollover work, I've had to dynamically add an event listener to each new instance of the movieclip, which triggers the rollover function.
I was wondering, instead of adding an event listener each time, can I somehow have an event listener within the movieclip to take care of the rollover? Or will it not make any difference to the number of event listeners, as it will still add a listener with each new instance of the clip?
I have a scrollpane in my library.Inside a movieclip, I create an image gallery and add it to the scrollpane.I do this in this function.[code]Now everything works fine, and no problems occur.I do however get the runtime error TypeError: Error #1009: Cannot access a property or method of a null object reference. at fl.containers::ScrollPane/endDrag()It doesnt seem to affect my file, but I am sure it would be better to try and get rid of it.I think it has something to do with adding my movieclip to the main movieclip, and maybe.I am not removing it when I add a different movieclip.Whenever I add a movieclip to the main one, I use container_mc.addChild(...);Does addChild check to see if a movieclip already exist, and remove it if it does? Or do I need to remove my clips beforehand?
I have a MovieClip called chipmovie which I have exported to a class method called ChipMovie, when I try and add it to another movieclip, for some reason it doesn't display. I have checked Export for ActionScript and Export in Frame 1.The code that adds it to the MovieClip is as follows:
public function addChip(chip:Number) { var newChip:ChipMovie = new ChipMovie();[code].....
I'm making a simple RPG platformer where a character will pass over an object. When the action key is pressed and the character is over top the object, I would like a block of text to appear on the stage with a close button to cancel out.
I would like to know how a person would go about making a "pop-up" text box.
How can I link to a movie in my libary to tell it to behave like a button. This is what I have tried but it's not working.
Code: var selectedButtons:Array = loadButtons(); var itemX:Number = 100; // initial item x position var itemY:Number = 100; // initial item y position
[Code]....
As you can see I am adding the Movies to my stage throught thier class name(apples etc). How come I can't link to it? Is it because I need to be using an instance name? And if so I would I assign one?
How do you make a movieclip move horizontally from the start of the stage to 3/4 of the stage. Stage size is 700 px by 600 px i want just one row in the middle of the stage. i want that movieclip to disappear right after it reach the end of the 3/4 mark.
I am having is trying to add objects to stage. At the moment I can not put anything onto the stage unless it is in my Main document class (Main). How would I add to stage in my player class and bullet class?
Code: package game{ import flash.display.*; public class Main extends MovieClip{
I am pretty new to actionscript 3. I want to remove the movieclip on the stage and add a new movieclip but the button is within the currently running movieclip that I want removed. I am trying this function
homeArtist_btn.addEventListener(MouseEvent.CLICK, newArtist); function newArtist(e:MouseEvent):void{ removeChild(homeAni_mc); addChild(artistAni_mc);} I get these errors
I have this library with more than 80 objects that i want to bind to my keyboard. My idea is use the "keyCode" to call the object to the stage, constructing the object's name inside a variable.This is the code that I'm trying to use, but the bold text line always give me an error (constructor, syntax and others) depending how i write that line.[code]I'm not very experienced with AS3 so i don't know if this is the right approach to solve my problem. Any help is well received.
I am trying to build a simple preloader. I have 4 movieclips on stage and on each one I am adding an image that comes from an xml file: theMap = new XML(); theMap.ignoreWhite = true; theMap.onLoad = function(success){ if (success) { theNodes = theMap.firstChild.childNodes; [Code] ..... Everything works ok but as the jpgs are a bit heavy I'd like to preload them. Is that possible?
just wondering why this code returns: 1137: Incorrect number of arguments. Expected no more than 0.when relating to this:var cm:collectionsMenu = new collectionsMenu('cm');