ActionScript 3.0 :: Access To Variables By A MovieClip In A MovieClip
Jul 15, 2010
I'm making a fighting game and so far all the controls are good, characters can walk, run attack etc. My problem: The character is a MovieClip, Guy, and is exported to a class Guy. In Guy.as I have a boolean "hitting" which is set to default "false". If the Guy object hitTests an enemy while "hitting" is true, the enemy will take tamage.
In the Guy MovieClip there are about 7 frames, each with its own animation. 3 of those frames are attacking animations in form of MovieClips, i.e, if we click them we get another set of frames. Say one of the attack MovieClips has 10 frames in it, frame 7 of 10 is where the punch actually lands, this is when I want the enemy to take damage, not before (while the character is still moving his hand forward). Seeing as this frame is inside a MovieClip which is inside another MovieClip(Guy), is there a way to access the property "hitting" with this inner frame?
View 4 Replies
Similar Posts:
Jun 10, 2010
I have 2 MovieClips, each with code on their timelines (I don't know if this is frowned upon).One of the MovieClips moves constantly in a biased random walk, influenced by a variable in its personal code. The other MovieClip has no specific instances, because it appears on mouse click, expands, then disappears after a certain amount of time.
I would like to change the value of a variable on the timeline of the first MovieClip, so it is more likely to turn when it hits the expanding circle. (Eventually influenced by the alpha of the circle, but just any effect is fine for now). My problem is that I can not access the variable from the main timeline or the circle's timeline, and all collision actions that I try end with error 1067, because I have not imported all of the necessary MovieClips and variables.[code]...
View 7 Replies
Mar 21, 2011
I have a movie clip of an explosion which is done in code because I am randomizing the direction and amount of debris from the explosion, so it's a movie clip with one frame, and all animation is done in code. Problem is, I'm trying to pause the game from the main timeline when the player presses "p". Right now I have it so it turns the variable gamePaused = true and calls the function pauseGame() which stops everything else. However I don't know how to access the variable gamePaused from inside the explosion movie clip's code. If I can somehow check that variable in the movie clip, I can pause that animation until the player presses "p" again.
So basically, how do I access a variable in the main timeline from a movie clip?
Also just to point out, all of these explosions were created as Sprites in the main timeline's code, any solutions I have found online didn't like that. So just keep that in mind.
Here's the main timeline code:
//This Creates An Explosion<br>
function createExplosion(explosionX, explosionY, explosionSize):void{<br>
//This Creates The Explosion Movie Clip
var explosionSprite:Sprite = new Sprite;
[Code]....
View 1 Replies
Oct 20, 2010
After I've created a movieclip, how do you create a variable from the main timeline in that movieclip? I thought I could do either of these:
ActionScript Code:
spy1.speedMax = 7;
// or:
with (spy1) {
var speedMax:Number = 7;
}
By tracing speedMax, I found it was available on the main timeline, but not in an event listener
ActionScript Code:
function OEF(event.EVT):void {
trace(event.target.speedMax);
}
These two methods are available in AS2...
View 2 Replies
Aug 17, 2010
I have attached the actionscript file on stage, however I can't access function or variables inside movieclip. Instead I can access them on main timeline, is there a way to access function and variables inside movieclip
View 2 Replies
Feb 1, 2010
In AS3, how can you access a relative variable within a specific movieclip on the stage?I have a test file that changes the variable "myVar" in one of the displayobject movieclips drawn on the stage. I want to simply trace the current value of this displayobject's myVar for additional purposes.In AS2, you would achieve this by calling the instance name and then the variable contained within.Assuming 3 movieclips existed on the stage named Container1¯, Container2¯ and Cotainer3¯trace(_root.myContainer2.myVar);// returns Hello which is value of variable "myVar" within the movieclip instance named "Container2".How would you do this in AS3?[code]
View 6 Replies
Oct 16, 2011
what I'm trying to do is accessingsnapText = scrollPane.source.textSnapshot;from an external swf. I've tried:
trace("-->: "+scrollPane.source.textSnapshot.getText(0, 1000));
trace("-->: "+myLoader.content.textSnapshot.getText(0, 1000));
trace("-->: "+mc.textSnapshot.getText(0, 1000));
[code].....
View 3 Replies
May 16, 2009
how I access variables in a frame on the stage with code from a frame within a movieclip?(basically passing variables from a stage frame to a movieclip frame)
View 4 Replies
Mar 6, 2012
Working on an RPG type flash, and I have to be able to control a text-box from quite a few locations. The one that is causing me trouble is the inventory. I need to be able to access the textbox with an instance of "statusWindow" from within the inventory clip (instance name "inventory"), so when I mouse over an item within the movieclip it will change the status window on the stage.In this instance I want to mouse over inventory.invHealth from the main timeline to get the display.itemName and itemProps are strings containing information about the item.I tried the following but it gave me a "possibly undefined" error.
invHealth.addEventListener(MouseEvent.MOUSE_OVER, itemStats);
function itemStats(e:Event):void
{
root.statusWindow.text = itemName+"
"+itemProps;
}
View 1 Replies
May 28, 2011
how can i access a movieclip via its instance name in another Movieclip class?
and a nother question how can i access a movieclip via its class name in another movieclip class?
BTW i want to access the movieclip child
View 4 Replies
Aug 13, 2009
I've got a dozen movie clips on stage, each with 3 children, and each of those have 8 children, as example named u01-u08.
Is it possible to access u01 directly without the parent names? like a wildcard? like the xml way of getting to nodes with a .. ?
sort of like: stage..u01.alpha = .5;
View 10 Replies
May 9, 2010
I want to access the properties of movieclips inside a movieclip.
Below is a code of how the Parent mc is created. It's looped because it's gets it data from XML. So there is not one parent movieclip but a number of parent movieclips depending on how many items the XML contains:
Code:
function doComplete(e:Event):void {
//create a new variable to store an instance of the XML class. We pass through the data from the XML file.
var xml:XML = new XML(e.target.data);
[Code]....
View 2 Replies
May 27, 2010
I have this variables in my movieClip
Code:
onClipEvent (load) {
myVar1 = 200;
myVar2 = 100;
[code]....
Even i click the button it doesn't add variables inside the Movieclip I tried it outside the movie clip and it works.
View 2 Replies
Dec 28, 2010
I'm trying to get a variables out of my movieClip. I just to work in AS2.
I have made a movieclip in the library and used the Linkage to make it available via script. Then I put it on stage using:
var mc_defaultefault = new Default;
stage.addChild(mc_default);
Inside the movieClip (named Default) on frame 1 layer 1 I declare a varaible:
[Code].....
View 4 Replies
May 28, 2010
It seems that my code is problematic, because I assign one instance of a MovieClip to several variables, type MovieClip. The behaviour of others of my codes makes me think, that ActionScript does not make copies of the instance, but references all variables to this single instance. This behaviour now causes trouble.The solution I consider now, is to create copies of the MovieClip and assign them to my variables. Is there any code to copy a MovieClip?
View 8 Replies
Jun 5, 2011
when i didnt use classes, i could easy attach my custom variables to movieclips using this code;movieclip.customvariable = value;but now I am working with classes, and it isnt possible anymore.I am trying to attach variables chip and sensor to the child like this: [eiland1 is the movieclip]eiland1.chip=1;eiland1.sensor=teller1;but then I get this error:1119: Access of possibly undefined property chip through a reference with static type Eiland.the same goes for the sensor variable.
View 13 Replies
Dec 8, 2009
I have loaded an external .swf and into a movieclip, now I am trying to trace all the existing variables.so far I have
Code:
stage.addChild(loader);
var myswf:MovieClip = e.target.content;
[code]........
View 8 Replies
Jan 14, 2006
I'm having some trouble trying to duplicate movieclips randomly. I have created an array with the instance names of the MCs i have on stage. Then I'm trying to create a variable that selects one random element from the array. Finally I want to use that variable as a target to duplicate my movie Clips... but it doesn't work.
Here is the code:
Code:
var Items = new Array('bombon', 'regalo', 'corazon');
pos = new Object();
pos._x=random(550);
[Code]....
View 5 Replies
Mar 5, 2009
I have a question: I want to duplicate a movieclip 10 times, with different variable names. So they are named: Main1, Main2, Main3, etc
View 1 Replies
Jun 26, 2010
Duplicate MovieClip by variables?This time I haven't been able to find anything already posted.[code]...
View 3 Replies
Feb 3, 2010
I have a button inside a MovieClip (instance name: bt_fechar) and I want to refer to it from the main timeline (that's where I want to keep most of the code). It returns the following output error message: "Error #1065: Variable bt_fechar is not defined"
Heres the code:
function retirarCiclo(event:MouseEvent):void
{
[code].....
View 1 Replies
Jul 21, 2010
How is it possible to access another movieclip inside a movieclip, if you have it linked to a class in the properties?
like
Code:
function rotateSubclip_():Void
{
this.subclip._rotation += 1;
[Code]....
View 6 Replies
Mar 10, 2011
Trying to develop a Monopoly in Flash/as3, I'm now displaying the properties of each player. When a user clicks on the userpanel, a "popup" appears, in wich all cards are displayed with an alpha = 0. My idea is to set the alpha at 1 for all the properties owned by the targeted user.
So, I have a panel called "panelCards", containing movieclips called "property1", "property2", "property3", ... In my code, an object Player has an array "pProperty", wich contains strings referring to every properties owned. I try to access the moviclips using these strings :
[Code]....
Obviously, it doesn't work. Is there a function wich allows me accessing those movieclips with the string reference?
View 2 Replies
Jun 2, 2010
I want to access a MovieClip in another scene than I'm currently in.
More specific I want to set a TextField to a certain value from a "preloader"-scene. This is for handling totally dynamic language phrases. Maybe this is the wrong way.
I'm loading a XML with language phrases that I want to replace the textfields with.
We could do this by altering all MovieClips, but I think this could be a smart solution, if it's possible! :)
View 1 Replies
Dec 17, 2010
Can't access in other movieclips for example I have my sections "home", "about", "contact" and the labels in the sections When I go inside about and call the contact section to set the text for example _parent.instancename(contact).title.text = "TEST"; this I call inside the about section but doesn't work!
View 2 Replies
Aug 20, 2009
is there a way to access the maintimeline from within a movieclip?
root. doesnt seem to work
View 7 Replies
Oct 13, 2009
Currently I found this code and adapted it to my document
Code:
var myLoader:Loader = new Loader();
var myUrlReq:URLRequest = new URLRequest("web11.swf");
myLoader.load(myUrlReq);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
[code]....
This works if I wanted to load the class "Buttongroup" but I want to load the movieClip 'clipHolder' which is a new instance of buttonclass (with functions applied to it)
View 2 Replies
Mar 18, 2011
I have a main.fla that contains say 1_mc and a 2_mc.
a1_mc has a button, which when clicked runs a function called say clickedButton.
a2_mc has a marker_mc inside it.
When the clickedButton function runs inside a1_mc, I want the slider_mc to go y=20
I know I can access main.fla timeline by
Code:
MovieClip(parent).gotoAndStop("nameOfLabel");
I tried
Code:
MovieClip(parent).a2_mc.marker_mc.y = 20;
but it doesn't work
View 3 Replies
Aug 1, 2009
Basically I have a SWF file, there is a movieclip in this SWF file with instance name "stage" and I can alter the parameters of "_level0.stage" from within this SWF file to change the way it acts. But now, I am making a second SWF file, which loads the first SWF file, and from this new SWF file I want to interact with the same "_level0.stage" variable from the first SWF, does that make sense? This is the AS3 code for the second SWF, I have a movie clip with instance name "LoadSWF" in this SWF.
Code:
var movieLoader:Loader = new Loader();
var movieRequest:URLRequest = new URLRequest("load.swf");
movieLoader.load(movieRequest);
LoadSWF.addChild(movieLoader);
load.swf is the file which contains movie clip "_level0.stage"
I've tried referencing this movie clip from this code using
"_level0.LoadSWF.stage"
but it doesn't find it?
View 1 Replies
Mar 3, 2009
On my main timeline I define a variable and it works:
var totalpages:Number = 1;
trace(totalpages);
In a child movie clip I try to recall the variable and it
traces "undefined":
trace(MovieClip(parent).totalpages); or trace(totalpages);
they don't work.
View 5 Replies