ActionScript 2.0 :: MovieClipLoader And Defining Variables?
Apr 28, 2008
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..
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); }
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?
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.
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'm looking at the MovieClipLoader class, which seems to include a lot more functionality than loadMovie(). However, the one thing it seems to be missing (and the only thing I absolutely need) is the ability to send variables (using either GET or POST) to the new clip. loadMovie()'s third parameter is an optional string that specifies which HTTP method to use to pass variables, but I don't see any equivalent in MovieClipLoader.
I'm wondering if there's a way that I can pass variables to my new movie using MovieClipLoader. OR.... Use loadMovie(), but still have access to methods like onLoadError() and onLoadComplete().
I'm making a XML photogallery. Im using a MovieClipLoader to load multiple images on the screen at the same time. I've assigned variable path to hold image
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});
I am using a movie clip with graphics as a cursor.
However, it appears that the actual 'hit' area of the movie clip is related to specifically the normal arrow cursor.
I would like to be able to define an area of the graphic, in this case it's a hand holding a billy club so I'd like just the tip of the billy club the 'hit area.'
pretty much just saying there is 10 elements in it. I define each function as "land", for example. Then in the same function I redefine a random element as "water".
(It is a bit more complex, this is simplified!)
Upon executing this I get the error:
ActionScript Code: TypeError: Error #1010: A term is undefined and has no properties.
if I put the second bit in a new function (the random water part), there is no problems and it executes perfectly. Obviously I cant define an element twice in the same function.
this is my first attempt at defining a function all by myself and surprise it don't work! I'm sure you can see from below what I'm trying to create.
[Code]...
Basically dependent on the hour the text displays a relevent welcome message. Once I cracked this I was going to use the same code to alter an animaton of a scene to reflect the time of day.
I have drawn a rectangle area in which I want to drag a copy of a MC instance from outside the rectangle.
1. I want to be able to define the rectangle as a boundary so that I can drag and drop a copy of the instance from outside the rectangle to inside the rectangle. If the MC instance is dropped outside the rectangle then the MC instance snaps back to it's original position.
2. Once the MC instance has been dragged and dropped inside the rectangle it can be dragged and moved around BUT only inside the rectangle and not outside it.
this is my first attempt at defining a function all by myself and surprise it don't work!
I'm sure you can see from below what I'm trying to create.
stop(); daytime = function () { myDate = new Date(); var h = myDate.getHours();
[Code]....
Basically dependent on the hour the text displays a relevent welcome message. Once I cracked this I was going to use the same code to alter an animaton of a scene to reflect the time of day.
I'm building a script that adds a textfield to a movieclip. I need to add an onkillfocus event to that textfield that will make it call a certain function, which is located in the movieclip where the textfield will reside. The trouble is that I'm creating the textbox in a script in a completely different movieclip, and I'm having trouble getting the event to find the function.
I am trying to figure out how to reference something thatappears later in the timeline with Actionscript on the firstkeyframe without receiving run time errors such as "undefined", or"null references". Trying to define the objects using references(ie. var myMC:MovieClip) doesn't seem to cut it. Short of placingitems on the first keyframe and then pushing them off the stage outof view, I have yet to find an elegant solution for this
It's not clear to me, where I have to define Classes and Constructor methods. In AS2 it was possible, to define a class "light" by defining a constructor method. In AS3, I read, a class can only be defined in an external AS-file. Is it still possible to use the constructor method inside the Flash-File or do I have to source out all my constructor methods and implement them into real classes into an external AS-File?
I've noticed that AS3 doesn't seem to contain a way of defining a minimum amount of characters required but does have a maximum. Any way to do this with a textfield?
What I am trying to do is kind of odd, but I am wondering if anyone can come up with a clever way to do what I want to do. Basically, I want to re-define a named function at runtime. I can do this with anonymous functions, but I can't figure out a way to do it for named functions. I want to do this so that I can implement a "spy" functionality on an object for a testing framework (a port of Jasmine to Flex).
Take, for instance, this class:
public class TestClass { public var anonymous:Function = function():void { trace("original anonymous");
[Code].....
Can anyone more clever than I come up with a way to hack this? Can the bytecode be hijacked? Something?