ActionScript 3.0 :: How To Make Reusable Rocket Classes
Jul 11, 2010
The sequence basically involves rockets being fired when an appropriate timer event is triggered. Each instance of a rocket has a code which looks for a mouse click event, and then tells it's parent (I've called it "gameplayzone") to remove it from the scene.I've got a problem where:I'd also like to be able to update a score variable held in the gameplay zone (add 50 to it's current value for example)I also want it to modify a "lastcolour" variable in the parent, which is a string. The lastcolour variable is used to see if the play is clicking rockets of the same colour, which is used to calculate a combo points bonus.
The biggest issue however is that I'd like the gameplay container to simply be able to add a new instance of a rocket when I want to, but also define that specific instances values (x position, y position - but also xVel, yVel and yAcc which are properties inside the rocket class)This is a blunt question, but... What's the best way to do this?
View 5 Replies
Similar Posts:
Apr 14, 2009
I am having a real problem with understanding something in flash - it doesn't work in the way I expect so I figure I have really misunderstood something.What I want:I am creating a bunch of .swf files and in each one I want multiple instances of an object that when you put the mouse over it the object will play its animation a bit and pop up a tool tip. Each object can look different (i.e. be a different bitmap) and animate differently (shake, pop, rotate etc).What I did:I have tried to create a class (myMouseItem) that creates the necessary listeners to handle the animation and pop up the tool tip.
I create a library item and attach it to the myMouseItem class. I can then put one instance of this inside my .fla and it works. (I still seem to have to put a .stop() in the actionscript for the scene to get it to stop animating for ever but I can probably live with that)What I can't figure out:How do I repeat this with multiple objects all with different bitmaps but reusing the underlying class? When I try to add another instance of my library class and edit the bmp it changes all instances. When I try to create another library item with the same underlying base class I get an error saying that I have to choose a unique identifier, so I don't seem to be able to reuse my .as file.
View 2 Replies
May 28, 2008
how to breakdown a given functionality into resuable classes.The style of scripting is very messy and lots of repetitive codes, as most of the time I just jump straight into scripting without prior planning (bad habit).Now with this component as a base, I want to learn how to manage my codes in a cleaner, more efficient way, OOP style. (I only get to know about how good and time-efficient OOP style programming is after I 'discovered' the Tween class a month ago lolx)For a start I will need some planning.. that's the place where I'm now stuck in..I've come out with the core items which I think should be as classes
1) Controller
2) Drag clips
3) Hit boxes
How much further should I break them down? Read from tutorials that generally classes should only perform one task is that true? The controller deals with 2 tasks (handling events and 'calculation part'), should I break them into 2 separate classes?From tutorials I also get to know that we can assign a class to a symbol in the library. Is it possible for to attach classes at runtime to script generated or existing timeline instances? something like instanceName = new classFunction(parameters) ?
View 6 Replies
Aug 16, 2010
I am trying to animate a rocket flying. I know there is a way you can use the line tool/ pen tool to draw the path in which you want the rocket to go?
View 3 Replies
Nov 12, 2009
I�m working on an asteroid game and don�t get it to create a nice trail for my spaceship(s).It doesn�t need to look spectacular, just "nice".I tried a comic look alike version with angled mc�s, whose scale are tweened down and up. But it�s not the right look.And I tried some flame effects by as3, but it not seems to be a smart solution. Nice look, but needs a lot of memory space.
View 2 Replies
May 12, 2011
I'm trying to create a homing missile in AS3. Easy enough when you want it to simply follow a point perfectly - but I'm trying to make the rocket have to turn around if the destination (target) bypasses it. Here's what I've got - it almost works, but as you can see it's quite glitchy (particularly if the mouse is to the left of the rocket (seems to work OK if it's moving right). [URL]
Here's my Rocket class:
package {
import flash.display.Sprite;
import flash.geom.Point;
import flash.events.Event;
public class Rocket extends Sprite {
[Code] .....
View 2 Replies
May 24, 2009
I am looking for reusable open source components. The level of depth, breadth and hopefully quality that I'm looking for is similar to this. Although I need them in programming languages C#, Java and Flex (which I often use in my projects), other languages such as PHP, Perl, Python, Ruby etc. are welcome. I see this as a big help for other programmers who have similar needs such as mine.
I plan to eliminate code duplication when building a large scale (in terms of code size) project by using this components and focus more on the business logic of it. Is there an open source (Java) or Codeplex (Microsoft) component implementation that does this that I'm not aware of?The main point that I want to address for this question is to avoid interdeveloper duplication. Interesting case found in Pragmatic Programmer: An audit for government computer systems have been made showed 10,000 different programs having their own version for Social Security number validation.
View 3 Replies
Apr 30, 2005
I have followed the tutorial "Reusable Preloader Using MovieClipLoader" HTML Code: [URL] and found it extremely helpful, there is just one thing i would like to add to the code which i think should be easy, but i cannot work it out...
I would like to add a fade out as well as a fade in...
View 3 Replies
Mar 29, 2006
I want to write a function for loading html text from a file, but I'm having trouble figuring out how to use LoadVars correctly in that manner. I'm not loading speific variables, but a chunk of html.'d like to be able to do something like this:
myText = loadHtml("blah.html");
myTextField.htmltext = myText;
This is my current code, but I don't know how to pass the data back out of the function.
loadHtml = new LoadVars();
loadHtml.onLoad = function() {
trace(this) // traces the text file.
[code]....
View 8 Replies
Apr 30, 2005
I have followed the tutorial "Reusable Preloader Using MovieClipLoader" [URL] and found it extremely helpful, there is just one thing i would like to add to the code which i think should be easy, but i cannot work it out...
View 3 Replies
Jun 16, 2009
A good button should have all the available out, over and down states, and often there are a bunch of nice to haves such as animation, disabled states, filters, you name it. I seem to change my mind in each project I do. The last one, I reskinned and extended the Button Component. The project before I extended SimpleButton Before that I built my own custom class using a Sprite and TweenLite. Then of course you need to work out if you will use library items which is great for laying out on stage, or do everything from scratch using code, which is more powerful but crap for design. I haven't looked at the swc or component route myself.
View 1 Replies
Feb 2, 2010
I'm trying to create a reusable button like it was possible in ActionScript 2 using the Var of a dynamic text box, hence allowing me to chose the name of the button and its link inside the HTML and pass these variables on to the swf file. This therefore means less traffic, and faster load times.
the html code would look like this:
PHP Code:
<param name="FlashVars" value="myText=HOME&myLink=http:\www.MyWebsiteHome.com"/>
How would i go about doing this with CS3?
View 5 Replies
Aug 16, 2010
I'm trying to make the code below reusable. I need multiple toggle buttons in my flash project. Right now the code below works on one button. If I continue and create more buttons, and follow the format below, I would need to create separate functions for each button.
I would like to put the reusable code in a separate ActionScript file and not in the FLA file. I am trying to put the rolloverToggle, rolloverToggle, and toggleClick in a class that I'm making.[code]...
View 1 Replies
Feb 26, 2011
I need to create slideshow for gallery. And one thing that i don't know is how to create reusable components. For example i want to create 3 components ImageLoader, Dock(that consist drom ImageLoaders) and SlideShow(that consists from Dock and ImageLoaders).
ImageLoader it is a container which loads image and while it loading showing some animation
Dock it is a container wich have few of ImageLoaders, it used to create Dock of thumbs images to chose.SlideShow it is a container wich have few of ImageLoaders, it used to preload images to ImageLoaders and the change them on mouse click.I need that all of this components was accessible fom action script, so i can create new instances of them.
Example code:
im1 = new ImageLoader('../im1s.jpg');
im2 = new ImageLoader('../im2s.jpg');
dock = new Dock(new Array(im1,im2));
ss = new SlideSHow(new Array(im1,im2),dock);
ss.init();
View 2 Replies
Feb 9, 2009
I would like to make my image gallery reusable because I would like to load a 2nd and 3rd XMLList into it.
My images are loaded into duplicated movie clips on the stage with different instance names.
See code below:
ActionScript Code:
import gs.TweenMax;
import gs.TweenLite;
import gs.easing.*;
[Code].....
how to make this image gallery reusable. I've tried putting it into a class, but I cant access the instances on the stage.
View 0 Replies
Feb 11, 2011
So Im developping a video player that I can reuse in my projects.
The video player contains both .as files and graphical assets (buttons, loading bar, etc). And the graphical assets need to be styled for each project.
Right now the approach Im thinking of is having a base videoplayer.fla, and importing the library items into my new fla, and modifying the graphical assets manually there.
The other option Im thinking of is compiling a swc, but afaik the styling would become more complicated and more limited to colors, fonts, and such.
View 5 Replies
May 2, 2005
I've been using the "Reusable Preloader Using MovieClipLoader" from the tutorial section of this site.The only difference is that i don't use 'm for preloading jpg. I load external swf files containing video. Everything works fine so far. The only problem is that the preloaded video already starts playing while preloading (at about 30%), but without showing the video.This is the code i have so far:
Code:
bar._visible = false;
border._visible = false;
[code].....
View 4 Replies
Mar 14, 2011
I'm trying to create reusable rollover button states with dynamic/changing text - any cleaver workaround for that?
View 1 Replies
Nov 19, 2009
I have been working on creating a package of reusable code for myself. I frequently create projects that have a set of panels, which I re-skin for each particular project, and each panel has its own body of functionality.There are about 10 different panels that could be used in a given project, but not each panel is used in every project. Some projects use 5, some use 8, some 10 etc. My problem is that when migrating the panels to a new project, I don't nessicarily want to have every single panel in the library with appropriate exports etc. if it's not going to be used in the project.
For example
PHP Code:
package panelPack {public class Main extends MovieClip{public function Main(){}public function activatePanel1():void{var panel1:Panel1 = new Panel1();}public function activatePanel2():void{var panel1:Panel1 = new Panel2();}public function acti
[code]...
Then I have something like a config class that would have code like this:
PHP Code:
activatePanel1();activatePanel3();activatePanel5();
Then each class is something like this, referencing a library item that is exported:
PHP Code:
package panelPack {public class Panel1 extends Panel{public function Panel1(){var closeButton:SimpleButton = this.closeB;var submitButton:SiimpleButton = this.submitB;..........}}}
I don't have to have panel1, panel2.....panel10 in the library if i'm only activating 1, 3, and 5!If i don't have those items in the library i get all kinds of undefined properties buttons etc. Everything that in the MC that gets exported.
View 1 Replies
Dec 14, 2006
Basically I'm using the code below to change the colour of the text in a movie clip that I'm using as a button. This works fine, but I have 8 buttons in my navigation and at the moment have to duplicate this code for each one. How to turn the colour change code into a function that I can reuse?
[Code]...
View 7 Replies
Aug 13, 2008
I've been using a fairly un-dynamic approach in AS3 as until now when it comes to loading assets, but now I'll be trying to adapting a current project to fit other clients with different needs which means I'll have to grab the bull by the horns. I have an XML with a list of images that will be used, which is reused multiple times in each project. So I'm wondering if there's a way to load an image using the loader-class, and making it reusable? Being able to attach said asset later to a placeholder inside a movieclip I have stored in the library would be ideal.
I managed to load it into a movieclip but duplicating it from there on was a bit of a headache, using an approach similar to this would be great(but I have personally no idea of how to implement it): [URL] Here's the current code I'm using, in case it helps understanding what I'm after(it's most likely really ugly compared to what you SHOULD be doing in as3):
[Code]...
View 3 Replies
Feb 3, 2012
I haven't scripted in AS3 is a while and can't remember having these issues. Perhaps it's because I've been using less strict languages like lua, ruby/php, and java that has made this difficult to get back into.
I am trying to make classes talk to each other and am using folders in an attempt to make things a bit easier for me to track.I have a document class in the base folder known as Main and right now one other class located in com/Game/ known as NewGame.as
Now the issues I am having is basically the Main.as sets up the stage. Puts on the starting buttons, interface, etc. The NewGame.as is called from the Main when the NEWGAME button is clicked. I have gotten that working properly, a few hang ups on error 1061.
[Code]...
View 6 Replies
Jan 3, 2009
I am trying to create a reusable class. documentation says to use as package name the directory structure.
in directory C:JJGFlashSourceRF
i have a class in a package called "package
C.JJG.FlashSource.RF {"
in my test flash file I have "import C.JJG.FlashSource.RF;"
I also tried import JJG.FlashSource.RF;
View 8 Replies
Apr 27, 2007
Does anyone have a loading solution that allows for loading swf's, jpegs and is fully customizable? My duct tape solution had been to have loaders in every swf that i was planning to load in- but this feels silly. I've tried a couple of components from the adobe exchange but they lacked a bit of elegance. Whether it's a class or example file- I just want to be able to smoothly load content into the parent- where the loader also resides.
View 2 Replies
Jan 17, 2010
I am going to sell the swf and I was wondering if my code was protectd from the decompilers -- and is their away to protect your classes
View 2 Replies
Nov 13, 2008
You have some examples of how works custom events in as2? If I have 2 classes that extends movie clip, how can I make them to comunicate with custom event.?
View 1 Replies
Apr 5, 2011
I am new to flex framework.I have created an application using flex framework 4.1 which is having various components that are shown to the end user in the form of a popup window using <mx:TitleWindow>.This titlewindow is closed either on the click of the close button (displayed in it's titlebar) or by pressing the "escape key" on the keyboard.I coded a functionality wherein I close the current TitleWindow whenever an 'escape' button is pressed.Here is what I did.On the keydown event of TitleWindow I called this function.[code]I had to repeat this code for every TitleWindow that I have used in the project.How can I write the above functionality only once and reuse it amongst various TitleWindow and other components so that the code for the same is not repeated across various components? Every TitleWindow that I am using has different code, scripts and layout in it.
View 1 Replies
May 8, 2011
I have a library symbol, exported for Action-Script and to Frame1. Now in the document Class, i write
public class Test
{
public function Test():void
{
[Code]....
Now the code works fine but when i write my own (sealed/fixed) Box Class that surely Extends MOVIE-CLIP, statement-2 gives error , i know the Box Class is not dynamic but the Movie-Clip is Dynamic. Now what i understand that Movie-Clip Class being dynamic becomes fixed/sealed when it is extended by any Fixed/sealed Class???
View 1 Replies
May 28, 2011
Assume i have a custom actionscript class. [code]...
Suppose also that i have a different class, that changes a second variable, which has the metadatatag [Bindable]. What methods and events do i have to implement in either of these classes, to make myVariable change, whenever the other is changend?
View 1 Replies
Oct 29, 2009
i been trying to figure out a way to make sure my property values from my xml file are fitting sweetly into my classes.
using 'property is XClassType' pretty much tells me if its an array, boolean, number. But strings are a bit weird. Even though the property is declared public var some:String the below test doesn't trigger it being set to a String. Are Strings different than Boolean, Array, Number, etc.?
Code:
if (myTarget[i] is String) {
trace("prop is string");
myTarget[i]=String(mySource[i]);
}
View 4 Replies