ActionScript 2.0 :: Access The Variables Of External SWF?
Jun 23, 2008
I have an MovieClip on Stage with instance name main_mc. I am loading an external game.swf in that main_mc. I want to access variables of root through game.swf. I have used loadMovie() to load the external swf.
I'm working on a game. Yep. I have the main class where I control all the stuff that's packed in external classes. My current issue is that I listen for a mouse event to happen, and when the left button is pressed, I add a child to the stage.[code]...
However, I want to set all the stats of the bullet in an external class called "Rock". In the main class I just attach a movieclip to the stage, and the behavior of this MC is supposed to be controlled by the Rock class. The problem is I dont know how to access the bullet variable from the Rock class.
I am trying to access a function in a loaded swf that has external class.. I would like to avoid having to put the function on my "Main" Doc class in the external swf and instead access the function directly from the class
This is what ive tried so far and it's a no dice:
private function startLoad(){ var loader:Loader = new Loader(); var req:URLRequest = new URLRequest("one.swf");
The error is as follows:1119: Access of possibly undefined property shiftX through a reference with static type flash.displayisplayObject.shiftX is declared in the first line of the movie clipFirst i check to see if the child doesnt exist and if it does I access it like so:getChildByName("ball"+ccc2).shiftX)
Here is a simple example: Code: <? session_start(); if(!isset($_SESSION["intro"]) { $_SESSION["intro"] = 0; } // has the intro been played? // code for including the swf ?>
ActionScript Code: if(intro == 0){ myclip.gotoAndPlay(2); // play intro intro = 1; }else{ myclip.gotoAndPlay(24); } // skip the intro and go straight to the end
I use flashIDE(CS5) to create and organize my assets for flash game. Some movieclips need to have specific params.I am typing them at a MC's first frame:
var shape :String= "circle"; var material :String = "wood";
And then make them Export as MovieClip.For AS3 coding I use Flash Builder 4. When I create new Instance of this MC and trace values I get "null". But if before trace gotoAndStop(1); typed then my values are ok ("wood", "circle").
What I am trying to do is pull data from an XML file so that I can store paramaters for my FLV player (i.e. flv link, dimensions, video name, etc) I can get the data from the XML file and story it in a dictionary but I am unable to access the data from my main class. I know it has to be something pretty simple but I think i have been looking at it to long to see it.
// Main.as package includes.action{ import fl.video.FLVPlayback; import flash.display.*; import flash.events.*; import flash.net.URLLoader; import flash.utils.Dictionary; import includes.action.XMLData; public class Main extends Sprite[code]..........
basically with all my traces this is what I get back...
// Trace dataVIDOEXML COUNT: undefinedELEMENTS: nullMAIN:LINK: nullWe are in LoadXMLname - no get: mortgagename - get: mortgage
The trace for Elements and Main:Link should give me back the name of the video but as of yet its either returning NULL or undefined.
I'm new to actionscript 3 and I'm trying to get a few simple things going, such as setting variables in other movieclips... So let's say I have an "apple" movieclip on the root/stage, and I want to access other variables on the root, or in other movieclips. How would I do that? In actionscript 2, I would use something like
_root.thisVar = 1; _parent.thisVar = 1; and with other movie clips I would use
I have a couple of textfields on my stage named "turist_box_inf" and "hotell_box_inf" (a couple more to come). These are located in a mc with the instancename "former". To fill these with text in code, it would be former.turist_box_inf.text = "nice text" and so on. The thing is I want to fill these with info from an XML sheet and therefore do it through a loop. [code]...
So in AS2.0 I would use _global.variableName to create and refer to a variable that was maybe created on the stage and then needed to be referenced to inside of an instance. That doesn't seem to work anymore. Are you expected to not want to do that, or is the code just changed now?
I'm trying to create an XML class to load some images on a stage, but my problem is that I can't access variables in my XML class(which I need to load the images) from the main timeline after I've created a new instance on the XML class.[code]...
Im working on an Actionscript 3 program where i will click through a tree structure of buttons and use the values of the particular set of buttons, to access its corresponding value in an XML file.As i click each button, I start forming a string eg.
Everything works perfect up to this point except that xmlString contains the incorrect value.I want xmlString to contain the particular value within that particular element in the XML but instead it only displays the concatenated path. (myXML.unit1.lesson1)is how would i be able to use that "xmlString" value to refernce the particular elements value.everything else works perfect and if i have to pass that XML path directly, "myXML.unit1.lesson1" it functions correctly, thus it must be an issue with the concatenated string not being registered as an XML path.
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]...
In my previous topic whitelynx_nivla gave me a code, which I edited. I'm using it to set variables when a certain key is pressed.But the loader can't access the variables and change them.[code]
I have a movieclip that is exported for actionscript and has a class linked to it.In the actual movieclip I have two dynamic text fields ex: tf1 and tf2. tf1 is on frame 1 of the movieclip and tf2 is on frame 2.In the constructor I pass two strings as arguments ex: s1 and s2, one for tf1 and one for tf2.So in the constructor I am trying to assign these values to the textfields i.e:tf1.text = s1;tf2.text = s2;But, because tf2 is on frame 2, I cannot access it.I think I read something somewhere that all variables and objects that are on frame 1 are global. But this is not what I am working with, I need to access tf2 which is on frame 2.
I'm trying to embed an SWF in my ActionScript project (Flash Builder 4.5). I need to have access to variables inside that SWF, but for some reason, embedding it strips it from all scripts.The solution I found on the web was to embed it like this:
ActionScript Code: [Embed(source="sprites.swf", mimeType="application/octet-stream")] private var Sprites:Class;
I am just writing this test code in AS1.0. Now the problem, I am not able to get access to my class variables. I am doing this stuff for learning As1.0. Although in 2.0 I get through those using static variable. But in As1.0 I don't know how to do this.
i assigned some variables called charstrength and so on but i want to access these variables globaly as the action is on the first frame with all the variables stated and on the second frame i need to access those variables but it just wont let me.
I have a class called Butterfly that extends MovieClip and exists as an asset in my Flash CS4 library.
The timeline of Butterfly consists of different wing flaps for different segments of its behavior. One of the animations is the wings opening up. Once the wings are open, dynamic text is shown on the wings of the butterfly.
Code: //Butterfly.as ... private var _textForWings:String = "Text For Wings";
I don't seem to have access to that variable from frame 159 inside of the clip.
What is the right process for accessing variables defined in the class by the frames inside?
Currently I'm using a getter for the _textForWings variable and using
Code: //getter inside Butterfly.as public function get textForWings():String
[Code]....
In this instance this works, but this things that i specify in the class are not avaiable to me within the timeline where i need them issue is really causing some headaches.
In many tutorial i have find how to use FlashVars in embed or object tag of html. I used the FlashVars in an html file as follows:
[Code]...
Then in the fla I tried to display the userName in a text field. But its displaying undefined. Should I define any method in fla to access the FlashVars variable.
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;
Is there a way to access variables on the main timeline in Flash other than MovieClip(root).myVar ? The problem I am having is that I have a movie clip that uses several main timeline variables, but when I instantiate it, it throws a 1009 type error (cannot access property of null object reference). My understanding of whats going on (and please correct me if I am wrong) is that when instantiated it runs the code on the first frame of the movieclip. However, it is not added to display list yet, so it does not have a root. Thus, all the MovieClip(root).myVar lines do not have a root to look at. Does anyone know of a way around this?
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...
I'm loading external swf's in a main swf, which are contained into a container "thisMC" which is a movieClip.
Now I've got various variables in these external swf's and I want to access these variables into my main swf.
eg - var myString:Variable = thisMC.myNumber; trace("Whats the value "+myString);
o/p Whats the value undefined.so if myString is a variable that i've defined in the main swf and myNumber is a variable defined in the external swf, if I try accessing it like this , this is what I'm getting.