ActionScript 3.0 :: Combine Similar Code Into One Function?
Oct 19, 2009
I have a project which uses very similar code for I think 12 or 13 different movieclips. I actually copy-pasted a good chunk of the code changing words and numbers here and there.[code]The main point of this part of the project is that each movieclip is a selector on a scrollbar. I just wanted the selectors to look nice, so they tween up and down on rollover and when they are clicked they change from black and white to color. Also when clicked they move a very long movie clip called customizing_forms_mc, into view on the stage. The code is inside a movieclip that contains all the selectors. There is a layer for each selector and on that layer is the code for that selector. I was thinking that there might be a way to call a fuction perhaps with the variables that are brought to the function being strings that i could substitute in for the names of the movieclips. I tried attatching the fla or an swf but they are both too large. For a more detailed look at the code on the stage:[code]As I previously said there is a scroller with the selector buttons and when clicked they bring a certain part of another movieclip into view. Of course, everything is masked so it looks nice.
View 1 Replies
Similar Posts:
Nov 5, 2011
I am a 3D Designer and I also want to learn Flash. give me some links or books because I want to learn that code , which is behind the design. I don't know the terms, I think is actionscripting and I would like to learn from start . How to combine code with design. I can follow some tutorials and copy the code from those tutorials but like this I will never learn to make what I want.
View 1 Replies
Jun 18, 2011
am currently developing a mobile app for android, and i have been getting some code from some tutorials, and want to combine them. But the codes are all in packages, and i don't know how to combine them since i can't make more than one of them the document class.How can i unpackage them, or package them together.
View 1 Replies
Apr 2, 2010
playback controls, however I still have a problem. I want to have an additional button that links to a website (I have coded this correctly with actionscript and works great. Now I have two seperate projects...one project has my playback controls and the other has a button that links to a website.I am having problems combining both action script codes and having everything working properly My code for each is below. How do I arrange them into one?
Code for link to website:
website_btn.addEventListener(MouseEvent.CLICK,gotoWebsite);
function gotoWebsite(evtObj:Event):void{ var theSite:URLRequest = new
[code].....
View 9 Replies
Feb 21, 2006
what's the best way to combine these onrelease functions here so i dont have to repeat the same lines of code?
[Code]...
View 9 Replies
Jan 21, 2010
i have here 2 very similar pieces of code, the first is supposed to make the movie clips larger on roll over and it does, the second, which is based on the first, is supposed to move the movie clips to the right on rollover, but it does not. the file names and class paths are not an issue, ive tested these pieces of code with copy and paste
Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
[Code]...
View 2 Replies
Sep 28, 2005
i am looking to create something similar to the str_replace function (from PHP) that will replace all occurrences of the search string the replacement string from within an larger string. Does anyone have something like that created already (save me the time)?
ie
var myStr:String = new String( "i wish i were an oscar meyer weiner" );
var myOutput = str_replace(myStr, "i", "we");
// myOutput would now = "we wish we were an oscar meyer weiner"
View 3 Replies
Sep 16, 2010
Is there any other function similar to 'hitTestObject'. Am having problem with this function, b'coz it checks the collision on a box around that object. I want to find the actual collision with the object.
View 2 Replies
Jan 26, 2006
I'm trying to combine a mc button's drag functionality with a double click functionality.
I have the actionscript to do both - with the drag aspect working fine - but I'm having problems getting the double click to work too - basically meshing the respective scripts.
Tried variations on combining the scripts but nothing working so far
The script is below
//double click: set initial variables
click = false;
//function for the button press
[Code]....
View 9 Replies
Feb 9, 2011
I keep confusing myself :S I've been staring at this screen too long.I'm trying to build function that creates a 2D array similar to this one:
Code:
private var test:Array = new Array
(
[code].....
View 2 Replies
Aug 26, 2011
I was hoping someone could help me working out some advanced data reformatting. What I'm hoping for is a function where I can input a value along with an array of key positions like so:
function remap(percentage:Number, keypoints:Array) { ...
The array would start with the minimum and end with the maximum point, with nested key points along the way. For example, I would input something like remap(0.25, [0:0,80:50,100:100] ) and the function would 'imagine' a spline curve graph from (0,0)-(100,100) with a key point of (80,50), then return the y value that is 25% along that graph.
View 1 Replies
Jun 10, 2009
I am trying to replace some code which loaded an external image and triggered and function once completed with code that uses and embedded image. The relevant code looks like this.
Code:
[Embed(source='globe.png')]
public function Globe()
{
var imageLoader:Loader = new Loader();
[code]....
The commented out section is where it used to take the loaded image and apply it to a texturemap.I need to replace the lines of code in the first function with something that calls the second function correctly.
I have tried using function imageLoadComplete (e:Event = null)and calling it with imageLoadComplete(); in the first function but although it compile and runs without error, the program does not work properly. I suspect this is to do with the dispatchEvent(); line which I do not understand.
View 4 Replies
Aug 6, 2009
I have been searching the internet for help on how to delay code within a single function, but every solution I have found so far relies on creating event listeners for a timer and then running commands from the event handler functions.I am writing a 'console' type interface where the user types in a string which is, upon pressing enter, processed in one function and then sent to a final function to display the result.[code]I want to somehow insert a pause between each call of that last function, updateDisplay.
View 1 Replies
Jan 11, 2010
In the moveThings function, the if part is only ment to play if the cursor is over the circle (ball_mc), which follows a bit after the cursor. However, something is wrong that makes it play this part (the first if statement in the moveThings), while it's meant to play the else part in that function unless the cursor is over the circle in which case the if is true.So what is wrong? I'm assuming that it's something with
Code:
if(-20 <= (stage.mouseX - ball_mc.x) <= 20 && -20 <= (stage.mouseY - ball_mc.y) <= 20)
that makes the computer play that statement even though the cursor isn't over the circle.
View 3 Replies
Jan 3, 2011
I have unfinished code I'm working on. It has a listener event and a function. I notice when I put the for loop outside the function (it would be below the last line) it doesnt execute. Why doesnt the code I type outside of the function execute? I need to know for future reference
[Code]...
View 4 Replies
Jan 13, 2012
In my quest to learn ActionScript 3.0 I have stumbled across another situation where I know what I need to do, but just can't figure out how to do. I have written code to animate a menu with 3 buttons. These 3 buttons reside in a seperate class file known as MenuButtons.as and I am animating them within my Main.as file which builds the application and places the relevant details onto the stage.So in my Main.as file I have written the animation code that I would like to use to animate the buttons. Whenever a button is clicked, an event is dispatched which a handler listeners for then executes the relevant function. So the function for animating my 3 buttons looks like this (bear in mind that the buttons are arranged in a place holder in MenuButtons.as which in turn is loaded in a new MovieClip in the Main.as file)[code]I also tween the logo from here too. It works fine which is great, but is there a way I can make this code more simpler? I may not be able to and I have tried to find my answer online but alas I cannot find what I am looking for.
I am loving how I am learning something new each day and by building up slowly I am learning more functionality and broadening my knowledge of ActionScript (although some of it is very confusing!)Is there any good websites out there that can help? I have a subscription with Lynda.com but i find that their explanations can sometimes be hard to understand. I love text based tutorials where I can follow at my own pace.
View 1 Replies
Dec 21, 2011
Say I need to know if a movieclip is draggable (for reasons of changing a custom cursor to an appropriate graphic).
I can check if that movieclip has a function assigned to it's onPress event.I store the assigned function in a Function object variable.
Can I see what code is inside this Function object? If it contains a "startDrag()" or "stopDrag()" method?
View 1 Replies
Jan 19, 2010
I am using CS4 AS3. I have a button that starts a function that creates dynamic buttons on the stage. I have another button that when pressed is to stop the previous function. I am relatively new at this and don't know how to code the STOP button so that it will stop the actions started by the first button.
View 2 Replies
Feb 29, 2012
I want to call a function in main flex app from the custom preloader code in actionscript before it dispatches complete event. Also i want to know how to call back to a function in preloader code from application
View 1 Replies
Jul 17, 2009
This seems like a simple problem but I can't seem to figure it out. If I use this standard code from the reference:
ActionScript Code:
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://myserver/");
var stream_ns:NetStream = new NetStream(nc);
my_video.attachVideo(stream_ns);
stream_ns.play("myflv");
the video streams fine, but if I put the exact same code within a function like this:
[Code]....
View 9 Replies
Apr 24, 2006
I am trying to turn the following code (which works well when applied to a _mc) into a generic function I can use on the first frame of my main timeline:
Code:
onClipEvent (load) {
this.speed = 0; // current tween velocity
this.tScale = 100; // target scale[code]..........
Have tried various ways without success.
View 5 Replies
Apr 30, 2006
I have an fla that uses the following AS:
PHP Code:
envisionblur._alpha = 100;
envisionblur.onRollOut = function(){[code]...........
I have four MC's that I want to fade onRollOver and onRollOut. As you can see, writing code for each MC is a rather convoluted way to achieve the effect.how to write the code as a function and apply it to all of the clips?
View 3 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
Mar 23, 2011
I am trying to figure out how to call an onComplete function without leaving the code loop (because the vars are no longer recognized with the hand-off). I thought this might work:
[Code]...
View 7 Replies
Feb 7, 2011
Having done some programming in Groovy, I know you can write test code in the Groovy console. I classify this as true a scripting language as it doesn't force you to have a class definition. So I'd assume with a name like ActionScript with 'script' in it's name that, you can write a series of statements that act linearly, such as a sequence of variables assignments, their manipulation and dumping out a value.
My question is if this is possible, how do you go about doing it, in order to test some code with ActionScript3? Does the code have to exist in a package?Can the code exist on it's own? (If so, what would the name be you'd give to the source file in order to compile it from the command line?
Would you use mxmlc?
Would you use compc?
I've heard about fsch too. How about that?I also read about a command called 'asc' in R.Braunstein's AS3 Bible 2nd ed (P8), but don't even see this in the SDK bin folders.... So what's that all about? Assuming I've managed to compile this name.as file, how do I execute it and see results? Do I have to run it through a browser and the HTML template, or can I execute from a command line?
Do you have to have a class in the source to bypass this? Can the code block be placed outside a dummy class? If so, does it have to exist in a function? Or can it exist on it's own?Does it have to exist in a code blocks, by wrapping them in curly braces?
View 2 Replies
Mar 19, 2011
My button use to work and then I added some code in the proceedToGame function and I get this error. TypeError: Error #1009: Cannot access a property or method of a null object reference.
Code:
package actions {
/*always extend a class using movieclip instead of sprite when using flash.*/
import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;
[Code]...
View 3 Replies
Aug 29, 2009
i have many buttons(they are actually movieclips) and for each i made separate listener function.. is it posible to optimize that code and make some kind of switch case inside the function. I don't know how to find out who called the function... is there way to find out. I don't want pass the additional argument with events because it wouldn't be optimization at all.I put only two buttons to reduce code:
Code:
button1.addEventListener(MouseEvent.CLICK, idi);
button2.addEventListener(MouseEvent.CLICK, idi2);
function idi(event:MouseEvent):void {[code]....
View 3 Replies
Jul 9, 2009
I created 2 separate swf files. One is a slideshow and the other is an interactive tool. I have have also converted these two files into a flash projector so as not to worry about plug ins that customer may or maynot have.I have another file right now which is the menu flash file that has buttons pointing it to the flash projector individual files. Since these are exe files, once the customer clicks on it, it will warn that it is potentially harmful and they have to click "run" in order for it to show.
View 7 Replies
Sep 11, 2009
Anyone can tell me the way to combine 2 fla files together. It mean in the 1st fla file I'll make a button and when I click the button it will run the content of 2nd fla file.
View 3 Replies
Apr 29, 2009
I have multiple .fla file (small online invitations etc) and I am trying to combine them as part of an online portfolio.
IS there a quick way of simply placing a .fla movie into another or do I have to use the swf.
And am I being silly - should this be done using Dreamweaver as the 'container"
View 2 Replies