Actionscript 3.0 :: Create Variable That References A MovieClip?

Aug 9, 2009

I am just starting to learn Flash. I am trying to make a "simple" Flash menubar to add to a basic html/css site I am building, as a learning project. I figured out how to make the navigation "buttons" using frame labels and event listeners. All the nav buttons will be identical, except for an image and the link destination. I know enough about ECMA based code to be dangerous to myself, so rather than make 7 individual buttons, each with there own AS and objects, I am wanting to make it more efficient by reusing the redundant information.

This is the logic than I am trying to use:

Create a generic button named "button_mc" that has a child which is a variable instead of actually pointing to a specific object. Then, create 7 different instances of that object (button1, button2, etc), and in each instance assign the proper image (contained in a mc) to the variable that is in the parent object.The problem I am having, is that I can't figure out how to make a variable that will reference a movieclip or graphic.[code]...

View 4 Replies


Similar Posts:


ActionScript 1/2 :: Variable References To Objects?

Aug 30, 2010

I've got a 15x3 grid of dynamic text fields in an object called "textbox" that I want to reference through a for loop, so I don't have to have 45 lines of code for assigning stuff to those fields.I have each dynamic field named by their placement in the grid, so, c0a, c0b, c0c, c1a, c1b, c1c, etc.I can also name them c00, c01, c02, if necessary.
 
I tried:
 
for (i=0; i<15; i++) {
textbox.c[i]a.text = "Cell " + i + " A";
textbox.c[i]b.text = "Cell " + i + " B";
textbox.c[i]c.text = "Cell " + i + " C";
}
 
but that gives me a syntax error.I also tried naming them c00, c01, c02, c10, c11, c12, etc., so I could do a double nested loop:
 
for (i=0; i<15; i++) {
for (n=0; n<3; n++) {
textbox.c[i][n].text = "Cell " + i + n;
}
}
 
but that gives me a syntax error too.So, is there a way to access all of these with a for loop, or am I going to have to do it the long way?

View 3 Replies

Flash8 :: Dynamically Create XML File References?

Jun 29, 2009

I need to create two combo boxes that are populated by an XML file. In the first combo box there are 13 choices and depending on what the user selects I need to populate the second combo box with the correct information. Now I can create the first combo box just fine but when I try to dynamically create the XML file name for the second combo box it doesn�t seem to work. What I am doing so far is taking the data from the first combo box and adding the quotes and .xml with this piece of code:

PHP Code:

pModCombo = '"'+event_obj.target.selectedItem.data+"Combo"+".xml"+'"';
pModComboXML = new XML();
pModComboXML.ignoreWhite = true;
pModComboXML.load(pModCombo);

If you trace that code it creates the file name just fine however the xml file will not load. If I replace that code with the normal xml code like this:

PHP Code:

pModComboXML = new XML();
pModComboXML.ignoreWhite = true;
pModComboXML.load("new.xml");

The second xml file seems to load just fine. However, if I create an if statement with all the different xml file names I will have to update the swf every time I add a new choice in the first combo box. So my question is does anyone know how to dynamically create the xml file name?

PHP Code:

pmComboXML = new XML();
pmComboXML.ignoreWhite = true;
pmComboXML.load("brands combo.xml");

[code]...

View 6 Replies

How To Create Variable That Contains MovieClip

Aug 8, 2009

I want to create several "buttons" (which are actually MovieClips) that are all identical apart from an image and the link. My thought was to create a movieclip button that contains a var that will represent a movieclip, then in each instance of the movieclip button set that variable to be the movieclip image that will correspond to the button.

Geez my query seems so simple until I try and put it into words...The gist of it is, how do I name a movie clip variable? Something like, in the main movieclip, instead of inserting a specific image into the movieclip, insert a variable named innerImage, then in each instance of that movieclip name the image to be inserted by specifying the variable

var innerImage:MovieClip = the movieclip I want for this instance.
If the var was a number, it would just be:
var innerImage:number = 4;
If the var was a string:
var innerImage:string = "word";
So for a movieclip:
var innerImage:MovieClip = ???

View 10 Replies

ActionScript 3.0 :: MovieClip References From A Class?

Jul 15, 2009

