ActionScript 3.0 :: Tracing Contents Of Display Object?
Sep 19, 2008
The author shows a function that is supposed to trace the contents of any display object. In his example file he has several nested movie clips on the stage and everything works just as it should, this is the code.
ActionScript Code:
function showChildren(dispObj:DisplayObject):void {
for (var i:uint = 0; i < dispObj.numChildren; i++) {
var obj:DisplayObject = dispObj.getChildAt(i)
[code]....
The problem I am having is that when I open a new actionScript 3 .fla and try to recreate the nested movie clips and use the same code I get these errors:
ActionScript Code:
line 3 1061: Call to a possibly undefined method getChildAt through a reference with static type flash.display:DisplayObject.
var obj:DisplayObject = dispObj.getChildAt(i)
line 2 1119: Access of possibly undefined property numChildren through a reference with static type flash.display:DisplayObject.
for(var i:uint = 0; i < dispObj.numChildren; i++){
Seems like something easy, but I don't see it in the docs. If I have a movieClip or sprite that is 200x200, and I generate an object that is 300x300 and add it as a child of the original mc, how do I clip the bounds so that I don't see content outside of the original mc? Do I have to create and apply a mask?
I am having some kind of issue with the display list? I have a function that goes through various frames of my timeline and then traces all the symbols on the stage.. ActionScript Code: for (var pm = 0; pm < this.numChildren; pm++) { var child = this.getChildAt(pm); trace(child.name) }
What I am noticing is that it will return everything until it runs into a symbol that does not exist on every frame.. as soon as it does encounter a symbol that does not exist on all frames of the main time line it spits out - TypeError: Error #1009: Cannot access a property or method of a null object reference. at 3_Migration_Standard_Nav_v2_fla::MainTimeline/pMovie()
I have some simple Sprites that I'm putting into an array. However, when I click on them I want to trace what their position is in the array. How do I go about doing that?
ActionScript Code: var myArray:Array = new Array(); var mySpriteOne:sprite = new Sprite(); mySpriteOne.graphics.beginFill(0x000000);
[Code]....
I want to add some mouse click listeners and then I want to trace the currentTarget's position in the array. I just have no idea what parameters to give the trace().
check out the attached file. Don't ask me why, but I need that yellow rectangle to follow that grey dot, which rotates around randomly... but see, if you place the dot to the center left of the grey rectangle, you see that the yellow rectangle screws up. I've deducted that this happens for this reason: to the left of the grey rectangle, the rotation value is 178... 179... 180... then it jumps to -180... -179... -178... (you can try this out using an onEnterFrame function and tracing the rotation of an object that follows the mouse).
Since the yellow rectangle follows the grey dot with an ease, it doesn't just do: rectangle._rotation = dot._rotation But instead: rectangle._rotation += Math.round((dot._rotation-this._rotation)/rotatespeed) Some of you guys should already be familiar with this kind of movement, but it's usually used to move objects smoothly. The bug here is that whenever that dot randomly jumps up into -180 from it's original position at below 180, it screws up the yellow rectangle.
I'm just starting to learn about classes in actionscript, I am following along with Moocks book Actionscript for Flash MX and are trying to execute a trace on the properties of my ballclass but all I get is undefined. He is what I have in my actions panel.[code]
I have an array of objects. What I would like to do is get the last index of an object whose property equals a certain value. Ex: // this occurs on a mouse click var stockObj:Object = new Object(); stockObj.ID = "an_id"; stockObj.category = "a_category"; array.push(stockObj); //psuedo trace(array.lastIndexOf(stockObj.category=="a_category")); I would like this to trace the index of the object whose category property equals "a_category"
I have object in which I have rectangle on one layer and following code on another layer:
[Code]...
And Object(this).play() or checking for current frame doesn't work, nor tracing a value define outside the function. How shall I reffer to the movieclip that events is called from?
If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased.With 45 rotation, the size becomes about 143x143 (from 100x100).Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't.At the moment I am doing this:
var currentRotation = object.rotation; object.rotation = 0; var normalizedWidth = object.width;
I have a php script that calls a result from the DB and gives it a variable. I then have a dynamic text box in flash that I want to say "goto read.php, find the variable and display the variable's contents in this text box"...
I'm using the WebServiceConnector in CS3 to load some XML. The trouble is, whenever I trace out the XML, all I get is "[object Object]". Here's the code I'm using:
I have a folder of different pdf files saved with my SWF file. I want the user to be able to click a button and have a new window open for that folder I tryed new URLRequest but that wants to open in internet explorer and wont display the folder contents..
need that the application will display contents that location on a server on the web.I have several html documents that locate on a secure server. I need that the application displays those pages (like a browser) sow If I'll change the html documents on the server, the application will display the new changed pages.I need that the html documents and the data they contain will not be embedded on the application but just display by the application.
I have a requiremnt where my Air application loads ZIP files instead of swf.The zip contains all swf ,images and other files.My requirement is when user browses for file in a browse dialog, user selects a zip file and the contents of this zip file should be displayed to the user.
I want to build an application using air. The application should load the flashlog file and display the contents after performing some text filtering.But when i load the application this clears my flashlog.txt though my file mode is READ.I can understand that running my air application clears the flashlog and prepares it for new logging. Is there a workaround for this.I dont want to open the flashlog file everytime and check for traces from my web application
I have followed the XML Video tutorial and everything works fine however Lee says you can use a movie clip to display the contents of the XML file instead of one of Flash's built in components. Is there a way to create your own drop down menu or simple text field?
I would like to send data from PHP to Flash however, it sends just fine but when displaying on Flash, it does not display the contents in the variable. Instead, it displays the name of the variable. This may be a simple answer but I'm quite new to this. Here is the code in Flash.
I'm just trying to have a textbox on my main stage display certain values depending on what frames are being played. So having not done actionscript in a LONG time, I would assume is it something like this:
I have an object that has all the elements I would want to pass arguments: var args:Object = { 'dog', 11, myArray }; and I want to be able to pass the contents of args to doSomething without making any changes to doSomething (assume it's someone else's function) and I'd like to do it in a way that doesn't assume I will know anything about the contents of args.
I want to load some .swf files using the Loader class. I'm all set with that and got the image on screen but I wish to have multiple instances of it. Do I have to reload one for each that I intent on using?
For example say I'm attempting to load a power up's graphic from an .swf (i'll call it ex.swf). I load it and then put the image I loaded into the power up. But then I also want to have another power up of the same type somewhere else, and I want to use that same graphic. Neither adding the loaded ex.swf's contents or simply assigning the contents to a child of the power up will work obviously. So do I have to load a new copy every single time i want a new one, or can I just clone/duplicate the contents?
I mean I know it must be common for games to have 100's of copies of the same graphic being used by different things, yet If I try to preload the amount I'd need it's not exactly flexibly and if I load them as I need them it seems bad practice..
I tried the tutorial on [URL] The Object-Oriented Scrollbar: Part 2 tutorial. Every thing is fine, but when I load the swf to main.swf
- I can scroll the scroller, but not the content - I got this error
TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.leebrimelow.ui::ScrollBar() at flash.display::Sprite/constructChildren() at flash.display::Sprite() at flash.display::MovieClip() at com.leebrimelow.ui::ScrollBox() .....
The scenario is: - The main timeline play and stop at 56. - At 56 the main.swf loads the sec1.swf
I was trying to create a preloader that preloads content loaded by the LoadVars() Object. For some reason, the getBytesLoaded and getByetesTotal variables of the LoadVars object kept retuning a null value. Below's how I do it:
PHP Code:
var news_lv = new LoadVars(); var url = "news.aspx" news_lv.load(url);
I was trying to create a preloader that preloads content loaded by the LoadVars() Object. For some reason, the getBytesLoaded and getByetesTotal variables of the LoadVars object kept retuning a null value. Below's how I do it:
PHP Code:
var news_lv = new LoadVars(); var url = "news.aspx" news_lv.load(url);