ActionScript 2.0 :: (Flash CS3) Defining Variables To Different Buttons?
Nov 24, 2010
I'm trying to assign actions to various buttons for a website I am building, however I would also like to play a little movie first each time before linking to their individual different frames. The movie is the same for each button but then, obviously each button ultimately needs to link to a different frame. I'm guessing a nifty mix of gotoandPlay and variables are the answer but I'm getting myself in knots.
The structure of the site is as follows.On the main stage I currently have 4 frames. Each frame contains a different "page" of the website. The "home" frame has the navigation bar (including a sub-menu movie which has a number of buttons nested inside it which I think is going to be tricky). At the end of the "home" movie, there is a little fade animation which is labeled/ red flagged on the timeline - and it's this little animation I would like to have playing when a button is clicked on before linking to another frame.
At the moment the best I can manage is that when the button is clicked it goes back to the beginning of it's movie (a problem with the target paths perhaps?) as opposed to a label within the parent movie.I also think where I'm getting confused is exactly where I am supposed to define all the various variables and pieces of actionscript. The little snippits of code I have are as follows: Within the button I am trying to link, so far I have:
The "artwork" tag is the frame specific to that button (this is one of the sub-buttons that is nested within a submenu movie).Then in the movie for the webpage I have the following in the last frame of the mini animation that I want to play before the button links to the artwork frame:
I�m planning to make a magazine in Flash, and I would have to load several pages of it in order. But I�d like to put the buttons forward and previous on the main movie and make then load each page in a container.Is there a way to set variables for each page so the main movie "knows" what movie is loaded at the moment and what page it has to load next.
I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.
I posted a problem recently and I think I was asking too much too soon, I apoligise for that one. I want to try again with my problem. Basically I am making an interactive circuit builder in flash mx for 8-10 year olds (does anyone remember crocodile clips?).
var cColor1:Color = new Color(mcBut1.mcFill); var cColor2:Color = new Color(mcBut2.mcFill); var cColor3:Color = new Color(mcBut3.mcFill); var cColor4:Color = new Color(mcBut4.mcFill); var cColor5:Color = new Color(mcBut5.mcFill);
What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?
Something like:
for (var i:Number = 1; i < 6, i++) { var cColor+i = new Color(eval("mcBut"+i).mcFill); }
using the MovieClipLoader function to load in several images into various actionscript defined movieclips. These movie clips, with images loaded into them, are going to have onRelease functions associated with them which will load in a larger version of the image already loaded. As you can picture, there are a series of thumbnails, and each thumbnail needs to be clickable and load a larger version of itself into an empty clip. However, I can't seem to define variables inside of the MovieClipLoader object as it's not technically a movie clip?
How might I know which larger file to load when one of the thumbnails is clicked? All the files are named all sorts of things, aren't in any particular order (user defined from a drag-n-drog UI)... I thought I was on the right track, until I realized I couldn't define variables within the empty clip holding the thumbnails..
Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:
Code: //define the function function attachVid(nc, ns, curVid, vidFile) {
[Code].....
I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working.
I'm having a strange problem setting variables in movie clips from another (parent timeline). I run the following code from the parent movie clip to target child movie clips it contains.
I am trying to set variables in a movie clip targetted by the 'clip' argument in the setVars function but they are being traced as undefined. However, setting the function works fine. I have also tried manually defining the variables in the movie clip and am still unable to change them externally from the setVars Function.
im working with my main FLA and a script for it child.as i have created a variable in the parent, "svar:Number = 0;" i would like the child to be able to modify this variable when certain triggers are met i've tried something like this in the "child.as" but im assuming its probably much more complicated
[Code]...
im wondering if there is a simple command such as this to call upon an existing variable in the parent? if not, is there a way i can import the variables using the import command?
how subclasses,instances,and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues.Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".
Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct? I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?
Also, conventionally, what should be in my Main class? Only the addChild code which attaches MCs to the stage? Or should the values of variables be defined in Main? What am I missing? I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head.where I should be defining values of variables for classes, subclasses, and instances?
I need to make the buttons that are associated with this code, toggle, so once you press them they become greyed out. So I was thinking of after you press a button, the alpha is reduced to 40%. Can someone help me place that piece of code into this monster? -I know it should go into the presto function of my script. Which works fine, but then it stays at 40%alpha after the user click on a different button. I need it to toggle off once someone clicks on the next button. [code]
I got a set of buttons and a text field where they load the content.I'm trying to not make one zillion functions and keep the code neat so i guessed i would try set the buttons' actions within the loop too. I firstly had some problems getting the i counter inside the onRelease function (actually I don't think i ever got how to do it). But I tried this and worked:
stop();var comprarXML = new XML();comprarXML.ignoreWhite = true;comprarXML.load('flash/comprar.xml');comprarXML.onLoad = checkLoading; function checkLoading(success) { rootNode = comprarXML.firstChild; ButtonReleaseAndContent ();} function ButtonReleaseAndContent (){ for (i=0;i<12;i++){ // my buttons are not generated dynamicly, that why the count. btTemp =
[code]....
At the line where I set the text, I had a though " I may have to refer from within the button mc, since the generated code goes inside it!". So i tried the this.temp , guessing that this would be equal to the button level. A few seconds later i noticed my referencing for the text field wasn't coming from within the button, but from the root.
I think I am on the right track here but if someone could help that would be great. I have a piece of code that loops ON_ENTER_FRAME and it is used to check if a pistolBullet is hitting a barrel.
The problem I have is that I can check for collision of a barrel, if I manually type the name 'barrel', 'barrel2' etc within this code:
I'm stuck with defining a getURL function while loading an external XML file.
I have a Flash AS2.0 file and I've made it CMS driven. The content for everything in the SWF file is loaded from an XML file which resides on the same server. I've defined all other XML variables and I'm able to successfully parse them inside a holder MC I have in my Flash file. Some of the many variables I have are name, caption, thumbnail img, large img, etc... I've also defined the XML file with a 'Link' that points to a URL relative to each image it loads.
I'm unable to define the function in Flash to retrieve the URL from 'Link' parsing value stored in my XML file.
I tried defining a function called getLink in actions layer of my Flash file:
getLink = function () { getURL('Link[ID]','_blank'); };
The ID is loaded in the beginning of the Flash file - based on the number of values available in XML file. All other functions work, except this getURL function.
I start the movie and it traces "null" which makes sense. But when I click on a button it doesn't trace the button name. I know the disconnect is at the point where I'm clicking the button. Is there a way to put a listener into the content movie clip that will run the code again when a button is clicked?
I have three movie clips that I am using as buttons. Their instances in the movie are Espanol_btn, Francais_btn and Deutsch_btn. I have added script to control the rollover and press/release states of the buttons, and now need to get the script to recognise which of the three buttons was pressed, store that result in the variable called lang (The posibilities are Espanol, Francais or Deutsch), and depending on what the variable land is, do different things. The script is below.how I can get this to work.
Code: import mx.transitions.Tween; import mx.transitions.easing.*; var lang:String;[code].....
I'm trying to use actionscript in a button to increment variables in my program. ie. when you click the button it increments a variable and so displays different information in one of my dynamic text boxes. The program doesn't seem to recognise the button input. I understand you have to give your button an instance name but I'm not sure how to set up the code to recognise this input.
So I want to do saving and loading for variables. I.E. I want to save a variable by pressing the save button. When you use the "load" button, the variable is what it was when it was saved. I've tried this but it didn't work...
Code: //Code on the frame var saveState = SharedObject.getLocal("Cookie");
//Code on the save button on (release) { _root.save.gotoAndPlay(2); savefile.data.blah = _root.blah; savefile.flush(); }
//Code on the load button on (release) { gotoAndStop(3); _root.blah = savefile.data.blah; }
I'm trying to use actionscript in a button to increment variables in my program. ie. when you click the button it increments a variable and so displays different information in one of my dynamic text boxes. The program doesn't seem to recognise the button input. I understand you have to give your button an instance name but I'm not sure how to set up the code to recognise this input. The code in my button is on (release) { buttonup++;} This is meant to increment a variable of that name but doesn't appear to work.
I have a movie which consists of 4 buttons( PLAY, PREVIOUS, NEXT and STOP)
[Code]...
These buttons work correctly and advance or reverse in sequencial order (slide1,slide2,slide3,slide4). However the movie can run from start to finish wihtout the use of the navigation. My problem is that if I let the movies run independently and then choose to use the next button while(for example) "slide3" is playing, the movie jumps to "slide1". Note that these slide labels are located within movieclip named "allunits" I know that the variable currentSlide is still equal to 1 thus returning the playhead to label "slide1".
I have two buttons (a and b) and a ball movie clip (ballMove) on the screen.This is what I want to happen:The ball starts off under button A. If you click button A, the ball stays where it is. If you click button B, the ball moves over to button B.When the ball is under button B it won't move if B if clicked, but will move to A if A is clicked.How I plan on doing this is within the ball movie there will be three motion tweens, staggered so they don't overlap. The first isn't a tween at all, actually. It is one key frame at the very start of the movie timeline. I have labelled it "beginning". Also, it has a stop action and var busbus = 1. Bus is the variable I want to use to track the position of the ball.
The next tween is the ball travelling from point a to b. The start frame is labelled "atobbegin". There is a keyframe at the end labelled "atobeend". A stop action is on this keyframe, and also bus = 4.The final tween is the ball travelling from point b to point a. The start frame is labelled "btoabegin" and the end keyframe is labelled "btoaend" with a stop action and bus = 8.Eek, just got Deja Vu.er, moving right along....
On button A I have assigned these actions: on (release) { if (_root.ballMove.bus == 4) {
Level1= the different sections of the site, are loaded into this level (eg. home.swf, aboutus.swf etc.)
Because each of these sections has both an 'in' and 'out' transition, i want to use variables (on the buttons) to control these external movies that are loaded into the main movie (im even starting to confuse myself
basically in a nutshell... can you use buttons which control a movie ,which has been loaded at another layer, using variables....
I have completely hit a wall. Here's what I'm after. I have two sets of radio buttons, each of which controls what loaded swf appears on stage. Then, depending on which button is clicked in group one and which button is clicked in group two, a third swf appears. I can access the value of each radio button, and I'm passing it into a variable (I think - the trace command works) but when I drop it all together into an if/else statement, no data is passed.
Here's the code: //printArea is a movie clip on stage, which has dynamic mc's attached via code var thisFront; //function for what happens when fronts radio buttons clicked frontListener = new Object(); frontListener.click = function(evt) { [Code] .....
I am trying to get a dynamic text box embedded in a button to populate on (XML) load but am having trouble with the path. The text boxes not embedded populate just fine. I have attached my FLA and my XML is below.
I am trying to define a CSS style dynamically. how to get around hard-coding the values this way:
code: var styles:TextField.StyleSheet = new TextField.StyleSheet(); styles.setStyle("mainBody", {color:'0xff0000, fontSize:12});
I tried something like this, but it isn't working:
code: var styles:TextField.StyleSheet = new TextField.StyleSheet(); styles.setStyle("mainBody", {color:colorVariableFromParentMovie, fontSize:sizeVariableFromParentMovie});