I have a files that has movie clips and nested movie clips on the stage. I am now writing a class and want to give the MCs event handlers and other properties.
 
When I do something like the following: myMC_mc.MyOtherMC_mc.mouseEnabled = false;
 
I get the error: 1120: Access of undefined property myMC_mc.
 
I added this to the top of my class and it seems to take away the error, but I thought this was not needed in AS3 anymore.

private var myMC_mc:MovieClip;
private var myMC_mc.MyOtherMC_mc:MovieClip;
 
What do I have to do to not get the error? How is this done right?

View 3 Replies

ActionScript 3.0 :: Movieclip References In An Array

Feb 27, 2011

I have a movie clip in which I have a number of sub movieclips. The number of sub movieclips can vary, so I would like to keep track of them in an array. I am doing that like so:[code]The trace seems fine, showing the names of the correct sub movieclips, but when I try to change the alpha I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 3 Replies

Flash - MovieClip References Going Awry In OnLoadComplete Callback

Mar 9, 2010

I'm loading a bunch of images into my AS2 flash movie, and I've encountered some strangeness.

Roughly, my code looks like this:

function doTheLoading()
{
m_imageClips = [];

[Code].....

why does my array content seem to change when in the onLoadComplete call? If the array is out of scope, then why can I still see the length of the array and determine the type of the contents?

View 1 Replies

ActionScript 2.0 :: Create One Or Several Instances Of A Movieclip From The Library With Variable Names?

Feb 16, 2011

Is it possible to create one or several instances of a movieclip from the library with variable names

my1_mc
my2 _mc
.........
my5_mc

so that I can make a function that will use the name of any of these movieclips.

View 4 Replies

ActionScript 3.0 :: AddEventListener Function References Child In Movieclip. How Do I Stop This?

Jun 28, 2010

I built a custom designed checkBox. The movieclip is in the libary and dragged onto the timeline of my .swf. I'm using CS4 & AS3. I'm using procedural AS3 instead of OO AS3.The checkbox movieclip has a child movieclip inside of it so I can apply a drop shadow filter to some of the graphics .When I put an eventlistener on the custom checkbox it works fine but when I try to reference the checkbox movieclip inside the eventlistener function, the event.target.name is referring to the child movieclip (just a graphic with a drop shadow filter).From my reading it looks like the function propogates down to the child movieclip but I don't want it to do that.How do I reference the parent movieclip? or

B. stop the eventlistener from propogating down to the child movieclip?

I tried using stopPropagation(); but it didn't stop the function event.target.name from trickling down to the child movieclip.Here's what AS3 looks like.The trace statement displays "step3_mc.cbEmail_mc.instance25"instead of what I need "step3_mc.cbEmail_mc"

step3_mc.cbEmail_mc.addEventListener(MouseEvent.CLICK, fnc_cbClick);step3_mc.cbAgree_mc.addEventListener(MouseEvent.CLICK, fnc_cbClick);
function fnc_cbClick(event:MouseEvent):void  {[code]....

View 2 Replies

ActionScript 2.0 :: Create A String Variable...and Then Use The Value Of That Variable To Declare Another Variable?

Jan 3, 2006

f you know PHP...then you know that you can create a string variable...and then use the value of that variable to declare another variable. like this:

PHP Code:

<?php$foo = "haha";$i{$foo} = "success";print $i{haha};?>

and it would display "success"...or like this:

PHP Code:

<?php$foo = "haha";$$foo = "success";print $haha;?>

and it would also display "success".

View 6 Replies

ActionScript 2.0 :: Create Variable Names Using My Percentage Variable?

Dec 4, 2005

I'm currently working on an advanced preloader and i'm creating loads of different variables etc. based on the percentage loaded. I need the variables to be named Number + percentage, so in the end I will have Number1, Number2, Number3, Number4 etc. How can I create variable names using my percentage variable? Can't seem to find anything that answers my question.

View 2 Replies

ActionScript 3.0 :: Create A Variable And Get The Button To Add One To That Variable?

Jan 28, 2010

I want to be able to have a number displayed on the screen that when one of the arrows next to it (up/down) is clicked it adds 1 to the original number (lets say 72). Then when they click the "save" button that really just takes them to the next frame (or a frame somewhere else in the movie), which is a confirmation page, I want the number they ended at to display on the confirmation screen.
I'm thinking that it is partially because I don't know what to search for.I know I have to create a variable and get the button to add one to that variable.

View 2 Replies

ActionScript 2.0 :: Flash8 Variable Set-up - 'if' Statement To Run From Variable When Playhead Encounters MovieClip

Aug 21, 2009

I want to declare a variable on the main timeline that can be called from anywhere in my movie. So, _global var should be the right approach. I want to declare a movie clip 'MC1' "open", or "closed" so that when it is revisited, my flash file knows the user has been there before and performs a different task from the one it does when 'MC1' was first encountered. So, i need a 'if' statement to run from the variable, when the playhead encounters the movieClip.

[Code]..

View 2 Replies

ActionScript 3.0 :: Change String Variable To A MovieClip Variable?

Oct 10, 2008

I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.When I trace "drawingCanvas" I get object drawClass] which is fine. Tracing drawingCanvas.name gets me the instance name 'drawingCanvas'.This is a String variable.Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.

The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).

