ActionScript 3.0 :: XML Node Referencing A MovieClip
Aug 28, 2009Is 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 RepliesIs 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 RepliesMy 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]
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());
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 RepliesI have an xml document that I would like to use to show MovieClips in my .fla:
<linkedMovieClip>TestClip</linkedMovieClip>
In my .fla, I created a symbol called TestClip and select Linkage > Export for Actionscript and named it TestClip.
My code in my Document class traces the xml:
var t:*= getDefinitionByName(String(slideItem.linkedMovieClip)) as Class;
var linked:MovieClip = new t();
trace("linked is..."+ linked); // outputs [Object TestClip];
[Code]....
However, I am still getting an error message. When I check the debugger it's from this line:
var t:*= getDefinitionByName(String(slideItem.linkedMovieClip)) as Class;
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.
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()
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 RepliesI 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] .....
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."
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?
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?
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].....
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 RepliesJust 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.
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.
I have an AdvancedDataGrid tree with a ArrayCollection as its dataprovider. Now, for instance, i drag a leaf from one node to another node. To catch the event I'm adding a Listener to dragComplete.
[Code]...
My Problem: I want to know the new node where the leaf was dropped. Actually i would have expected that in the event there is a property like dropParent. This is not the case.
Im trying to build a script that attaches and positions an instance of a movieclip for each node of an xml sheet. However, I can't seem to get it to loop properly. The script is simply attaching and positioning the movieclip according to the last node in the xml file. Here is my script:
Code:
var myXML:XML = new XML();
myXML.ignoreWhite=true;
myXML.load("map.xml");
[code]....
I have a tree im my mxml that uses a XMLListCollection as dataProvider. Itīs XML is like:
<list>
<conta nome="Plano de Contas" id="1">
<conta nome="Creditos" id="2" />
<conta nome="Vendas" id="4" />
[code]....
How can I make the node for, say, id==4 visible AND selected?
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].....
I am trying to reference a movieclip from the stage which is nested. I really have no idea how to do that.
View 5 RepliesThis 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.
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
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]....
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 RepliesFirst 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]...
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?
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]....
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.
Code:
container_mc = _root.createEmptyMovieClip ("Page_Container_mc",100);
pageContent = new Array ();
[code].....