ActionScript 3.0 :: Does AddChild() Add Items Immediately
Jul 4, 2010Since I jumped onto AS3, there are lots of things I'm missing, so I'm now coding in super-safe mode. Ie, in order to place a new mc at z-index 1:
[Code]...
Since I jumped onto AS3, there are lots of things I'm missing, so I'm now coding in super-safe mode. Ie, in order to place a new mc at z-index 1:
[Code]...
When I add a DisplayObject to a DisplayObjectContainer (e.g. a Sprite to a Sprite) in a function, it seems that the DisplayObject is actually added not immediately, but after finishing the function.
See this example:
Code:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
[Code].....
So we have a simple green button, and when it is clicked, there's a red Sprite constructed and added to the stage. But actually the red Sprite isn't visible until the onClick() function has been fully executed.
Why is that and what can I do for the red Sprite to be visible immediately?
Is there some (for the developer invisible) global paint() or update() function, that is not executed until some stack is fully executed or something?
I have a MovieClip called item with the same linkage set and my first task is to display 10 of these items on the stage nested inside a movieclip called MainItem. I have dragged MainItem to the stage and have the following for loop:
[Code]....
I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?
View 8 RepliesI have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
I'm trying to resolve an issue that reared it's ugly head yesterday.Frame one of main timeline I have the following code:
Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
The newMC doesn't show up.If I add 'parent.' in front of the addChild then it appears.mc_LibItem has a base class of "flash.display.MovieClip" and is exporting for ActionScript and on frame one.For grins I created a new .fla and began messing around with the same addChild idea and it worked.
I have a project underway where I am making an interactive game. It is a personal character creator game and I need Actionscript 3 help with this.Something similar here:http:[url]....
I have tried already with toggling visibility and 'gotoAndStop()' to make items appear over other items when the corresponding button is pressed, for example, when the user tries out different pants/shirts on their character.
I would like to use the selectionMode=multiple described in the Flex docs, but with a few modifications:
1) I would like the box that the user drags over the graph to remain there until the user drags a new one.
2) In the top right corner of the box I want to display the sum of the items selected by that box.
How to make list items as tool tips for combo box items?
View 2 RepliesI'm creating a facebook application in flex. I'm actually working on the friends component that shows your friends who are using the application. now, each friend has a profile image.
I created the component using a s:List element.
In the Skin Class of the element i configured the requestedColumnCount to 3, which means it shows 3 friends. i added buttons to scroll left and right in the list.
Whenever I scroll to see a different friend, for a half of a second i see no image because the List component is loading the image in order to view it.
is there a way to make the list preload all the elements so i won't have this kind of problem ?
im having some dificulties in the combobox of Flex 3, after defining the dataProvider and filling the combobox, how can i remove the items in the combobox later (without removing items in the dataprovider)? if i set the provider to "" or null, the items in the combobox are still there
View 1 Repliessomewhat understood the basics of adding and removing children, however, I am facing another problem. After using the removeChild Function, I can't seem to add another child.For example:
ActionScript Code:
var attachedMC = new (getDefinitionByName("Content1") as Class)()
Page.addChild(attachedMC);
[code].....
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
[code]....
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa?
I'm having a problem similar to [url]...
Basically, bmpd.draw and/or png.encode are dog slow, so I'd like to have a nice "please hold while we prepare your png" dialog to appear. I can't use callLater() because of the FileReference.
And just for good measure, the loading screen appears at the same time the save dialog appears from the call to fr.save().
Everytime I start Flash on Acer Laptop Windows XP SP3 it shuts down. It used to run smoothly before. It only happens since I updatet Flash Player.Do you have any idea what's wrong?
View 7 RepliesIn an AIR application I have the following code:
theDialog = PopUpManager.createPopUp( this, TheDialogClass, true ) as TheDialogClass;
theDialog.addEventListener(FlexEvent.CREATION_COMPLETE, cpuIntensiveCalc);
At the end of cpuIntensiveCalc the dialog is removed. The dialog informs the user that "something is going on, please stand by."
The problem is that cpuIntensiveCalc starts before the dialog draws. So the user experience is that the application freezes for 10 seconds with no indicator, then the modal dialog flashes quickly (less than a second) on screen.
The Adobe docs say this about creation_complete
Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing.
So this feels like the correct event. In the name of completeness, I also tried
theDialog = PopUpManager.createPopUp( this, TheDialogClass, true ) as TheDialogClass;
cpuIntensiveCalc();
I need to make a function that execute a java method and return his result. It is static becouse a lot of other functions will call this function. So I did this:
public static function FKDescription(dest:String):String{
var jRemote:RemoteObject = new RemoteObject();
var s:String;
[Code].....
But the function returns null, because the valresult() was not been called at the end of main function. What shoud I do to make FKDescription() return the string that came from remoteobject?
When I add a DisplayObject to a DisplayObjectContainer (e.g. a Sprite to a Sprite) in a function, it seems that the DisplayObject is actually added not immediately, but after finishing the function.[code]...
View 4 RepliesI've setup a very simple FLA, if you wanna see what I'm talking about:ample.zipIf you fire the swf and you click the red thing (button), you will go to frame 2. If you click it again, you will go to frame 1.Both frames contain a green mc with a "this.visible=false" action, so you shouldn't see it the first time.Now click fast the red button. You will see the green mc from time to time.So, seems the flash movie is executing "clicks" every ENTER_FRAME (not immediately when you click the button). The sample mc I attach has a framerate of 1fps, so you can see easily the behaviour, but it's the same with 30fps.
And the same for the green mc. The "this.visible=false" line is not executing immediately when the main timeline reaches the related frame.In the second frame, the green mc is contained inside a red mc. If you break appart this red mc, all will work as it should and you will never see the green mc (the FLA file is attached as well, so you can test).
since my Timer runs every 5 seconds I have to initially execute the function normally. This creates a problem though since if the user has the mouse over the stage, it stops the timer.It cannot do this because it takes 5 seconds before the Timer first runs the function
View 2 Replies[URL].. i am following these tuts but evrything is working fine but what i want is that my music should start playing immediately as it is loaded rather then waiting to click button to play...
[Code]...
I'm using actionscript 2, I've got a preloader working, but now I'm struggling to make an alpha animation play immediately after the preloader. My attempts have ended up with the animation playing during the preloader.
View 2 RepliesBeen having an issue lately with Flash Media Encoder immediately closing down after starting the program. It will display the window for a very brief moment and then close down. I have used the program many times with no issues but this recently started to happen. When it started closing directly after startup the first time, it allowed me to use it a few times afterwards. But recently its not working at all.
View 2 RepliesWho'd have guessed it, my SWF plays immediately with FF, but I'm getting long delays with IE8. I've come a long way from when I started this project. I think I have everything in the right place and have the right files to work with.
I'm using SWFObject 2.2 think I'm using it properly. I used the generater (air vers.) to generate the html file. The file now plays and I have a background that displays right away (it's an image of the what first shows up).
where I can improve: [URL]..I've compressed all the images, but the file is still rather big. I expected problems with FF, but it plays immediately .
I've successfully attached a clip (identifier = "myPane_mc") which contains a ScrollPane (instance name = "myPane_sp") to the main Timeline from the Library. No problem.
attachMovie("myPane_mc","myPane_mc_01",getNextHighestDepth());
However, I can't immediatley load another clip (identifier = "myPic_mc") into the ScrollPane.
attachMovie("myPane_mc","myPane_mc_01",getNextHighestDepth());
myPane_mc_01.myPane_sp.contentPath = "myPic_mc";
Is this particular to the ScrollPane component? It works fine if I place the contentPath code in the next frame of the Timeline, but is there a function that I can attach to myPane_mc_01 to load myPane_sp's content without the additional frame?
I have a two way binding between a loaded flash file and the main application in flex.
BindingUtils.bindProperty(this, "micGainValue", audioPublisherApp, "micVolume");
BindingUtils.bindProperty(audioPublisherApp, "micVolume", this, "micGainValue");
micGainValue=75;
[code]....
In flex component life cycle, after we make some change in a components property, invalidation methods schedules a call to methods like commitProperties, updateDisplayList, etc for some later time. I need to call the updateDisplayList instantaneously. Is there some direct way to do this.
Currently, both the labels are changed simultaneously after completion of the loop. Instead I need it to work like this, to first render the updated 'myButton1' label then enter the loop and then update myButton2's label. I know, it is elastic race track issue, but isn't there some way to achieve this ?[code]...
I can stream video RTMP just fine in JW Player by LongTail Media. The Pause seems to work, however using Windows 7's Resource Monitor I can see that the player continues to download data when the video is paused, it downloads for about 60 seconds (and does not seem to be longer for longer videos). I have found the same using the examples on longtailmedia's website, so I know it is not something I have done.
I want a way to pause the video and have it stop downloading, this will save us lots of bandwidth. But also have it continue where it left off if play is pressed again.
I checked the logs on our wowza media server, which indicates that the player actually waits 60s before it sends the pause command to the server.
LongTail's support say that the pause functionality uses the built in NetStream class and its behaviour is out of their control.
I have tested flowplayer online examples, and a couple of Adobe / OSMF examples and they all continue to download for 60 seconds after the video is paused.
A way to get this working in JW player would be best, but Are there any flash players that will stop downloading while paused?
If this is not possible with RTMP are there any technologies that will do this with a flash player?
I have looked around the web and everything I have seen and tried doesn't work. I am trying to load an external swf (5 of them, seperately though) wait for it to completely load then play it. Whats happening is as soon as I call Loader.load("myswf.swf") it begins to play immediately before its finished downloading. Heres the code..
Code:
var loader:Loader;
var clip:MovieClip;
var isLoaded:Boolean = false;
[Code].....
In the LoadSwf function there is a variable called tut that was created in frame 1, this just happens to be frame 2. I think everything else is self-explanatory.