View 9 Replies

ActionScript 3.0 :: Create Variable Without Variable?

Feb 24, 2010

I have a [code]...

in the end of code i have 2 variables 'iconFace' and 'splice'.This variables without var.. so first question this is ok practice?

Second question: maybe need create 2 classes for this variables? and in class declare variable?

View 8 Replies

ActionScript 3.0 :: Movieclip Inside Movieclip Variable Not Defined

May 17, 2011

I am brand new to AS3 and just about muddled through with AS2. I have a problem which should have a simple solution but everything I try gives errors.I had a load of buttons on the main timline which worked fine. I have moved a load of them into another movieclip called flyoutMenu. Now none work and I get the error:Error #1065: Variable about is not defined.This is the code stripped down to one button:[code]

View 2 Replies

ActionScript 3.0 :: MovieClip Accessing A Variable That Is In A Function Outside Of The Movieclip

Dec 8, 2010

I am trying to access the variable myParentVariable within the function myParentFunction() from the MovieClip's myMovieClip_mc function myMovieClipFunction().
 
I know that It works if I declare the variable myParentVariable outside of the myParentFunction() but I don't really want to do that

main timeline
//-------------------------------------------------------------------- ---
myParentFunction();
function myParentFunction():void

[Code]....

View 1 Replies

Use A Variable And Then AddChild With A RemoveChild For The Old MovieClip After The New MovieClip Has Loaded

Mar 30, 2009

This is something I'm experimenting with, but haven't seemed to figure out... I have several MovieClips, basically the same, only different colors. As each one plays, I'd like it to "overlap" whichever one is already there. Right now I have each button linked to a gotoAndPlay function, but I don't think that will ever get me what I want. You can see how I have it now here: [URL]

Instead of having the content MovieClip go back to all white when a button is clicked, I'd like the preivious one to remain, and get "covered up" by the new one. You continue to see the old color, and the new color overlaps it. I have a feeling I need to use a variable and then addChild, with a removeChild for the old MovieClip after the new MovieClip has loaded, but I'm not getting any good results yet.

View 1 Replies

ActionScript 2.0 :: Send The Variable X To Each Movieclip So That It Can Be Called From Within Each Movieclip Instead?

Aug 1, 2005

I have a loop that creates movie clips where the movie clips are named mc_+ x for say x = 1 to 10 so the movieclips are called mc_1, mc_2.....mc_10.

What I need to do is the know which one of the movieclips is clicked on but more importantly the number i.e if movieclip mc_2 is clicked on then I need to use the value 2.

At the moment I am sending the value of x to be displayed in a text box within each movieclip:

_root.search.textfield.text = x;

Then I have a piece of actionscript that uses the value of x but I don't seem to be able to "re-read" the value of x back with:

var t = _root.search.textfield.text;

what I want is t = x is it to do with strings and number variables?is it possible to send the variable x to each movieclip so that it can be called from within each movieclip instead?

View 1 Replies

ActionScript 3.0 :: Create A New Movieclip For Each Top-level XML Node And Include In The Movieclip Two Separate Textfields?

Jun 4, 2009

