IDE :: Reusing Reusable Classes?
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
Similar Posts:
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
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
Mar 1, 2011
I am trying to reduce the size of my swf, and I see that I am using a movieclip on each frame on the Timeline, which has to be adding considerable size to my file, since I have placed the movieclip(animation) on every frame. How could I do this more efficiently and still acchieve animation between each frame? I have included a ripped version of the fla. , since the attachment limit here is pretty low. In the file the video - files and the picture files have been removed, but the rotate... mc's(animation) are placed in the interanim Layer and the Menustate Layer, on each frame.
View 1 Replies
Jun 21, 2009
I am doing a web portfolio with thumbnail buttons that change the pictures. What is the best way to avoid having to make a new button for each new picture thumbnail? So resusing the button but changing the thumbnail picture in it and what picture it links to? Using CS4.
View 1 Replies
Feb 25, 2010
Suppose I want to load a .jpg from the server ONCE and then I want to reuse it a dozen times in my .swf... How can I achieve this without adding to the .swf`s file size? I was thinking copying its BitmapData a dozen times, but that adds to the file size, right?
View 2 Replies
Aug 31, 2011
I am making a mobile application in as3. I'm optimizing.I have a scroll containing 30 objects (buttons). All buttons are the same except its title.This bucle is inside the container scroll:
for(var a:int=0; a<global.get_A.get_B.length; a++)
{
b = new ItemList(global.get_A.get_B[a]);[code].....
View 1 Replies
May 18, 2009
Out of some curiosity and the use of possible standard key variables so I don't have to create several instances to the same class, I was trying the following:
[Code]...
My question is: Is there a better approach to this on AS3? Something tells me I'm just heading the wrong way there...
View 4 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
Apr 2, 2009
I'm doing a filmstrip animation and each frame of the strip has a small pic on it and using TweenLite, I'm making it expand and contract on mouse rollover and rollout. That's not the problem. Since it's basically the same function, I don't want to have to write it for all 16 frames. I thought I'd try 'this' but that doesn't work on AS3. So I'm trying to find a solution that does. Here's my code (for one frame of the movie....in this case, the eighth).:
import gs.TweenLite;
fsAnim.filmstrip_mc.photo8_mc.addEventListener(Mou seEvent.MOUSE_OVER, photoOver);
fsAnim.filmstrip_mc.photo8_mc.addEventListener(Mou seEvent.MOUSE_OUT, photoOut);
function photoOver(evt:MouseEvent):void {
[Code].....
View 3 Replies
Feb 17, 2011
I need to load an external resource and be able to reuse it (create new objects based on that resource). I need to create multiple objects using that resource and I don't want to load it again over and over every time I need to use it. My question is: How can I load a resource (in my case, it's a collada file ".dae") once and be able to reuse it again?
View 1 Replies
Jun 28, 2011
I'm creating a pacman game and basically I'm having trouble coding the enemies (ghosts), the code works perfectly with just one ghost, as soon as I add another it starts to go wrong.Firstly I've got this function which places the enemies:
Code:
//places the enemies
function placeEnemies() {
[code].....
View 2 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
Apr 17, 2009
if I have two scenes and on scene 1 I have some code with variables and event listeners in it and I copy that code into Scene 2. When I test the movie I get a duplicate function definition error because the variables/event listeners on both scene 1 and 2 have the same names. To fix this I could just change the names of the variables and event listeners in scene 2 to a different name but what if I have say 10 or 20 scenes then I would need to change the names of all of them on every frame and I don't want to do that.Is there a way of using the same variables/event listeners on different scenes without having to rename them and without getting the duplicate function definition error.
View 21 Replies
Jun 19, 2009
I'd like a movie clip called "following_cursor_mc" to follow the cursor, regardless of which of several different frames the playhead may be on. I've reproduced the code below on each frame in which I would like the cursor to be followed by "following_cursor_mc" but these errors are thrown for each of the frames:
1021: Duplicate function definition.
View 7 Replies
Feb 4, 2010
I am trying to reuse the lines of code and it worked fine the first time but when I tried to use the evtObj.target.name it gave me error 1120:Access undefined property evtObj.Here is the code I tried to use:When I test the movies it just runs automatically instaed of waiting for the click.
View 4 Replies
May 23, 2010
If I use an empty movie clip to load a series of images into,how do I get them to load in the center?The images are all different sizes.I think this is fine, if they loaded with the center of both the target clip and the image aligning.Upper left registration point for the target is not good.
View 10 Replies
May 2, 2011
i was in situation that tree is re-using my custom item-renderer.. is there any method or way around we can stop tree to reuse.. and always create a new item-renderer for new item..
View 1 Replies
Jun 6, 2011
I want to be able to reuse my existing controller logic regardless of whether a request has been sent from a Flex client (using BlazeDS + Spring at the backend), or as a simple HTTP POST/GET request. For simple cases, things work OK, however, there are some occasions when I need to access some session attributes. At first, I almost exclusively used the FlexContext class, but then I realized that when one sends an HTTP request, then the Flex Context is obviously undefined.
My question is, what is the best approach to abstract the session extraction logic,regardless of the type of the request. In other words, I would make a class called SessionManager, which has a method getSession. This class will make a check whether there is a Flex context, if there is, it will return the session of that context. If not, it will simply return the current HTTP session (which I assume is the same as the Flex client session, but I was not sure)
View 1 Replies
Sep 11, 2009
I somehow am able to write bits of code but am still learning how to restructure code so that it is more efficient.I have 15 buttons. Each one, when rolled over, should change the color of 2 movieclips underneath it (and when rolled out, should change back). I have the below code so far but I don't think I have to re-write the functions each time. How do I "re-use" the function code (or, only write the function code once), but specify what movieclips the function should be applied to? These are just 2 of the buttons of the 15:
Code:
menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OVER, changeColor);
menu_mc.invis1.addEventListener(MouseEvent.MOUSE_OUT, changeBack);
function changeColor(event:MouseEvent):void[code].................
View 9 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