ActionScript 3.0 :: Referencing Movieclip In Game

Sep 20, 2009

var xBoard:Number = Math.floor(mouseX/cellSize);
var yBoard:Number = Math.floor(mouseY/cellSize);
if (board[(yBoard-1)][xBoard] == 0)
{
root.getChildByName("b"+(yBoard-1)+xBoard).alpha = .7;
}

I want to be able to call various movieclips I have arranged in a grid from these two variables (xBoard and yBoard). They get new values every time I click on my gameboard.

Basically I check if they space ahead of the unit is empty. If it is I want the alpha of that space to change designating you can move there. The movieclips are arranged in a grid and named b00 (top left) to b77(bottom right).

This is the error message:

1061: Call to a possibly undefined method getChildByName through a reference with static type flash.displayisplayObject.

If I take out the getChildByName... root.("b"+(yBoard-1)+xBoard).alpha = .7;
This is the error message:

TypeError: Error #1123: Filter operator not supported on type Game_fla.MainTimeline.
at Game_fla::MainTimeline/test()

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Object Oriented Game - Referencing Dynamic Objects

Jun 26, 2009

I'm doing this object oriented game and I create a bunch of 'boxes' via a for loop

Code:
Select allfor (var z=0; z < numOfBoxes; z++){
var box:Object = new Object();
box.mc = new Box();
box.mc.name = "box"+z
box.mc.x = Math.round((Math.random()*(530-box.mc.width)) + 20);
for (var i=0; i<boxXArray.length; i++){
[Code] .....

I get my random amount of boxes scattered over my stage (I haven't put in any checks to see if they are touching). How do I 'name' these boxes so I can reference them later? Say I want to move the .x of boxA in another function? Is there a simple way to call them box+z instead of just all as box? (Then I can run them through a loop later to talk to them).

View 2 Replies

ActionScript 2.0 :: Referencing A Movieclip Within An Attached Movieclip?

Nov 29, 2006

I am trying to reference a movieclip within a movieclip that I am loading using "attachmovie". In the first frame of the root, I am attaching the movie. Then, from the attached movie I am calling a function that is also in the first frame of the root. In the function I am tring to set the property of a clip within the attached movie to visible using the following code:

_root.logIn.loginMessage._visible = true;

I have also tried _root["logIn"].loginMessage._visible = true; with no luck.

(logIn is the name of the clip I am attaching using attachMovie and loginMessage is the clip I am trying to reference in the attached movie)

This is how I'm loading it and I know that part is working: _root.attachMovie("login_mc","logIn",getNextHighes tDepth());

View 1 Replies

ActionScript 2.0 :: Referencing A Movieclip Within A Movieclip

Jul 26, 2004

If I have movieclip named box01_mc inside movieclip btn01_mc and I wanted to change box01_mc's alpha to 0 on the rollover of btn01_mc how would I write this? I tried writing the following code on btn01_mc but it didn't work:[code]

View 6 Replies

ActionScript 2.0 :: F8 - Referencing MovieClip After Attaching It

Feb 17, 2009

I'm having issues trying to reference a movieClip after attaching it. What I have is:
Code:
btn_instructions.onRelease = function() {
instructions = true;
attachMovie("parchment", "mc_parchment", getNextHighestDepth(), { _x:280, _y:280 });
} mc_parchment.btn_close.onRelease = function() {
instructions = false;
trace("close");
removeMovieClip(mc_parchment);
}

The first is creating it on top of the other items that are created during the game. I can't have the instructions on the timeline and just change the visibility of it due to all the assets this game is making. The instructions variable is used in an if statement elsewhere in the game to lock the user controls so they can't create anything else in the game while your viewing the instructions. The second function is the one that should close it. The movie clip that's attached has a button in it, with the instance name btn_close. The trace doesn't even pop up so it's not targeting it correctly. Yet when I go to 'debug' and 'list objects' both mc_parchment and mc_parchment.btn_close are listed as being in the scene after clicking the instructions button.

View 2 Replies

ActionScript 3.0 :: XML Node Referencing A MovieClip

Aug 28, 2009

Is it possible to make a reference to a MovieClip in an XML object. It doesn't seem to be working with this code.[code]

View 2 Replies

Data Integration :: Referencing What Is In A Movieclip

Mar 11, 2007

I am calling an image from a server to be displayed in flash using php, mySQL. If the image is in part of a browsing gallery where there are eight images on screen all in movieclips how do I get it so when a movieclip is clicked it recognises what image it contains and then goes to another frame where it can have just that one image?

View 1 Replies

ActionScript 3.0 :: Referencing MovieClip Within Another In Flash

Jul 15, 2010

I was creating a drap and drop simple game, dragging and dropping an item from within a movie clip. All was working fine, but then I had to add more items so I created a ScrollPane and referenced the movie clip through that, now I need to rework how I pull reference that movieclip again. The movieclip is exported so the scrollpane can bring it in...

package {
import flash.display.*;
import flash.geom.Point;
import flash.events.*;
public class shopping extends Sprite {
public function shopping() {
shoppinglist.Ketch.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
shoppinglist.Ketch.addEventListener(MouseEvent.MOUSE_UP, dropIt);
[Code] .....

View 1 Replies

ActionScript 3.0 :: Referencing Movieclip With String

Nov 9, 2009

Basically I'm trying to get a certain section to open when it's corresponding button is pushed The button has an instance name of "home" The section I need to be able to reference is labeled "home_mc"

[Code]...

My gut tells me the code should work, but every time it runs through, I get "Actionscript Error:#1065: Variable home_mc is not defined."

View 2 Replies

ActionScript 3.0 :: Referencing New MovieClip Into For Loop

Jan 17, 2010

Trying to convert a project from as2 to as3. Take this simple function:
Code:
function add_tf(contents:String,target_clr:uint,font_size:Number,a_type:Number,a_thickness:Number,a_sharpness:Number,target_width:Number, target_height:Number) {
var format:TextFormat=new TextFormat ;
var tf:TextField=new TextField ;
[Code] .....
How do I reference the newly created textfield into a for loop?

View 4 Replies

ActionScript 3.0 :: Referencing A MovieClip In It's Function

Aug 28, 2010

i was wondering how i would access the desired movieclip's x, and y value from it's function.[code]HOW do i access the x and y values of MC from here
like you would use "this._x" in AS2, how would i do that here?

View 1 Replies

ActionScript 2.0 :: Referencing A MovieClip With A Variable?

Oct 20, 2010

I'm trying to set something up that will print a bunch of boxes on a grid in a certain pattern, and set things up so that a path can be determined from the start to the end. Each grid square is a MovieClip with an instance name x0y0, x1y0, etc. for each coordinate of the grid. I want to set a variable in my grid square class to 1 or 0, depending on whether or not a box is in that square. So I have this code:

for(var j=0; j < row1.length; j++)
{
for(var i=0; i <= row1[j]; i++)

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing A Specific Movieclip

Apr 13, 2011

Suppose you have a movie clip called MC1 and it is on frame 20 of the stage in layer 3. How should I refer to this MC within actionscript? Can I only refer to this movie clip from frame 20?

View 1 Replies

ActionScript 3.0 :: Referencing Movieclip In Array

Jun 13, 2011

Just learning as3. For testing purposes, I duplicated a movieclip 4 times on the stage and gave each mc a different instance name and put them in an array ("line1","line2","line3","line4"). Then I just want one movieclip to move 200 pixels based on the conditions of the array. Here is the code:

var stuff:Array = new Array("line1","line2","line3","line4");
for(var i:int=0;i<stuff.length;i++)
{
if ((stuff[i]) == "line4") {
trace(stuff[i]);
var duke = (stuff[i]);
[duke]y += 200;
}
}

It traces out the correct mc (line4) but ALL the movieclips move 200 pixels instead of the one (line4). Do you know why this is? I have a feeling that [duke]y is not the correct way to reference the movieclip.

View 2 Replies

ActionScript 3.0 :: Referencing The Same MovieClip Repeatedly?

May 31, 2010

I'm trying to make a loader class that will spit back MovieClip data from the Loader. If another class/function requests the same data (Rather, the same file), rather than making a new loader and re-loading it, I was hoping to just have it return the same MovieClip. This all works to some extent, but the problem I'm having is this - Because the new request is adding the MovieClip, it's taking it away from the old one.

I tried making a copy when the request is made, but the image is generally not loaded then, and because the copies aren't updated, most of the images are empty when everything requests it.So basically what I'm hoping you can guide me towards is a sort of... C++ pointer-esque thing, something that could point to the MovieClip data without actually taking it away from everything else. I've messed with AS3 for a while, but can't find anything like that. Or any other method that would let multiple MovieClips reference a single "original" movie clip, reference-style.

View 2 Replies

ActionScript 3.0 :: Classes: Referencing Of A Movieclip Not Being Recognised?

Mar 12, 2010

I have a main .fla file that has a movieclip with an instance name level. Within this there is another movieclip called hero.I have a main class with the following function:Quote:

public function beginLevel() {
var cHero:Hero = new Hero;
createFunction1();

[code].....

View 2 Replies

ActionScript 3.0 :: Referencing MovieClip From Nested Stage

May 9, 2010

I am trying to reference a movieclip from the stage which is nested. I really have no idea how to do that.

View 5 Replies

ActionScript 1/2 :: Revisiting: Referencing A MovieClip Using A Variable?

Jun 15, 2009

This is a problem I thought I understood and was addressed in a previous thread [URL] but I have a new situation where the old solution isn't working.I have 3 instances on a "nested" movie clip. Their instance names are: b1, b2, and b3. When I trace these movieclips from the main timeline, I get:
 
trace(b1); // result = _level0.slide_mc.newMC.b1
trace(b2); // result = _level0.slide_mc.newMC.b2
trace(b2); // result = _level0.slide_mc.newMC.b3
 
From the main timeline, I want to fade up these movieclips using tween, but I need to do this by building the instance name in a variable:

var myInstance:String = "slide_mc.newMC.b"+ instanceNumber //(instanceNumber is equal to 1, 2, or 3)
 
Now, I thought using the variable in this manner would work:

new Tween (this[myInstance], "_alpha", None.easeNone, 0, 100, .5, true);

...but it doesn't.
 
I've checked trying to use the actual movie clip instance:

new Tween (this.slide_mc.newMC.b1, "_alpha", None.easeNone, 0, 100, .5, true);
 
...and it works fine.

View 2 Replies

ActionScript 1/2 :: Referencing Nested Parameter Movieclip?

Dec 1, 2009

on stage a movie clip instance name is: LetterCont
for (j=0; j<20; j++) { duplicateMovieClip("letterCont", "Letter"+j, j);}then...
_root["Letter"+j].attachMovie("libLetter"+ j,"let"+ j,j);

and now I want to refrence "let"+j

[Code]....

how should I reference "let"+j

View 1 Replies

ActionScript 2.0 :: Referencing A Movie Clip Within A Movieclip?

Jul 17, 2009

Maybe someone can shed some light on this issue for me. I have a main movie clip, call it Main, that loads external swf files during run time. One of these loaded swfs, or movie clip is called FOB. Inside FOB is another movie clip with a variable name of contentText. What I want to do is to adjust the x location of contentText from the Main movie clip.

Inside the Main movie clip I have this (entire code):

ActionScript Code:
//CREATE MOVIE CLIP CONTAINER
this.createEmptyMovieClip("FOB", _root.getNextHighestDepth());
this.createEmptyMovieClip("PirateClub", _root.getNextHighestDepth());

[Code]....

View 0 Replies

ActionScript 2.0 :: Referencing A Dynamic Movieclip (button)

Oct 15, 2009

how do I reference a button that has been loaded dynamically?Furthermore, is it possible to use the removeMovieClip() method with a button that is inside the movieClip you are trying to remove?Simply put, I've got a movieclip that is loaded via the "attachMovie" method. There is a button inside that says "Close". I am trying to use the removeMovieClip() method on that button, but it's not working. I can put a button on the stage, and use the same method, but it doesn't work.

View 4 Replies

ActionScript 2.0 :: Tweening With Dynamic Movieclip Referencing?

Oct 22, 2009

First of all: this is my first post at actionscript.org *happysound*. I'm working on this flash gallery since a couple of days and something is drinving me crazy in actionscript.

The concept: in this part of the flashfile i'm loading thumbnails in dynamicly created movieclips on stage (1.jpg, 2.jpg, 3.jpg). Everything is working fine, but now I wanted to add some fancy fading when the loading of a single thumb completes. For some reason I can not get the tweening class working and I'm sure it's a problem with the referencing to the clip. I know this cause when I change "thumb"+i to thumb1 it is working. Googled for hours without result..

[Code]...

View 5 Replies

ActionScript 3.0 :: Referencing Stage From Within MovieClip Or Class

Dec 9, 2009

I'd like to know how I can reference root stage values from within a movieclip, or even worse, from a class. For example, I have a class called Bground.as. It does stuff, according to current stage size - so if someone were to resize the window/browser, Background updates in real time and does something fancy while it's at it. To do this "fancyness", I need stageheight and stagewidth. However, simply pointing to them does not work.

Here's the simplified ActionScript Code:
package klaseFP{
// imports
import flash.events.*;
import flash.display.*;
public class Bground extends MovieClip{
[Code] .....

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at klaseFP::Bground()
at FullScreen_03_fla::MainTimeline/frame1()

Background works as a document class, works perfectly in fact. However, if I use it as the class of a library object, error 1009 shows up. Same thing happens if I simply put the code into the timeline of the library object - stage referencing simply causes it to break. So, how do I dynamically change the values of variables in Background, according to values in the main movie/app?

View 2 Replies

ActionScript 3.0 :: Referencing The Stage From A Child MovieClip

Dec 15, 2009

I feel like I should know this by now, but I'm having trouble. I want a function in one of my child functions to increment an integer in its parent function.

[Code]....

View 9 Replies

ActionScript 3.0 :: Referencing A MovieClip Based On Variables

Mar 15, 2012

I am having trouble referencing a MovieClip based on certain variables in my code. I am using Flash Player 9 as the player setting and ActionScript 3.

I have a symbol with a name "Check1" set as a MovieClip, exported for ActionScript, I have ten of these on the stage with an Instance Name of ch0, ch1, ch2...ch9.

Each ch? has 21 frames on the timeline, each with a label name (named with a Number reference "00", "32", etc...) and a different image in each keyframe.

What I would like to do based on these variables:

Code:
iTurn = 1;
iLeft = 3;
iRight = 2;

This is how I would like to use it:

Code:
Check1.ch[iTurn].gotoAndStop(iLeft+iRight);

//iLeft & iRight as a frame label and not a frame number, so in the case I would like to access framelabel "32" which is frame 10 on the timeline.

I have tried many way to try and make this work with no luck, the only way I have been able to make it work is by using:

Code:
ch1.gotoAndStop("32");

Doing this, I would have 10 clips, each with 21 possibilities. I can do this with many lines of code but I have been unable to tighten it into smaller code.

View 5 Replies

ActionScript 2.0 :: Referencing MovieClip Properties From An Array?

Mar 20, 2007

Code:
container_mc = _root.createEmptyMovieClip ("Page_Container_mc",100);
pageContent = new Array ();

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing Movieclip Created In Another Function?

Oct 14, 2009

wrote a couple of small games using AS 2.0. One of the things I found easiest about AS 2.0 is that a MovieClip created using _root. attachMovieClip() inside of one function was accessible to every other function. For instance:

Code:

function AddClip() {
TheClip = _root.attachMovie("Object", "TheClip"+ClipCount, _root.getNextHighestDepth(), {_x:30, _y:30})
}[code]....

This causes an error, because the MovieClip variable was declared inside of a function and when the function ended, the MovieClip variable was erased. Is there any way of doing this without declaring the MovieClip variable outside of the function? I want to be able to create an unknown amount of these movieclips on the fly, so I can't just declare them outside of the function.

View 9 Replies

ActionScript 3.0 :: Dynamic Referencing Of Items Within MovieClip?

Feb 19, 2010

I am building a drag and drop application. I have a few items within a movie clip that are movie clips. They each have their own instance name.

I am trying to access them from the document class using 'event.target.name'.

That works and I can pick up the name of the movieclip.

I put it in a string var called tName.

Then I try to modify a property of the selected movieclip:

itemList.items.tName.x+=23;

thats when i get, 'A term is undefined and has no properties' error.

I know itemList.items.tName is the correct navigation to the clip, because if i replace the var and hard code the correct name, it works.

whats funny is my tName var is tracing out the correct name of the movieclip.

Or a better way to dynamically access mc's within mc's.

View 1 Replies

ActionScript 3.0 :: Flash Referencing MovieClip Within Several After Getting Parent?

Feb 13, 2011

I have this MC attached to the stage with an instance of say: insA, then within this I have another called say: insB, then finally another one within insB called say: insC.so normally to access the third one I would use: insA.insB.insC do something.I have this button within another MC called say: '2ndinsA', so when a button within '2ndinsA' is pressed I need to perform 'something/move' onto insC.

Now within the class attached to '2ndinsA' i have the parent.getChildByName("insA") code and its seemed to grab the 'insA' and I could then move it, but its the insC that i want to move.How can I then reference the 'insC' within that MC )'insA', i have tried several ways but all come up short (errors galore)

View 2 Replies

ActionScript 3.0 :: Referencing Class Variables For A Movieclip?

Dec 5, 2011

Hey guys. It's been a while since I've used Flash and I am still trying to wrap my head around Actionscript 3.0 and the way it works; I am so used to the way AS2 works.I have provided the code below, it's very simple, so you might be able to skip this explanation and just take a look at the error and the code:

- I have made a movieclip called HeroMC in my FLA.

- The HeroMC movieclip has the AS Class linkage of exactly the same name, "HeroMC".

- I have made an actionscript class file, HeroMC.as, to house specific variables for my hero; such as Name, Age, xPos and yPos.

- I have also made an actionscript class file, Main.as, the document class for this FLA.

- In Main.as I instantiate HeroMC using the variable hero, and then run the function addHero() from my constructor.

- addHero() is a simple stage.addChild(hero);

This all works perfectly fine and it adds my hero to the stage. However, the problem arises whenever I try to reference one of the variables from HeroMC.as. I am met with this error - I will use the variable xPos as an example.

Here is the error:

1119: Access of possibly undefined property xPos through a reference with static type HeroMC.

Here is the code for Main.as:

Code:
package {
import flash.display.*;
import flash.events.*;

[code]....

It is obvious this is a very simple problem, but I have searched Google, Kirupa and Flashkit for an answer, but none of the threads I find discuss my specific circumstances and I am unable to find the specific information I need to.

View 3 Replies







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