ActionScript 2.0 :: Substitute For _root In Classes?
Apr 23, 2008
I have just started writing my own classes in .as files. I am now wondering what the structure is for calling movieclips and buttons on the stage. I have been using _root but have read that it is not a clever choise if you want to import other swf files into your project. Is there a smart way here to structure my classes?
In the code below i want to change the _root.broj and _root.logo variables inside the function which returns values from .php file. Inside the function everything works fine and all values are correct but when i trace var broj outside the function it's still 0.
var result_lv:LoadVars = new LoadVars(); var send_lv:LoadVars = new LoadVars(); var broj:Number=0; var logo = new Array();
if a condition is true, then:_root.(MC with instance name that is the value of "_root.eelmine").nextFrame(); is this correct?_root._root[eelmine].nextFrame();
I just recently began migrating from AS2 to AS3, and I have of course realized that I can no longer move the "_root" by changing the _x and _y positions of the _root (which no longer exists in AS3). How can I do this in AS3 (specifying _x, _y, _z possibly of the "_root")?
I still use AS2. Since I migrated from Flash 8 Pro to Flash CS4, the .fla I used to work with displays now a Font Mapping window.
The window says that the "VerdanaReg*" font is not available on my system.i never had such a font installed Verdana is a font I make an extensive use in my .fla and the installed fonts are (for several years):
I have reasonable experience with PHP, CSS, and javascript/jquery/ajax. I'm taking my first steps learning Flex/Flash/Actionscript and it's already striking me that using flash/SWF could solve many of my problems. For example:
I won't have to worry much about javascript availability e.g. handling the form submit twice like I do now, once for js available and one for js not available. There's also a CSS advantage: looks like things are very easy to style and drop in their correct exact spot in flash than it is with CSS (I hate CSS because I'm not that great at it and it usually gives me a headache).
Consider a string template of the following format: String template = "The credentials you provided were username '{0}' with password '{1}'"; Substitution variable fields are of the form {n}, where n is a zero based index. This is the template format used in Adobe Flex, see StringUtil.substitute(...). And also .NET, IIRC. Since I want to re-use the templates used by the Flex code I'm looking for an Java equivalent. I'm aware of String.format(...) but the template structure is not identical. What is the best way to get the same "Flex compatible" template functionality in Java? Basically this is the desired end-result:
what I want to know if there's a substitute for a stage (since you only can have one) that accepts objects to be added to it (as childs with addChild(object)) that isn't the size of the stage but its size is definied some other way.I just created another thread about loading swf files, but my question is new but related to that.I'm creating a series of mini-games that shoud be loaded into a project from external SWF files, but right now I'm using "stage" as the place where I put all my objects.For example, I have a GRID that accepts new Grid(4, 4, "Object") as the Construtor parameters, that is to say 4*4 (16 boxes to this grid) and it determines "automatically" how wide the stage is, if it's 200 px every box is 50 pixels wide. And the same for height. It calculates stageWidth / X, stageHeight / Y
so it's always a "full grid" that is 100% on the screen no matter the size.Finally, my question is if there is some other type of container other than stage that can "contain" these objects. Say that I create 4 of these containers, and each should hold 4 mini-games without taking up 100% of the stage container - instead it should take up the Substitute that acts in a similiar way.
is it possible to load a .swf and play it in such a way, that this loaded clip will become a root effectively substituting a loading clip on top of the hierarchy?
Saying this another way round - rather than loading external .swf as a child of a "host" movie I would like it to replace host movie entirely.
We're making a Flash browser game with a few reasonably complex animations. Our designer is making the animations in Flash Professional while I'm wiring everything up and adding some logic through AS3 (using FlashDevelop).In one of our more complex animations a "bonus item" moves around the screen. It tweens hither and tither, there special effects and as such, it disappears for a few frames and then reappears later.From AS3 we want to be able to dynamically decide which bonus item (say a mushroom or a star) to include in the animation. We don't want to have to ask our designer to replicate the entire animation for each of our bonus items.This is what we've tried: Created a two frame (1 mushroom frame, 1 star frame) "BonusItem" movieclip in FlashPro and Exported for ActionScript.Created the complex animation movieclip in FlashPro and added the BonusItem movieclip to the relevant frames. Gave the BonusItem instance an instance name on all necessary KeyFrames. Exported entire movieclip for ActionScript(exported as "ComplexAnimation").[code]This would play the complex animation with the star and we could easily call gotoAndStop("mushroom") to play the same animation with the mushroom.
The first problem was that complexAnimation.bonusItem was null on line 02 above. I solved this by handling ADDED_TO_STAGE for complexAnimation and putting line 02 above in the handler. The next problem was that each time the bonusItem movieclip started tweening, or if it was not present in some frames and was subsequently re-added the complexAnimation.bonusItem attribute/reference was reassigned to a new bonusItem instance. I then had to find a way to know when this was happening and call gotoAndStop("star") on the new instance. I've found two ways to do this:
1) Listen for ADDED events on complexAnimation with a target.name of "bonusItem". It's a bit crap in a strongly typed language to have to resort to matching strings, but this works. Btw, when the ADDED event is fired new frame object references are still null.
2) Listen for FRAME_CREATED events. This happens later than ADDED at a point where new frame references have been initialized. As such I can check if complexAnimation.bonusItem is non-null at then call gotoAndStop("star") on it. One problem with this is that calling gotoAndStop actually triggers another FRAME_CREATED event to fire, so I need to guard against infinite looping. Again, it works but I don't have a great feeling about it.
I'm reposting this message as I realized I mis-titled it the first time. And I really do mean it: I will pay for a working solution to this problem. I need to do this for a client and not getting it done is not an option. It's all working like a charm. The only bad thing is: I want to place .swfs files where the dynamic text is right now, and can't figure out how to do it.
What I really want is one large image/JPG on each slide, and below that, instead of the dynamic text shown in the tutorial example, a smaller .swf file should appear. (For this project, the text itself needs to be animated, and I can't do that with the <caption>/dynamic text option; I need to insert an SWF.) I'd really like to do this using XML since that's working so nicely otherwise and will be so easy to update in the future if the client wants to add new slides.
Can anyone provide me with the actionscript code to use in the context of this photo gallery? I'm not advanced enough yet to know where or how to place code that doesn't fall into this gallery/AS format.(I'm not being lazy: I have looked all over these forums for hours, read through about 60 pages of tutorials, went through the whole XML Photo Gallery with Thumbnails hoping I could somehow alter that to meet this project's needs... no dice. I had gotten far enough in that tutorial to be able to insert an empty movie clip where I want it, but could only figure out how to fill it with JPGs from the XML, not SWFs... and in any case the images did not then work correctly while advancing the slides.)
Here is my current Actionscript code:
************************************************** ***** function loadXML(loaded) { if (loaded) { xmlNode = this.firstChild;
[code]....
(It's not showing the preloader and the counter is missing on purpose; I don't need those items for this project...) In another version I have deleted the desc_txt code and the dynamic text field in Flash, substituting a new movie clip (in its own layer) called "description" and an external link to the SWF file in line 2 of each node of my XML file, closing and opening that line with <description> and </description> rather than <caption>.
I have a menu whee you can choose a picture to lead, works great with first selection, but when you choose a different picture it loads over the last picture,I want to substitute the content of that movie clip not to load all the pictures in the same space. I treid to use clear() and removeChild(), but this only works when I choose pic1 then remove that to load pic2, is there an easy way to substitute the content for the new content?
I was wondering if its possible to substitute a variable with another variable's name instead of its actual value. I have a variable named "pLeg" thats equal to the value of 1.I have blank variable named "itemVar".Now, I want "itemVar" to equal to "pLeg", but not of its value, but of its name string.The reason is because I need "itemVar" to substitute multiple variables in a main timeline code.
For example:
Code: if(_root.itemVar !== 1) { //do something }
"itemVar" can be any variable, like pTorso, or pWeapon or anything. Which is why I can't have it equal to the variables actual value, because then the timeline code would turn out to be:
Code: if( 1 == 1) { //1 being itemVar }
PS: I've tried add quotations like _root.itemVar = "pLeg" but Flash will not read it as a variable.
The examples I'll use don't do anything - they're classes without ANY members - no variables, methods, anything.
Let's say I extends Sprite and call it MySprite.
I save it in test.core
[code]...
Now I create another custom class called MyWindow that extends MySprite.
I save it in test.windows
[code]...
Then I create another class that extends MyWindows (the example I'll use is a document class - but that doesn't matter - I've tested using an instance too).
[code]...
Notice that I'm not even trying to instantiate the helper classes - just having them there throws the error.
If there is only a single helper class, everything runs fine.
Also note that - as far as I can tell - this only happens when extending one class from another package, then extending that class with more than one helper object.I'm pretty sure there's no namespace bumps or typographical errors, as this is a very pared-down version of the original application.
EDIT: seems the problem exists even without the crossing packages - even extending MySprite in the document class with multiple internal classes generates this error.
I am creating a library in AS3. Inside the library I make use of a bunch of classes/packages that need not be exposed to the end user of my lib. I want to only expose one of these classes.
I guess my questions are:
1) How are libraries commonly distributed in AS3?
2) Is there a .jar equivalent in AS3 that developers can include, but will only have access/knowledge of the classes I've declared as public?
I have an actionscript project which uses visual symbols from an SWC. I have a CheckoutButton which has the following class associated with it (compiled into the SWC in Flash CS3).
i have these lines of code, when i try them alone it works fine but when i try to use it in my project it stop working, the rotation actually and is because of "this" in the tweener.
[Code]...
my question is, is there any way to reference another object in the tweener to make this thing works? project consist in several classes wich are called by a fla to ensamble interface, maybe that's the reason it stop working. now i noticed the code i have just works directly on the fla, if i place it in a clase it stop working because of the same...."this"
I'm trying to import a class from a class that is located in another folder. How do you move up a directory? Using./ or ../ doesn't seem to work. Essentially I want to access a TweenLite Class but not from the document class. My class is at com/myName and the class I want to access is at com/TweenLite. import ../TweenLite doesn't work... I realize I could just copy and paste the entire Tweenlite folder again, but there's got to be a less duplicative way of doing this..
inheritance and building classes from other classes.
I have 3 classes: gfxRoomText - changeable colour gfxRomInter - changeable colour - interactive gfxRoomImg - interactive - only image / no colour
The first two incorporate the same text field and functions to change colour. The second and third incorporate another class to interactive with. What is the best way of creating these classes using inheritance and how?
I have a dynamic text and in it I pull a value that I places in the PARAM of my HTML, like this, " ...&p1=de|R$+9,49|por|R$+799,58 ", I am trying to make the following one, show the value in the dynamic text, " R$+799,58 ", without the "de" or "|" or "por", I already tried to make this.
[AS] var valorDe:String = "!"; var valorPosicao:Number = _root.p1.text.indexOf (valorDe); if (valorPosicao >=0) {
I have to use many custom classes for a project, each class includes lots of elements(methods,properties) and I generally forget their names when coding. Is there any editor which I can enumarate the elements of my classes after pressing "." like Flash's built in classes?
I am new to classes and I am just starting to follow tutorials on how to assign classes and sub classes and I am wondering when you assign a base class or class to an object(Symbol e.g movieclip) through the properties, are all instances on the stage no matter how many and what they are named influenced and is the Stage/main timeline always the parent? and just one more question, is the parents objects display list all the movieclips that are used on the stage or all the instances on the stage?
I an trying to get the _root node of an FLA via JSFL. A co-worker wrote a script that uses _root via actionscript. I was trying to wrap that code into a panel. I have all the trace functionality running and everything running accept I can't seem to access the "_root". I have tried _level0, and almost everything I can think of... I am looking to have JSFL return the _root object from the current file the same way can can hand "_root" to a function. (IE: myfunction( _root ); ) here is my current attempt:
Code: var doc = MMExecute( "fl.getDocumentDOM()._root;" );
I have an external swf, that is a photo gallery, loading into my main swf. When the external swf loads, everything works fine except when you click on a thumbnail in the external swf, the jpg doesn't load. I have it set up that an empty movie clip is created first, then the jpg is loaded into that. I have a feeling it is something with the fact that I am using _root, but I don't have any guesses whats causing the issue and how to fix it.