My goal with this actionscript is to create a new movieclip for each top-level XML node and include in the movieclip two separate textfields, an image, extend the movieclips to two row if necessary, rotate each movieclip differently depending its parity and add a hover event based on the movieclips instance name. I have achieved each goal except for the hover bit. The reason I cant access the instance name outside of the for loop is because the instance name only lasts for duration of the loop. Here is my current code (at pastie address).

[URL]

View 3 Replies

ActionScript 2.0 :: HitTest And Positioning - Create An Invisible Movieclip That Has The Exact Size And Shape Of The Animated Movieclip

Aug 23, 2005

This is the third thread I've written for my current project (1st was answered perfectly, 2nd failed [but I still figured it out anyways]) but I'm not sure if there is a solution to this problem. I can't really explain my problem, so once again I've included a helpful animation to show you what I mean. Bear in mind that the pale-blue box represents the movie clip's borders, and those borders are usually changed to include the animation (instead of the borders moving with the animation, the borders get bigger).

For the animation problem, I've already got a solution: create an invisible movie clip that has the exact size and shape of the animated movie clip and make it follow the movie clip as it animates, and make the hitTest check the invisible movie clip instead of the animated one. As for the rotation problem, well, I don't know how to fix it. Is there a way to change that?

View 1 Replies

IDE :: Can't Create A Variable

Jul 28, 2009

I'm trying to declare a new variable within it, but its not working... When I list the variables after, they have not been added?

[AS]var curDepth:Number = 0;
var someNumber:Number = 9;
function makeImage(){

[code]...

View 2 Replies

ActionScript 3.0 :: Can't Create A Movieclip Inside A Movieclip

Feb 23, 2012

I am not able to create a empty movie clip inside a empty movieClip.
 
Here the code..
 
var photoHolder:MovieClip=new MovieClip();
addChild(photoHolder);
var photo:MovieClip=new MovieClip();

[Code]....

View 9 Replies

ActionScript 3.0 :: Can't Create A Movieclip Inside A Movieclip?

Feb 23, 2012

I am not able to create a empty movie clip inside a empty movieClip.Here the code..

var photoHolder:MovieClip=new MovieClip();
addChild(photoHolder);
var photo:MovieClip=new MovieClip();[code].....

View 6 Replies

ActionScript 2.0 :: Create A Button Within A Movieclip Instead Of Just Having A Movieclip?

Feb 27, 2006

Why would you create a button within a movieclip instead of just having a movieclip? Does the 2 different types give you more scripting options?

View 1 Replies

Actionscript 3 :: Way To Map Object ID References?

Nov 4, 2010

I'm writing an application where I have many objects (data models) that are identified by a unique String ID that every such object possesses and these objects can refer to each other by their IDs.So far so good but now I need to keep track of which object keeps a reference to another object and of course there are cases where an object references (or is referenced by) more than one other object and I was wondering what would be the best method to store these references? In a simple map data structure I could just map one object's ID to another but as mentioned there are cases where an object can hold a ref to an arbitrary amount of other objects

View 1 Replies

C++ :: Why Some 'Types' Are References While Some Are 'Primitives'

Mar 19, 2012

Types like Movieclip , String, Object act as references when declared and defined, while types like int, Number are primitives. Why such difference has been made. Why not all of them can be primitives ?

View 1 Replies

ActionScript 2.0 :: Multiple CSS References In One Tag?

Aug 15, 2009

I'm using the CSS object (TextField.StyleSheet) to format my dynamic text, which is loaded from an XML doc. I tried referencing more than one class, like <span class="body bluetext">. However, it doesn't seem to work because it ignores the first syle(s) and only applies the last one in the list. I'm guessing Flash doesn't support this (since they're CSS support is already very weak). Just want to make sure I'm not doing something wrong.

View 0 Replies

ActionScript 3.0 :: Create A Variable With A Function?

Jun 30, 2010

Is it possible to create variables with a function? I don't mean create my own variable in a function but actually have the function create a unique variable name (eg. exam1, exam2 and so on) they would all have the same data type.

View 1 Replies

ActionScript 1/2 :: Randomly Create Variable From XML?

Dec 13, 2010

I want to create random objects on to the stage through and xml.
 
If u refer the image attached. each circle represents a data from the XML.

i want these to get generated on to the screen randomly with easing animation.
 
note: circles should have random 3-4 colors as mentioned.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved