ActionScript 2.0 :: Loading Random MovieClip From Library On Stage
Oct 20, 2004
I want to load a random movie clip from the library to an empty clip on the stage called (bg_graphics). the clips in the library are called (green, blue, yellow).
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 am looking for a way to remove a movieclip from the stage when it is dropped (after a pause) and then have a new random movieclip appear at a specific point on the stage, which can then be dragged and dropped onto its own target (which repeats the process).
Code: var movieArray:Array = new Array(); movieArray = ["Red", "Green" , "Blue"];[code].....
I have 3 mc's in my library each with linkage "icon1", icon2", icon3". What I'm trying to do is load one of them randomly in to the stage. Here's the code I have so far:
Code: //creating an array that holds the mcs var iconsarray:Array = new Array("mc1","mc2","mc3"); //creating a random number to use for loading the mc var randmc:Number = Math.round (Math.random ()*2)+0; //this is just a string to hold the mc with the number, not used var all:String = (iconsarray[randmc]); [Code] .....
How to add random movie clip onMouse Move to stage from many (lets say 50) different movie clips in library? If I wanted to add one movie clip to stage I would do liko so:
ActionScript Code: stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); function onMove(e:MouseEvent):void { var mc:MovieClip = new Ball();
(****another title for this could be "how to create a MovieClip variable") basically, im trying to load random movie clips from the library when i run the function "TRO1".. the logic behind what im trying to do is to to first create an array containing the class names (name given in the "linkage" option) of the movie clips in the library... then randomly select an item from that array... then bring it to the stage.. Here is the code I typed:
var characterArray:Array = ["truck", "car", "boat", "train", "helicopter"] function TRO1(event:Event):void {
[Code].....
When i try to run the function, i get the error message "Instantiation attempted on a non-constructor..."
I think the problem is that flash doesn't understand what "randomCharacter" is in the line "var character:MovieClip = new randomCharacter();"... I assume there is a proper way of writing the "randomCharacter" variable so that i can use it in the succeeding line...
Basically, I have movie1, movie2, movie3, movie4 in the library, with linkages.
These are just 5 frame clips, with a single dummy_mc moving statically over the 4 frames.
I need these to be picked randomly and placed (each has its own set of co-ordinates where it should appear) on the stage at a random set interval (ie, every 2-3 seconds).
There are also 7 items (item1, item2, etc) in the library.
So once one of the 4 movies has been placed on the stage, I need one of these 7 items to randomly attach itself to the dummy_mc within that movie (and, I guess, generate instance names etc)
I used to know how to do this (maybe): I want to load a Symbol from the Library on the fly into an Object on the stage. I think I have to give the Symbol a Class under Properties/Linkage, but after that I'm lost. I know this is a hack-y way to do it, but I want to do this without external Classes and files, all in the one swf.
I'm creating a mask effect. i create 10 movieclip with a library class reference that appear on the screen with a random alpha effect. THe problem is that if i try the effect alone all works ok. if i mask the layer that contains the effect on an image i don't see the effect. i see directly the image masked with the boxes. i can't explain that because i've the effect first but it seems that when i test the movie the effect doesn't play and the boxes appear directly on the screen.
getting a MovieClip item onto the stage within say the Document Class.
The trick is though, I would like to do it when the MovieClip linkage refers to a Class name, but does not actually have a Class document created.
I know that you could give it a class complete with document and that would be easy. But if you have say 10 enemy objects that literally do the same thing but just look different, why should I create 10 separate classes!
or am I barking up the wrong tree and I should just set up 10 different enemy styles within the 1 MovieClip and just attach the 1 Class to it?
Though I would still like to know how to get a MovieClip onto the stage dynamically from the Library when it doesn't have a Class file associated with the Class name in it's linkage
All I am trying to do is add a movieclip from the library to the stage from the class below. The trace works but the dang thing does not show up. I am trying to get into using classes finally.
I'm developing a flash lite app in as 2.0. loading a movieclip on to the stage from the library. The name of the mc is Objects and I have exported it for actionscript in the linkage. I learnt as 3.0 initially. That is why finding difficult in going to as 2.0
This is how i did it in as 3.0
Code: var obj:MovieClip=new Objects(); addChild(obj);
basically i have my blank document (no movieclips on the stage). I ahve my library item which is a movieclip and i want to attach this directly to the stage NOT into another movieclip.
so i have a document class with added_to_stage handler, and when i get access to stage is there a difference between: having few movieclips on the stage ready for use, or pulling these same movieclips from the library? is there a reason why i should be pulling them from the library (and i dont mean multiple instances, just single item of each) when i can "leave" them on stage and get them directly?
I want to load a random movie clip from the library to an empty clip on the stage called (bg_graphics). the clips in the library are called (green, blue, yellow).
I need to load a movie clip to the stage from the library. I also need that movie clip to load with a certain string of actionscript code in it. To load the movie clip, i checked the "export for actionscript" thing in the "linkage" section of the movie clip info, and i named the class "sol1" I then used this code on the first (and only) frame: Code: _root.attachMovie("sol1", "NewInstanceName", {_x: 50, _y: 100}); It seems to work, but the question is, how do i load the movie clip with code in it?
I am basing my site layout all one this one actionscript thingy...when you press a button, a window pops up. The window is from the library. It's called "ContactWindow" and its linkage is "contact".
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);
I am trying to learn ActionScript 3. I have a MovieClip called Ship in the library and have made class of it called ship. The Ship movieClip glows from Frame 6 to indicate when it crashes into an asteroid.The myShipMovieClip child is controlled by arrow keys and asteroid approaches. The hitTest works but I cant get the ship to glow i.e. from the timeline go to the Ship MovieCli in the library and go to frame 6 to start it to glow. I have managed to do this in ActionScript 2 but have tried for the last few days to try and do it in AS3here is my code :
Is it even possible to associate a class file to a movieClip manually placed on the stage without setting up the class linkage in the library? If so, how?
P.S. linking in the library then placing on the stage is not a viable option. Nor is using "addChild" from the library.
I've started trying to get into AS2 and all of a sudden, I don't know how to attach a movieclip from a document's library to the stage! The debugger's saying that attachMovie isn't a method. Just to clarify, I have an external as file which is defining a class and in that class, I want to attach a movie from the library to the stage.
I wanted to attach movieclip(btn_select) from my library to the stage (movieclip:container) by XML so here's my code.. here's my loading of xml... Note: portXML.childNodes[0].childNodes.length; is 3
I have a MovieClip in the library with a class associated with it. I can instanciate the MovieClip just fine using code and add it to the stage without any problems. But how can I manually add the MovieClip to the stage and feed it the one parameter when it's instanciated? I've tried all the usual stuff but nothing seems to work:
var testClip:className = new className("helloworld");
testClip is the name of the MovieClip that's been manually placed on the stage.
I am new to AS 3.0 and getting stuck with few things.I want to add movieClip named "button" to stage from library.Linkage to custom class name "customButton".Now,
When you attach a movieclip taken from the symbol library to the Stage, by using the attachMovie function and its Linkage name, do you have to - previously - place a dummy instance of the mc anywhere on that Stage to get it works ?