Actionscript 3 :: Refactor Nicely To Avoid The Massive Switch?
Aug 9, 2011
I see this quite a lot and I was wondering if there was a way to refactor this nicely to avoid the massive switch? This is a method in a factory: RoomControllerFactory, instantiating a game location based on its type. Here's an example from a switch in the factory method:
[Code]...
View 2 Replies
Similar Posts:
Oct 4, 2011
I've just started using Flash Builder (4.5) instead of coding in Flash IDE and so I was REALLY happy when I discovered the refactor-feature (I've never used a proper coding IDE like this before).Problem is, it just not working! :O And it's driving me mad and no one else on the entire internet seems to have the same problem.No matter what I do, or project I use, whenever I try to refactor a function (selecting it, then CTRL ALT R) it only applies to the currently open as-file, but all other files in my project is left untouched despite containing references to that function.
It's like I'm totally clueless as to what to do next .I'm guessing it has something to do with how these as-files are connected, basically they are all in the source folder so when I need a class I just write "new CustomClass()" and it will work as they are in the same folder,but when it comes to the refactor-feature maybe that's not enough? I'm thinking this since even the "show reference" feature and such doesn't seem to ever find the references from the other files. :S
summary: My code works and runs, problem is just I really need to rename some stuff for easier coding and that just isn't working.
edit: Btw the "preview" button on the "rename function" doesn't show the references either.
View 1 Replies
May 26, 2010
Just taking my first stumbeling steps from Flex Builder towards FDT.As I understand refactoring should work much like in Flex Builder, but when I select a variable for refactoring the dialog box shows the name of the class and if I click OK the class (the current .as file) is renamed and not the variable.No matter what I try I can only refactor the class name.
View 1 Replies
Dec 15, 2009
So I'm trying to make Flash video work at [URL].. Things are going swimmingly in Safari and Firefox. Not so in IE.
I completely expect this is due to my Flash incompetence. where things are going wrong? I'm attempting different methods to input my video in each of these cases:
[Code]...
I know I'm missing something fundamental here, as all three examples are broken. I'm not necessarily just looking for the fix for each of these three. I'd like for your help understanding what I don't understand it, and how to understand it.
Eventually, I'd like to build a template where the client could throw either an .flv or .mpeg4 or .mov at it, and voilĂ , but is something like this even possible, given I correct my current, idiotic Flash principles?
View 1 Replies
Jul 14, 2011
We're developing a Flex-based component that's going to be hosted inside another company's product. Due to the nature of their hosting environment, the Flash movie will run in its own <iframe> tag.The Flex app calls out to our REST services via HTTPS, and authenticates with an HTTP cookie. This works beautifully in Chrome, Firefox, Safari... everything except IE. I compared requests from Chrome and IE using Fiddler, and noticed that they are identical, save for the HTTP Cookies. IE omits several, including the one used for authentication.
View 1 Replies
Jun 9, 2005
does anyone know the actionscript so that and item fades in and out nicely with out any motion tweening or anything
View 4 Replies
Sep 7, 2011
FDT can do it, but half the time it times out and needs to be restarted on renaming some objects. Can Flash Builder do this?
View 1 Replies
May 26, 2009
I've been building my app' and testing it every day by exporting it to a movie, and testing everything.It's all been going very well and the .swf is usually exported to my desktop in less tha the time it takes to minimize the Flash window.Today I started work on my .fla (mark18) and added a "back" button to every scene (it takes the user back to a main page with the actionscript:
on (release) {
_root.gotoAndPlay("Main");
}
There are 9 scenes which are very short.BUT, when I tried to export it, it took about 15 minutes to export.
View 4 Replies
Nov 21, 2010
I made an app. I figured out how to load all my images into in.
I have about 1000 images and 1000 sounds that I am using in it. About 70MB of data
How will this affect a users computer?
Is it even possible the load up this much content?
I ask because I am getting stack overload error on my bulkloader!
Scares me to think that months of work will go down the drain because I can't load this much data!
View 4 Replies
Jul 8, 2011
I got this website at work which I've just updated.It was working pretty well, yesterday I showed it to a friend.And it was working perfectly. This morning, I hear sound but all i get is a black screen.It works on every other browser (chrome, firefox, SeaMonkey, etc.) but in Internet Explorer, black screened.If anyone can,I need a quick solution, my bosses are freaking out and that is kindda out of my league as for "trouble shoot".Why something that was working not even 12 hours go goes awry on me today?
View 2 Replies
Feb 1, 2012
this is the offending bit of code:
for (var i in yearMarkersArray) {
yearMarkersArray[i].x = ((timelines.x + 350) % 140) + (140 * i) - 5;
yearMarkersArray[i].text = "0";
}
This is part of the main loop that triggers whenever the user drags the zoomed-out timelines (the sprites in eventsArray) left or right. The six TLFText objects in yearMarkersArray appear to scroll left or right with the user, but are really repositioned and relabeled with the correct year markers as calculated by a function I did not include above (it's working and not relevant to this problem, I simply replaced it with the "0" for clarity).
The text-setting statement is the problem code...I've commented literally everything else out of the main loop to verify it. I even changed the statement to not involve any function call (simply setting the text attribute to "0"), and it still causes the final .swf to eat an extra 1% of my CPU every 15 seconds until finally the FPS crashes through the floor. The rest of the main loop has much, MUCH more complex and I'm sure inefficient code that also runs every frame,Since this project reads a data file with a list of timeline events whose span of years I cannot predict, I do need the displayed year markers to be done dynamically in some way. The code ultimately works (I only noticed the ridiculous slowdown when I accidentally left the movie open and idle for a few minutes),
View 2 Replies
Jun 3, 2009
We have a problem working with FMS 3.5 (installed on a IIS server). Configuration of the servers all based on IIS: webserver (authentification, xml data loaded by Flash app, data (on IIS) sended to and recieve from FMS). Seperate FMS 3.5 (latest update) server. Only running FMS (no other apps are running on this machine).
[Code]...
View 7 Replies
Jul 25, 2011
How do you load an image that exceeds the 4096×4096 limitations of flash while splitting it?
View 5 Replies
Feb 18, 2011
I am making a snow boarding game in AS3. The problem I am having is that I want to leave a trail in the snow behind the board.
I have had a think and feel that the best way of achieving this would be to use the lineTo() method to draw a line form the snowboards previous position to its current position. If I do this all of the way down the slope I would end up with a line almost 23000 pixels long which seems extremely large and will have a major impact on performance.
If I were to convert the trail movieclip to a bitmap would it improve performance? I am targeting a minimum of flash player 9 which I have found to have issues when handling bmp's over 2880 pixels so I think this method might not work.
View 2 Replies
Nov 14, 2011
I have created a class that I've been using as the storage for all listings in my applications. The class allows me to "sign" an object to a listing (which can be created on the fly via the sign() method like so):
manager.sign(myObject, "someList"); This stores the index of the element (using it's unique id) in the newly created or previously created listing "someList" as well as the object in a 2D array. So for example, I might end up with this:
[Code]...
View 1 Replies
Nov 4, 2010
So I am trying to embed some simplified Chinese into my flash file. When I turn off embed fonts the flash file is fine. If I add simplified chinese char set it makes the swf massive. Is there a way to embed a smaller character set than the ones flash offers. Standard English Characters if I add all the characters and pnctuation amount to 106, simplified Chinese is 11,218 it just is not doable.
So
(i) Can I smooth html text in flash
or
(ii) Can I used a reduced character set?
View 1 Replies
Oct 30, 2011
What I'm trying to do is create a program that, depending on 2 variables, multiplies another variable by a static number. Heres the code I have so far:
[Code]...
View 1 Replies
Dec 10, 2003
I want this on an MC:
[AS]
i = 0;
switch(thing){
case 0:
[code]....
Basically what I'm wondering is, will I lose the value of i in the first switch once I'm out of the switch? Can the second switch read the 1st switch?
View 8 Replies
Oct 29, 2011
Im trying to create a program that, depending on 2 variables, multiplies another variable by a static number. A friend suggested I use case/switch instead of if/else statements,which is what I was using before.
[Code]...
View 1 Replies
Sep 17, 2009
How can I avoid that the ActionScipt error pop-ups appear.
View 4 Replies
May 24, 2011
It seems it isn't possible at runtime to change styling defined in CSS files, ex.: colors. This is seemingly because the CSS files are compiled into SWF. Is it possible to externalize styling information in CSS (or any other format) without compiling it to SWF file so that it can be changed easily at runtime just as normal CSS can be changed when it is used in HTML.
View 3 Replies
Mar 9, 2010
I have a movieclip, a square, which I would like to have moving around on stage, avoiding the mouse if you "chase" the movieclip. all the threads I have found have been with Actionscript 1.0 or 2.0. I tried converting it to AS3, but failed.
stage.addEventListener(Event.ENTER_FRAME, avoidTouch);
function avoidTouch(event:Event):void {
var distx: int = noTouch_mc.x - mouseX;
[code]....
Im stuck. I want to make it calculate the distance from the mouse to the NoTouch_mc and if it gets below a certain number, make the noTouch_mc move away from the mouse.If it could be made so it never leaves stage, that I'd like to incorporate too, but wouldn't I have to consider sinus and cosinus to an angle to make it turn?
View 6 Replies
Jul 30, 2009
iam using following code to scroll map. when scrolling horizontal or vertical, it scrolls perfect without any jerk(stutter) but when scroll diagnol this stutter happens.
Code:
function scrollMap(){
var p = {x:0, y:0};
var minX=(stageW/2)-32;
var maxX=(stageW/2)+32;
[code]...
View 0 Replies
Feb 18, 2010
I'm doing simple program to design kitchen. I'd like to avoid overlapping my movieclips but i dont know how. It means that when you drag movieclip - it would stop when it meets another movieclip. In others words, movie clip can be anywhere but not on the other movieclip.
View 1 Replies
Nov 24, 2003
I am creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around i.e.:
Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}}
But I'd like to avoid using that if possible.
View 7 Replies
Mar 14, 2009
every time i click on a button called create, an avatar is added to the stage. The positioning of each avatar is random and every picture is resized to fit 95x95 pixels.How can I check if I have positioned an avatar over an existing one? I am trying to avoid positioning them in the same space.
View 2 Replies
Apr 17, 2009
I currently have a login form in flash that needs to pass variables to a PHP script. That part works fine. The problem I am having is that when Flash passes the variables to PHP, it also passes the style of the input text.
For example, instead of passing "atomstore", it passes
"<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">atomstore</FONT></P></TEXTFORMAT>".
This does not match the "atomstore" in the database and results in an error. Any way to get rid of all of these tags?
View 2 Replies
Nov 24, 2003
im creating a menu with nested MCs, of course, and the parent MC is using a RollOver action. The problem with that is: all other nested MC's RollOver action are not detected. I know you can use a mouse hitTest as a work-around ie:
Code:
onEnterFrame = function(){
if(this.hitTest(_xmouse,_ymouse,true)){
//do whatever
}
}
but i'd like to avoid using that if possible.
View 7 Replies
Apr 8, 2009
I've been trying all morning to figure this out but I'm really not the best when it comes to actionscript. I've looked around and I just simply don't have a clue how to adopt other code to fit my own .I have the following code
Code:
function reActivateTopMenu() {
_root.top_nav.btn1.gotoAndStop(1);
_root.top_nav.btn1.enabled = true;[code]....
I just can't figure out the exact way of writing the code in "flash" talk and not "dave" talk!
View 10 Replies
May 3, 2010
Code:
if(_root.selmovie.hitTest(this._parent)){
_root.hit.text="it worked";
}
Why doesnt this work? I want to avoid naming all of the movieclips that this hittest is to apply to but this._parent isnt working...
View 4 Replies