Find The Top Of The Display List
I'm trying to move a movieclip to the top of the display list on MOUSE_OVER. anyone have any ideas?
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 03-21-2008, 12:32 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Where Do I Find A List And Description Of Var Types
when you type in - var varName:[ ] - after the colon you get a drop down menu.
This menu has things like "adobe" and "EncryptedLocalStore"
Where do I find a list of what these things are and what they do?
Thanks,
Keyboard Key Codes - Anyone Know Where I Can Find A List?
Does anyone know where I can find a list of all the key codes for keys on a keyboard? I've always looked for one but I've never been able to find one. It would be highly useful !Does anyone have one or know where I might be able to get one ?
---------
EX: W:87
S: 83
Z: 90 (That's about all I know )
--------------------
Thanks,
Fargate
Where Can I Find A List Of Features For The Calendar Component?
I am trying to present the use of flash to a client and they have requested a "feature list" for the capabilities of the calendar component with Flash and/or Flex. I have looked all over the Adobe site and searched on the board and can not find anything.
Any help is greatly appreciated!
Thanks!
Display In List.
I was wondering....
If I have a database with four items.
And I have a PHP-file who sends those four items to a swf-file.
If I have a List (Listbox?) in Flash.
How do I list all those four items at the same time i the list?
I cant work out how to do it.
I can only display the last item. Not the three first.
Can you help me?
Display A List
I curently have a list displaying
All my elements
I am displaying a list. But I do not want to display anything that is a space or a undefined
What I have and I know is not the best way
Attach Code
onClipEvent (enterFrame) {
this._parent.shoppingCart.shoppingcart.main.cartItems.text = BREAKFAST_1A+"
"+BREAKFAST_1B+"
"+BREAKFAST_1C+"
"+BREAKFAST_1D+"
"+BREAKFAST_1E;
}
The Display List - AS3
Finally got my copy of Flash Pro CS3 last week and I am finally playing around with AS3. Typical training project... Convert a simple, older AS2 project over to AS3 (in this case my personal site). I've been coding AS2 in a OOP model for some time now so getting used to the new packages and class features wasn't much of an issue.
In my old file, I figured out preloaders and the basic jist of the display list and using addChild. I'm running into issues though with handling a custom form class I wrote not long ago and getting it migrated over...
I can get the window for the form drawn quite easily. It was actually a piece of cake with the new functions from the graphics package.
THANK YOU ADOBE FOR THE SIMPLIFIED ROUNDED RECTANGLE FUNCTION!!!
In AS2, you would create an empty container to hold the contents of a group of items (in my case a form). When I created an empty movie clip in the container, the coordinates were relative to that container. I'm trying to understand the display list so that when I create the text fields and form box titles etc, their (x,y) are relative to the window I created. As of right now, they are relative to the main shell. Does this make sense?
In AS2 it would be something like this....
movieClipName.createEmptyMovieClip blah blah blah
Is there a similar method when using addChild in AS3 so that everything I create is positioned relative to the window calling it?
Display List
I'm having trouble getting at a class. So I have a class in a shell swf that imports a swf and runs it on the stage. When this imported swf is done, I need to tell the class that birthed it to get a new swf. I have a way to do this that works, but I feel like there's a more direct way.
My working way is that the class assigns a variable within the imported swf to hold a pointer to the class ("shellPointer = this;). At the end of the swf, it prefixes a method call with this variable. Simple enough, sure. But I want to know if there's a way for the swf to access the class without the class assigning the pointer. Is there? I tried prefixing the method call with variations on parent and MovieClip(this.parent), but I always get an error.
Up And Down The Display List
In the Flash IDE debugger for AS3 I would like to traverse the display list and see the properties of all the objects on the stage. If I place an object on the stage with addChild I can then see it's reference to the stage in the debugger (this.stage) and stage can be expanded to see various properties. There is also a this.parent and a this.root and this.stage itself has the similar properties.
Using these, how can find "this" and other objects on the stage?
Also, where can I find such technical details?
Many thanks.
John
Display Output In List Box.....how?
ok, i have this line of AS that displays a result.
code: return "Both are "+_root.relateOne[i]+"s";
but i would like this displayed in a list box called "result"
could anyone help me with this code?
many thanks
Lost In Display List
Hi,
I'am trying to find the right way in the hierarchy of objects, but still no success. AS2 rules are lost..
Code:
var all:Sprite = new Sprite();
addChild(all);
var logo:Sprite = new Sprite();
all.addChild(logo);
var place:Sprite = new Sprite();
all.addChild(place);
trace (place.parent.logo) //error
I know that trace(logo) is possible in this case, but I need to use it in function where I know only "place". In old times I would trace the path which would be like: "_level0.all.logo" but no chance now in AS3.
Compiler says: 1119: Access of possibly undefined property logo through a reference with static type flash.display:Sprite.
Could you help me please? It has to be easy.
Thanks.
Display List Trick?
I have a small problem. I would like to test a sprite whether it is on the display list or not. I have found 2 simple but not so ellegant sollution.
My question is, there exist an elegant sollution for this problem? (with predefined functions or something like this).
beczesz
Display List Problem
I have built a movie clip in the library that will be part of a dynamic menu that I am building. Inside the movie clip are other movie clips that will hold text and image content. I want to load in the images and display them in the appropriate holder. The image loading thing is fine. I am having a problem access the clips inside my instance.
I create a sprite as my nav bar holder
var navbar:Sprite = new Sprite();
// then I build the buttons from my XML document I imported
var padding = 12;
var maxBtns = navData.kit.length()
var count:int =0;
// pull a new instance of the NavButton from the library.
for (var i:int=0; i < 5; i++) {
var btn = new NavButton();
btn.name = "abtn"+i;
btn.x = (btn.width*i)+(padding*i);
navbar.addChild(btn);
}
add the nav bar to the stage
navbar.x = 92
navbar.y =300
addChild(navbar)
All is great now I want to access the first button and load it with content
Here is the problem navbar has 5 children
trace(navbar.getChildAt(0)) // returns [object, NavButton]
How do I create a path to one of movie clips inside this object
navbar.getChildAt(0).abutton.imageholder.alpha = 0.1;
This gives errors and everything else I am trying and yes it was due today and I am going crazy.
XML List And Display View
I have been racking my brain on why this won't work. All I want to do is have a list of news items with date and title pulled from a xml file. I want to be able to click on 1 item and have it populate the detail view. If I replace the sendID with the actual id I am referencing it works but it won't read it as a variable.
Attach Code
Here's the AS I'm working with:
function DetailDisplay(sendID:String){
var loadXML = new XML();
loadXML.ignoreWhite = true;
loadXML.onLoad = function(success){
if (success){
var loadText = loadXML.firstChild.firstChild.childNodes;
for (var i=0; i<loadText.length; i++) {
if (loadText[i].attributes.id == sendID) {
var title = loadText[i].firstChild;
var date = loadText[i].childNodes[1];
var copy = loadText[i].childNodes[2];
newsDetails._visible = true;
newsDetails.html = true;
newsDetails.content_txt.htmlText = copy.firstChild.nodeValue;
newsDetails.title_txt.text = title.firstChild.nodeValue;
}
}
}
else {trace("Error loading XML file");}
}
loadXML.load("news.xml");
}
newsDetails._visible = false;
function CreateNewsList(newsList_xml){
var items = newsList_xml.firstChild.firstChild.childNodes;
for (var i=0; i<items.length; i++) {
if (items[i].attributes.type == "article") {
var title = items[i].firstChild;
var date = items[i].childNodes[1];
var sendID = items[i].attributes.id;
newsList.html = true;
newsList.htmlText += "<i>"+date.firstChild.nodeValue+"</i><br /><a href="asfunction:DetailDisplay, "+sendID+"">"+title.firstChild.nodeValue+"</a><br /><br />";
}
}
}
var news_xml = new XML();
news_xml.ignoreWhite = true;
news_xml.onLoad = function(success){
if (success){
CreateNewsList(this);
}
else {newsList.text = "Error loading XML file"; }
}
news_xml.load("news.xml");
XML Setup:
<?xml version="1.0" encoding="ISO-8859-1"?>
<news>
<newsitems>
<item id="3" type="article">
<title>News Item 3</title>
<date>October 1, 2007</date>
<copy>This is the 3rd news item.
</copy>
</item>
<item id="2" type="article">
<title>News Item 2</title>
<date>September 25, 2007</date>
<copy>This is the 2nd news item.
</copy>
</item>
<item id="1" type="article">
<title>News Item 1</title>
<date>August 08, 2007</date>
<copy>This is the 1st news item.
</copy>
</item>
</newsitems>
</news>
Checking Display List
what is the best method to check if a certain object is on the display list ?
Thanks for any advice.
Help With Display List And Classes
Hey guys,
I have a FLA file which creates an object based on a class. This class then adds a movie clip (in the stages libary) to the stage (while adding it into the display list). However, I try virtually the same thing with another file, and it cannot find my movie clip (from the stage).
I think that this might be because of my movie clip linkage data? I right click it in the libary, select 'linkage' then check the box 'export for actionscript', then click the little pencil next to the 'class' textbox. It does not come up with any message saying that it cannot find any pre-created class (because I have made a AS class file for it).
But when I try to run it cannot find the class ('not compile-time constant'). What is wrong? And what is this 'linkage' stuff as well???
any help would be appreciated :)
thanks
Can't Add To Display List From A Class
in my Main.as file, this works as expected:
var t:TextField = new TextField();
t.text = "hello in main";
addChild(t);
However, when I create an instance of a class, and I have that same code in the constructor of that class, the text doesn't show up. I am creating the text field variable at the class level, not the contstructor level, so I think the variable should still hang around.
Do I have to get an instance of the stage, or something?
thanks
Trying To Understand Display List In AS3
I have FLA 01. I create a loader in FLA 01. I use the loader to load SWF 02 and when the load is complete add SWF 02 to the stage and place it in a movie clip. So far, so good.
SWF 02 is a rather complicated file. It dynamically creates in ActionScript several dozen small movieclips that are all added to the stage (all done in ActionScript).
I have a button on FLA 01 to replace SWF 02 with SWF 03. This works fine, but the movieclips that SWF 02 added to the stage still remain even after SWF 03 replaces SWF 02. This confuses me. I would think that when I replace SWF 02 with SWF 03, all aspects of SWF 02 would be gone, but it doesn't seem to replace any objects that SWF 02 added to the "stage." I appear to be successfully replacing SWF 02 with SWF 03, EXCEPT for any objects SWF 02 added to the stage. So, how would I also remove those?
I am guessing that when SWF 02 uses ActionScript to dynamically add movieclips to the "stage" they are not really a part of SWF 02?
So, basically I'm trying to figure out how that works. If I have one Flash file and l load another SWF into it is there always only ONE stage? I thought each SWF file had its own stage and so when SWF 02 was adding items to the Stage they were still a part of SWF 02 and would go away when SWF 02 was replaced. Thanks for any insight and clarification.
Best Way To Display A Price List
I was wondering what do you think the best way to display a complete list of prices and how would this be done
here is what i need displayed: http://www.beautyplus.co.uk/prices.html as you can see its fairly easy to do in html but i wouldnt have a clue where to start in flash
cheers
Working With The New Display List
Hi all,
I'm quite new to AS3 so please bear with me. I have read that the attachMovie has been replaced by addChild. I'm not sure how this works though. Basically I have a document class in which I have all my game code, I have movie clip symbol in my library which I need to follow the mouse but how? Obviously I will use startDrag but how do I get the symbol into the display list or the document class???
Please help, very confused!
Lar
Display List Woes
Hi,
I've been writing some code to create a scrolling pane without the scrollbar.
Essentially, when the cursor is within the pane to be scrolled, I want the pane to be scrolled at a speed proportional to the distance the cursor is from the horizontal centre-line of the pane.
The code all works fine if it's there's no children of the Sprite to be scrolled.
Also, when using some sort external box as the scrolling control instead of the Sprite itself, all works fine as well. But when I try to use the Sprite that is to be scrolled as the "slider" it all starts to go wrong. The child Sprites seem to block events flowing up the tree to the Sprite I'm trying to scroll. Then again, it might be something else. I've been trying the mouseChildren property to no avail.
Here's the code:
(Thanks for any help)
EasyScroll.as
Code:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class EasyScroll extends Sprite
{
var rect:Rectangle;
var scrollSpeed:Number;
var scrollRectHeight:int;
var contentHeight:uint;
var clip:Sprite;
var clipY:int;
public function EasyScroll(SpriteToScroll:Sprite, scrollRectH:int)
{
scrollRectHeight = scrollRectH;
clip = SpriteToScroll;
clipY = clip.y;
contentHeight = clip.height;// the textField's height
clip.scrollRect = new Rectangle(0, 0, clip.width, scrollRectHeight);
clip.cacheAsBitmap = true;
clip.addEventListener(MouseEvent.MOUSE_OVER, scrollHandler);
clip.addEventListener(MouseEvent.MOUSE_OUT, stopScroll);
}
function scrollHandler(event:MouseEvent):void
{
// Add listener to capture the mouse position
// The listener dispatches the event to the moveScrollRect function
// which adds another event listener for ENTER_FRAME, which is dispatched to bumpY function.
clip.addEventListener(MouseEvent.MOUSE_MOVE, moveScrollRect);
}
function stopScroll(ev:Event):void
{
clip.removeEventListener(MouseEvent.MOUSE_MOVE, moveScrollRect);
clip.removeEventListener(Event.ENTER_FRAME, bumpY);
}
function moveScrollRect(ev:MouseEvent):void
{
rect = clip.scrollRect;
scrollSpeed = 0.4*( (clip.mouseY-rect.y) - (scrollRectHeight/2) );
//trace("mouseY: "+clip.mouseY+", target: "+ev.target.name+", scrollSpeed: "+scrollSpeed+", rect.y: "+rect.y);
if ( clip.hasEventListener(Event.ENTER_FRAME) == false )
{
clip.addEventListener(Event.ENTER_FRAME, bumpY);
}
}
function bumpY(ev:Event):void
{
rect = clip.scrollRect;
//if scrolling up
if (scrollSpeed < 0)
{
// if not at "top"
if (rect.y + scrollSpeed >= 0)
{
rect.y += scrollSpeed;
clip.scrollRect = rect;
} else if (rect.y > 0)
{
// make scrollSpeed less negative so can scroll right to top
scrollSpeed += 1;
rect.y += scrollSpeed;
clip.scrollRect = rect;
}
} else if ( rect.y < contentHeight-clip.height )
{
rect.y += scrollSpeed;
clip.scrollRect = rect;
}
}
}
}
scrollerTest.fla:
Code:
var circleArray:Array = new Array();
var containerSprite:Sprite = new Sprite();
containerSprite.name = "cont";
containerSprite.graphics.beginFill(0xEEEEEE);
containerSprite.graphics.drawRect(0,0,150,500);
addChild(containerSprite);
function printCircle(x:Number, y:Number, radius:Number, name:String, color:uint):void
{
var circle:Sprite = new Sprite();
circle.name = name;
circle.graphics.beginFill(color);
circle.graphics.drawCircle(x, y, radius);
circleArray.push(circle);
}
printCircle(0,190,25,"green1",0x00FF00);
printCircle(20,140,35,"green2",0x00FF00);
printCircle(120,200,15,"blue1",0x0024DD);
printCircle(140,270,20,"blue2",0x0000FF);
for (var i:int = 0; i < circleArray.length; i++)
{
containerSprite.addChild(circleArray[i]);
}
var events_scroller:EasyScroll = new EasyScroll(containerSprite, 150);
Display List Performance
So I am not exactly sure how to pose this question:Say we have a particular set of possible children objects and a parent object (these are Sprite subclasses).
The parent is NOT attached to the SWF display list (so parent.parent = null).
Thru a particular API, we attach the child to the parent's display list indirectly (parent.addChild(child))
Will calling the addChild API on the parent hinder performance since it is NOT attached to the main display list? Does that just get ignored since the parent is not attached? Are there any real performance gains by this?
This is relative to blitting techniques.
Best Way To Display A Price List
I was wondering what do you think the best way to display a complete list of prices and how would this be done
here is what i need displayed: http://www.beautyplus.co.uk/prices.html as you can see its fairly easy to do in html but i wouldnt have a clue where to start in flash
cheers
Display List, Is It Possible <li>Text</li>?
Hello fellow FLASH'ers!
I find lists to be one of the most attactive ways to highlight specific list of things about anything ... and having grown used to it, I am having naustalgia over not been able to use it in FLASH.
Is there a trick to it or is it just not possible?
For now, I have added a layer with discs but this is way too much work and non-dynamic.
Thank you all for your help!
Regards;
Jose Lerebours
If you have the knowledge, consult and educate those who need it! - Jose Lerebours
Display The Framenumber In A List Box
Folks:
I'm not sure how to tackle this one. I'd like to do the following:
Count all the frames in a movie (_totalframes, of course).
Load the number of frames into an array.
Display the frame numbers in a list box.
Note that the final result will be a list box with a sequence of numbers (1, 2, 3, 4, 5, etc...) not just the total frame number.
Any help would be great.
AS3 - As3 Display List Problem
Last edited by koose : 2008-04-24 at 08:55.
this is killing me, i've been working on it for a few hours and i can't get the event.target to recognise what i want it to. basically i want to click on the screen and have the code recognise what i have just clicked on. i have tried the getObjectsUnderPoint () array option as well. i'm trying to hide the box if the user clicks anywhere else but on it.
its like it's deliberately ignoring it and always looking one above, which has a value of null.
Code:
package {
import flash.display.Sprite;
import flash.events.*;
public class TabTester extends Sprite {
//array to track emoticon items [0]pop-up window [1]boolean for active
var emoticons:Array= new Array(0,0);
//init function
public function TabTester():void {
init();
}
//initial function
private function init():void {
//add temporary background
var tempBack:RoundedRectangle = new RoundedRectangle(0, 0, 2, 0x000000, 0xFFFFFF, 550, 400);
addChild(tempBack);
//add emoticon button
var emotiButton:RoundedRectangle = new RoundedRectangle(282, 86, 2, 0x000000, 0xFFFFFF, 18, 16);
emotiButton.addEventListener(MouseEvent.MOUSE_UP,emotOpen);
addChild(emotiButton);
//add pop-up area for emoticons
var emoticonArea:RoundedRectangle = new RoundedRectangle(282, 26, 2, 0x000000, 0xFFFFFF, 180, 60);
emoticonArea.addEventListener(MouseEvent.MOUSE_UP,emotOpen);
emoticons[0]=emoticonArea;
emoticons[0].visible=false;
addChild(emoticonArea);
}
//open emoticons area (make visible)
function emotOpen(e:MouseEvent):void {
if (emoticons[1]==0) {
emoticons[1]=1;
emoticons[0].visible=true;
this.addEventListener(MouseEvent.MOUSE_DOWN,emotOff);
}
}
//if user clicks anywhere expect emoticon window - close the window
function emotOff(e:MouseEvent):void {
trace("emoticonArea = "+emoticons[0].name);
trace("targetName = "+ e.target.name);
trace("targetName = "+ e.currentTarget.name);
if (e.target.name == emoticons[0].name) {
//do not close
trace("name is the same");
} else {
//close window
trace("not the same");
emoticons[0].visible=false;
emoticons[1]=0;
}
}
}
}
the output i'm getting from the trace statements at the end is:
emoticonArea = instance5
targetName = instance6
targetName = root1
it's driving me mental. why as3 whyyyyyyyyyyyyyyyyyyyyyyyyyyyy?
Papervision And Display List
Hi all,
I'm having some trouble with Papervision and/or AS3.
I have a loop putting all of my 3D objects onto the stage. I would like to target specific instances of the clips at runtime.
How do you do that?
I am using an item in the library of the fla for the movie material (LibraryClip1), setting it as a movieclip, naming it, and giving it properties.
Code:
for (i = 0; i<totalImages; i++) {
var tempClip:MovieClip = new LibraryClip1();
tempClip.name = "name"+i;
frontMaterial = new MovieMaterial(tempClip);
frontMaterial.interactive = true;
frontMaterial.smooth = true;
frontMaterial.animated = true;
frontMaterial.oneSide = false;
var aCube:Plane = new Plane(frontMaterial, 200,200);
trace("this is the instance name: "+tempClip.name);
//attach the plane to the 3D scene
scene.addChild(aCube);
}
That works well (I took out some extra code that places everything one the stage randomly to make this post easier to read).
Now when I try to get the instance names of the clips I put on the stage I run into trouble... I can get the name of a clip that I click on like this:
Code:
tempClip.addEventListener(MouseEvent.CLICK, buttClick);
function buttClick(event:MouseEvent):void {
trace("Instance Name on CLICK: "+event.target.name);
}
But I cannot target any other clips by name! I've tried using AS3 displayList methods like this:
scene.getChildAt(1)
I've tried stepping back to the viewport:
viewport.scene.getChildAt(1)
It seems the scene doesn't behave like a normal container when you addChild.
Any suggestions on how to access the children of the scene?
Thanks so much.
Selecting An Image To Display From A List?
(Not quite sure how to describe this, sorry if it's confusing.)
I want to be able to have a page of thumbnail images where a user can select one, and then get taken to a page/frame where that selected image is then the central image in this next frame. "Central image" may not be correct...I just simply want the previously selected image to be included in the next frame, or selected as a stored variable maybe...I don't know.
(The purpose of this is to make an online postcard creator.)
I've looked through the Tutorials here on FlashKit...but there's so many, I can't find one that helps with the concept I'm wanting to do.
Anyone have any suggestions as to where I can find a tutorial that allows one to select an image from a list and send it to another frame as a central component?
Thanks!!
Liam
druid -at- celticbear -dot- com
Selecting An Image To Display From A List?
(Not quite sure how to describe this, sorry if it's confusing.)
I want to be able to have a page of thumbnail images where a user can select one, and then get taken to a page/frame where that selected image is then the central image in this next frame. "Central image" may not be correct...I just simply want the previously selected image to be included in the next frame, or selected as a stored variable maybe...I don't know.
(The purpose of this is to make an online postcard creator.)
I've looked through the Tutorials here on FlashKit...but there's so many, I can't find one that helps with the concept I'm wanting to do.
Anyone have any suggestions as to where I can find a tutorial that allows one to select an image from a list and send it to another frame as a central component?
Thanks!!
Liam
druid -at- celticbear -dot- com
How Do I Display A List Of Files In A Dir. In Flash
I am creating an application from which the user will be able to search and view files from within the same directory as the swf file.
All of the files will be jpegs, and i would like to display a list of files within the same folder as the swf, in a dynamic text box that the user can select and open via hyperlink. in other words, this is an indexing programme.
How do i set this up?
help!
Cannot Get List To Display Movie Symbols
I am trying to create a list of items from a MySQL database through a PHP page. I can get the data to return with no problems, and I can get them to display the information if I use "htmlText" function. What I need to do is be able to load the list and display the each text item behind a button symbol, which I have already created. Is there a way to load the text from the PHP page and overlay that text with a button symbol I already have created? Any help would be appreciated.
This is what I have so far ...
var c = new LoadVars();
c.load("home.php");
c.onLoad = showContent;
function showContent() {
var i;
content.html = true;
content.htmlText = "";
for (i=0; i < this.n; i++) {
content.htmlText += "<b><a href='" + this["url"+i] + "'>"+ this["title"+i] + "</a></b>";
}
}
Using A List To Display Movieclips...[MX04]
guys, thanks for the help, and please excuse if this has been covered before...
I have 2 movieclips, both set to not be seen when the movie loads with this:
_root.pressDenise._visible = false;
_root.pressDose._visible = false;
now, I want to have a list component that when I click on the first entry the first mc will show, and when I click on the second, the second will show (and not the first), so only one movie clip shown at a time, based on where I click in the list. I also wish to have more entries in the list later. the _visible = false works fine, but I really have never used a list, so specific instructions in newbie terms and exact locations of actionscript would be much appreciated. I know I can put entries in the data or labels parameters of the list, but not much more. I guess my ultimate eg is that I put 'pressDenise' and 'pressDose' in the labels, then I'm lost...
thanks!!
chris j
Still Not Grokking The Display List Apparently...
I thought I understood it, but clearly I don't. Here's what I'm doing:
I'm making a sort of "low tech" particle effect. The movie's document is set to be a MovieClip and has an enterFrame listener. Every enterFrame it pulls a "spark" MovieClip from the Library, gives it a unique name, and adds it to the Display List. The spark then does some things and at a particular time decides it should now die.
Problem is, I cannot remove it from the display list. I continue to get the message about addressing a null property.
I've tried having the spark remove itself. No.
I've tried having the spark remove itself from its parent. No. (I've used various ways of addressing what used to be _root, the document class, the spark, the spark's parent.)
I've had the spark call a routine on the document, passing along the spark [a] as (this), [b] just the sparks name and then use getChildByName, [c] and other convoluted methods to get the document to remove its own child. No.
So, here's what seems to be the pertinent data again:
1: The document class can add the spark to the screen with addChild and it appears just fine.
2: Nothing seems able to execute a removeChild. I can't get the spark to remove itself.
3: Most annoyingly, I cannot get the document clss to remove its own child even though a few seconds later it--itself--added the child.
Can someone give me clues?
---Damian
Simple Display List Problem
I have an object called UI_Total which contains 3 objects called Star, instanced as star1 star2 and star3.
In my code I do the standard:
PHP Code:
mainUI=new UI_total;
addChild(mainUI);
to instance the UI_Total.
Now, I can do something like
PHP Code:
mainUI.star3.x+=500
no problem.
And when I do
PHP Code:
trace(mainUI.star3.parent)
I get [object UI_Total] as expected.
Would someone be so kind as to explain to me then why
PHP Code:
mainUI.removeChild(star3)
doesn't work, and also why I can't do anything like
PHP Code:
mainUI.getChildIndex(star3)
Accessing Object In The Display List
I'm trying to add a tween event to external images that I load.
The images load just fine and the tween action work.
However the tween only works on the last item loaded.
when i trace my display list it lokk like this
[object MainTimeline] root1
[object MovieClip] level1
[object Loader] temp1
[object Loader] temp2
[object Loader] temp3
[object Loader] tempt1
[object Loader] tempt2
[object Loader] tempt3
As you can see i have named my loader instances.
how do i reference the individual images loaded by the same object loader
the tween ask for object as the first parameter.
any help would be appreciated
thanks
Is There A Display List Reparenting Event?
Hello,
I've got two box sprites on stage and a filled blue circle movieclip that I have moving back and forth between these boxes through reparenting the blue circle sprite:
box1.addChild(circleMovieclip)
box2.addChild(circleMovieclip)
What I'd like to be able to do is trigger the circleMovieclip to play its animation just after it has been reparented to another box sprite.
I'm not sure what would be the best approach to triggering the circleMovieclip to play its animation right after it has been reparented.
Is there a built-in reparentEvent what I mean by that is when a displayObject is added to the display list is a default event generated or is this an event that i would have to create and if so how would something like that work..
Would the event listener continually monitor the display list for changes through a setInterval...then when the display list grows or shrinks it triggers a change event?
Has anyone done something like this before and would be willing to share their thoughts on this question?
Any and all responses are greatly appreciated!
cheers,
frank grimes
Sprite Not Added To The Display List
For some reason the sprite instance is not being added to the stage. But my trace statement do print. When I attempt to list the object the only object is frame 1.
SpriteExample.as file
ActionScript Code:
package {
import flash.display.Sprite;
import flash.events.*;
public class SpriteExample extends Sprite {
private var size:uint = 400;
private var bgColor:uint = 0xCCCCCC;
public function SpriteExample() {
trace("--! Fired Function ( SpriteExample ) ")
var child:Sprite = new Sprite();
child.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
child.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
draw(child);
addChild(child);
}
private function mouseDownHandler(event:MouseEvent):void {
trace("--+ Fired Event ( mouseDownHandler )");
var sprite:Sprite = Sprite(event.target);
sprite.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
sprite.startDrag();
}
private function mouseUpHandler(event:MouseEvent):void {
trace("--+ Fired Event ( mouseUpHandler )");
var sprite:Sprite = Sprite(event.target);
sprite.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
sprite.stopDrag();
}
private function mouseMoveHandler(event:MouseEvent):void {
trace("--+ Fired Event ( mouseMoveHandler )");
event.updateAfterEvent();
}
private function draw(sprite:Sprite):void {
sprite.graphics.beginFill(bgColor);
sprite.graphics.drawRect(0, 0, size, size);
sprite.alpha = .9;
sprite.graphics.endFill();
trace("--! Fired Function ( Draw )")
}
}
}
code within swf
ActionScript Code:
import SpriteExample;
var se:SpriteExample = new SpriteExample();
Display-List Order Problems
Hey,
I'm having trouble with the display list organization of my file. I have some objects that I have dragged to the stage as well as a background perlin noise that I added through the actionscript. The perlin noise clip is sitting on top of all of the other clips and I'm not having much luck figuring out how to get it to sit behind as I am new to as3 and this is making my head spin.
I really appreciate any help that you can give me!!
here is the code for the perlin noise:
PHP Code:
import flash.display.BitmapData;
import flash.geom.Point;
var waves:BitmapData;
var _xoffset:Number = 0;
var _yoffset:Number = 0;
//alter speed number below to change speed of waves
var xspeed:Number = 2;
var yspeed:Number = -1;
waves = new BitmapData(Stage.width, Stage.height, true, 0x00FFFFFF);
var wavesClip:MovieClip = this.createEmptyMovieClip("wavesClip", 2);
wavesClip.attachBitmap(waves,0);
colour_filter.swapDepths(1);
colour_filter._xscale= Stage.width;
colour_filter._yscale= Stage.height;
function onEnterFrame ()
{
var seed = 1000;
_xoffset += xspeed;
_yoffset += yspeed;
var point:Point = new Point (_xoffset,_yoffset)
waves.perlinNoise(600, 100, 1, seed, true, true, 8,false, [point,point]);
}
Display List Invisible To AS3 Debug
It seems like the actionscript 3 debugger does not allow you to browse DisplayObject and DisplayObjectContainer instances that you have created dynamically with addChild() ...like they are invisible.
If I store references to them with variables then I can see the reference but it would be cool to be able to see the whole display list at a glance.
Trying to find them with .numChildren and getChildByName() is like hunting in the dark. Am I doing something wrong?
Trouble Understanding Display List
I'm trying to convert some code to AS3 and having trouble getting my movieclips to appear/show their loaded content.
I think the problem is with my understanding/incorrect utilization of the display list.. can anyone see what i'm doing wrong when i load my images into my clips (i'm assuming this is where i'm screwing up) ???
My movieClip in the library has a class name of 'item' and within it are the icon.inner and ref.inner clips.
code:
Code:
for(i=0; i<numOfItems; i++){
var t:item = new item();
t.angle = i * ((Math.PI*2)/numOfItems); //Math.PI*2 = 360 degrees in flash (flash uses 'radians') then this is divided
//by number of items to create equal spacing.. then multiplied by i to determine which angle
t.toolText = nodes[i].attributes.tooltip;
var toLoad:String = imagePath+nodes[i].attributes.image;
var loader:LoadDisplayObject = new LoadDisplayObject(toLoad, true);
loader.addEventListener("displayObjectLoaded", onComplete, false, 0, true);
t.icon.inner.addChild(loader);
t.ref.inner.addChild(loader);
function onComplete(evt:Event):void {
trace("loaded complete received");
trace ("t loc: "+t.x+" , "+t.y);
}
trace(nodes[i].attributes.image);
t.addEventListener(Event.ENTER_FRAME, mover);
t.icon.addEventListener(MouseEvent.ROLL_OUT, mcOut);
t.icon.addEventListener(MouseEvent.ROLL_OVER, mcOver);
t.icon.addEventListener(MouseEvent.CLICK, mcClick);
home.addChild(t);
}
Determine If An Object Is In The Display List
Does anyone know the command to check whether an object is currently present in the Display List?
I have a TextField called _startHereText. I have some logic where I need to sometimes use RemoveChild to take this object out of the Display List, but I first need to determine if it is presently there.
Create A List From An XML File No Display
I have a multiline Dynamic text box called projList.
I am trying to populate it from an xml file and create a clickable list.
The trace works but cannot get to display the list in the text box.
As far as the clickable goes, haven't gotten that far yet.
Help very much appreciated.
The xml is structured like this:
<?xml version="1.0" ?>
- <images>
- <pic>
<Image>/Butler/Images/sfah2_small.jpg</Image>
<Category>Institutional</Category>
<Proj_title>FRESH AIR HOME</Proj_title>
Please see code below:
import mx.xpath.XPathAPI;
var allproj_xml:XML = new XML();
allproj_xml.ignoreWhite = true;
allproj_xml.onLoad = function(success:Boolean) {
trace("onload...");
if (success) {
trace("success...");
var thePath_str:String = "/images/pic/Proj_title";
var title_array:Array = XPathAPI.selectNodeList(this.firstChild,
thePath_str);
for (var i:Number = 0; i < title_array.length; i++) {
trace(title_array.firstChild.nodeValue);
projList.addItem(title_array.attributes.Proj_title);
}
} else {
trace("error loading XML");
}
};
allproj_xml.load("allimages.xml");
stop();
|