AddChild() vs addChildAt() methods?

I have the following code:
var container_mc:Container = new Container();
for (var i:int=0;i<4;i++){
var myTrap_mc:MyTrap = new MyTrap();
var myTrapR_mc:MyTrapR = new MyTrapR();
container_mc.addChildAt(myTrap_mc,i);
container_mc.addChildAt(myTrapR_mc,i);
myTrap_mc.rotate=i*90;
myTrapR_mc.rotate=i*90;
container_mc.x=20;
container_mc.y=20;
trace(myTrap_mc.rotate);
trace(container_mc.x+" x");
MyTrap and MyTrapR are sheared rectangles in my Library with Export at Frame 1 selected.  When I test the movie I don't see any objects on the stage.
If I simply declare addChild(myTrap_mc) within the loop it will add one child instead of 4 which is why I tried using a container and adding the children to the container.  Still no beans.
How can I get these sheared rectangles to appear so that they form an 8-pointed star?  This is simply an exercise in drawing shapes dynamically using ActionScript.  (Of course I'm not using ActionScript graphics properties so it's not truly dynamic in that sense).

Well, the container was always superfluous. Your original problem was with the property rotate vs rotation.
But anyway, in authortime in the Flash program you can create a symbol on the stage, give it an instance name say square_mc. Then add that instance to another symbol with an instance name say container_mc. Then to talk to the inside symbol (square_mc) you call it with dot syntax like so: container_mc.square_mc.
Creating the symbol dynamically changes things. Giving a dynamically created object a name using the name property is different than giving an object an instance name using the property panel. Try changing the name incode of a symbol that you named with the property panel, it can't be done. You can't even assign a name to an object that you placed on the stage even if you didn't name it in the first place.
There is never a need to declare a symbol that you have placed inside another symbol in Flash authortime. In fact, I am not even sure how you could do it. Neither var container_mc.contained_mc:MovieClip nor container_mc.var contained_mc:MovieClip work. I played around with some stuff here:
import flash.display.Sprite;
import flash.display.MovieClip;
var mySquare:Square = new Square; //Square is a movieclip in my fla library
var myContainer:MovieClip = new MovieClip; //a dynamically created movieclip
addChild(myContainer); //put the new movieclip on the stage
mySquare.name = "mySquare_mc"; //give the dynamically instance Square an instance name
myContainer.addChild(mySquare); //add it to the container
trace(mySquare.name); //mySquare_mc
trace(myContainer.getChildByName("mySquare_mc")); //[object Square] BTW referencing the object using this method is less efficient than just calling it mySquare
trace(myContainer.mySquare_mc); //undefined. If container is declared as a Sprite instead of a MovieClip, this gives an undefined property error. Truthfully, I am unsure why this doesn't work (at least when the container is a MovieClip). If you put the square inside the container in Flash at authortime with an instance name it works fine. Or even if you add the container dynamically, if it contained a named symbol in the library it still works. There must be some difference between assigning the name property in code and doing it via the property panel.
var mySquareReference2:MovieClip = MovieClip(myContainer.getChildByName("mySquare_mc")); //assign a new reference in memory to mySquare using the dynamically assigned name "mySquare_mc"
trace(mySquareReference2); //[object Square] BTW, mySquareReference2 is the exact same Square as mySquare, just using a different reference

Similar Messages

  • AddChildAt bug?

    Hello there!
    I just figured out a strange behavior of the addChildAt method and would like to share it.
    On the example below we have 2 rectangles. On the Stage MOUSE_CLICK event, it take the rect1 and put it on index 1. The expected behavior, according to the documentation, is to level up all the DisplayObject from that index ahead. So the rectangle rect1 should not change it's index, staying just below rect2. Right? But the Flash still change the positions of the two DisplayObjects, putting the rect1 above the rect2.
    Look:
    var rect1:Sprite = new Sprite();
    rect1.graphics.beginFill( 0x000000 );
    rect1.graphics.drawRect( 0, 0, 150, 150 );
    rect1.x = 100;
    rect1.y = 100;
    var rect2:Sprite = new Sprite();
    rect2.graphics.beginFill( 0xff0000 );
    rect2.graphics.drawRect( 0, 0, 150, 150 );
    rect2.x = 175;
    rect2.y = 175;
    addChild(rect1);
    addChild(rect2);
    this.stage.addEventListener( MouseEvent.CLICK, this.click );
    function click( foo:MouseEvent ):void
         addChildAt( rect1, 1 );
    Conclusion: when a movieclip is sent to the index just above it, the addChildAt method changes it behavior, putting the reordered object above the next one, instead of leveling up the next one and higher levels.
    Is this right? Is this a bug or did I missed anything?
    Thank you,
    CaioToOn!

    Hi, Greg.
    This is why I'm saying that the addChildAt method does not act like the documentation says:
    If you specify a currently occupied index position, the child object that exists at that position and all higher positions are moved up one position in the child list.
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
    If I had sent the DisplayObject (rect1) to the depth 1, that is used by another DisplayObject (rect2), so it should move the rect2 up ( rect1 on depth 1 and rect2 on depth 2), after that, an empty slot would move down all the DisplayObjects again, leaving the rect1 again in 0, and rect2 in 1, changing anything at all, on the display list. Wasn't that the expected?
    Looking further, I just realized that if I move any DisplayObejct to a higher depth that is ocuppied by it, the behavior is also unexpected. In the code below, when a MOUSE_CLICK is dispatched, the movie rect1 is moved to the depth 2. The expected is that the DO rect3 (the one at depth 2), should be moved up with rect4, higher than the depth 2. After that, as the depth 0 became empty, the list should be all moved down. Finishing on rect2 at 0, rect3 at 1, rect1 at 2 and rect4 at 3. But it's not the case.
    var rect1:Sprite = new Sprite();
    rect1.graphics.beginFill( 0x000000, .85 );
    rect1.graphics.drawRect( 0, 0, 150, 150 );
    rect1.x = 100;
    rect1.y = 100;
    var rect2:Sprite = new Sprite();
    rect2.graphics.beginFill( 0xff0000, .85 );
    rect2.graphics.drawRect( 0, 0, 150, 150 );
    rect2.x = 175;
    rect2.y = 175;
    var rect3:Sprite = new Sprite();
    rect3.graphics.beginFill( 0x0000ff, .85 );
    rect3.graphics.drawRect( 0, 0, 150, 150 );
    rect3.x = 50;
    rect3.y = 200;
    var rect4:Sprite = new Sprite();
    rect4.graphics.beginFill( 0x00ff00, .85 );
    rect4.graphics.drawRect( 0, 0, 150, 150 );
    rect4.x = 150;
    rect4.y = 225;
    addChild(rect1);
    addChild(rect2);
    addChild(rect3);
    addChild(rect4);
    this.stage.addEventListener( MouseEvent.CLICK, this.click );
    function click( foo:MouseEvent ):void
    trace(getChildIndex( rect1 ));
    trace(getChildIndex( rect2 ));
    trace(getChildIndex( rect3 ));
    addChildAt( rect1, 2 );
    trace(getChildIndex( rect1 ));
    trace(getChildIndex( rect2 ));
    trace(getChildIndex( rect3 ));
    Thank you for the replies!
    CaioToOn!

  • AddChild gives an error#2006

    When I populate a TabNavigator through mxml, it works
    perfectly
    When I do it using ActionScript with the
    addChild(item:DisplayObject) method i get an out of bounds error.
    How is this possible as i don't manipulate the childIndex?
    =_=
    Hopefully, someone got the same error :(
    Laurent

    Ok, just found an answer..
    the displayObject I am trying to add is a canvas in which I
    just add a children. So I think the chain of addChild method calls
    was too quick and the computer couldn't follow.
    Remember to let some delay between addChild ;)
    Hope, it will help people.
    Laurent

  • Why does addChild(new Shape()) not work?

    I would like to know why the following code does not work:
    <mx:Application>
    private function doShape():void {
    var aShape:Shape = new Shape();
    this.addChild(aShape);
    <mx:Button click="doShape()" />
    </mx:Application>
    according to the docs, addChild() takes a DisplayObject as a
    parameter. Shape is a DisplayObject. However, I get an error
    (#1034) that Shape can't be converted to mx.core.IUIComponent
    I don't understand what the problem is...

    inlineblue -
    Thanks for the advice...
    I was actually converting code over from Flex 1.5 where there
    is a pretty big difference between calling a beginFill()/lineTo()
    method on a UIComponent and attaching a whole new
    Container/MovieClip. In Flex 1.5 the application was so slow I
    trimmed out every container/MovieClip I could.
    If it's not such an issue in Flex 2.0 then I will go with the
    easier to read addChild(new Box()) method.
    Flex harUI - I assume that you mean if I create a new
    UIComponent and then add a Shape for color, I am essentially doing
    the same thing that normal containers like Box (a UIComponent) do
    with their chrome instance (a Shape?).

  • Cannot resolve attribute 'treeDataDescriptor' for component type mx.controls.Tree.

    Hi,
    I'm trying to compile an example from the documentation:
    I have two files :
    treeEx1.mxml
    <?xml version="1.0" encoding="iso-8859-1"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="initCollections()">
    <mx:Script>
    <![CDATA[
    import mx.collections.*;
    import mx.controls.treeClasses.*;
    import customComp.MyCustomTreeDataDescriptor;
    //Variables used to construct the ArrayCollection data
    provider
    //First top-level node and its children.
    public var nestArray1:Object = [
    {label:"item1", children: [
    {label:"item1 child", children: [
    {label:"item 1 child child", data:"child data"}
    //Second top-level node and its children.
    public var nestArray2:Object = [
    {label:"item2", children: [
    {label:"item2 child", children: [
    {label:"item 2 child child", data:"child data"}
    //Second top-level node and its children.
    public var nestArray3:Object = [
    {label:"item3", children: [
    {label:"item3 child", children: [
    {label:"item 3 child child", data:"child data"}
    //Variable for the tree array.
    public var treeArray:Object
    //Variables for the three Array collections that correspond
    to the
    //top-level nodes.
    public var col1:ArrayCollection;
    public var col2:ArrayCollection;
    public var col3:ArrayCollection;
    //Variable for the ArrayCollection used as the Tree data
    provider.
    [Bindable]
    public var ac:ArrayCollection;
    //build the ac ArrayCollection from its parts.
    public function initCollections():void{
    // Wrap each top-level node in an ArrayCollection.
    col1 = new ArrayCollection(nestArray1);
    col2 = new ArrayCollection(nestArray2);
    col3 = new ArrayCollection(nestArray3);
    // Put the three top-level node ArrayCollections in the
    treeArray.
    treeArray = [
    {label:"first thing", children: col1},
    {label:"second thing", children: col2},
    {label:"third thing", children: col3},
    //Wrap the treeArray in an ArrayCollection.
    ac = new ArrayCollection(treeArray);
    // Adds a child node as the first child of the selected
    node,
    // if any. The default selectedNode is null, which causes
    the
    // data descriptor addChild method to add it as the first
    child
    // of the ac ArrayCollection.
    public function clickAddChildren():void {
    var newChild:Object = new Object();
    newChild.label = "New Child";
    newChild.children = new ArrayCollection();
    tree.treeDataDescriptor.addChildAt(tree.selectedNode,
    newChild, 0, ac);
    ]]>
    </mx:Script>
    <mx:Tree width="200" id="tree" dataProvider="{ac}"
    treeDataDescriptor="{new MyCustomTreeDataDescriptor()}"/>
    <mx:Button label="add children"
    click="clickAddChildren()"/>
    </mx:Application>
    and
    and MyCustomTreeDataDescriptor.as :
    package customComp.MyCustomTreeDataDescriptor
    import mx.collections.ICollectionView;
    import mx.collections.IViewCursor;
    import mx.events.TreeModelChangedEvent;
    import mx.events.TreeModelChangedEventDetail;
    import mx.controls.treeClasses.*;
    public class MyCustomTreeDataDescriptor implements
    ITreeDataDescriptor
    // The getChildren method requires the node to be an Object
    // with a children field.
    // If the field contains an ArrayCollection, it returns the
    field
    // Otherwise, it wraps the field in an ArrayCollection.
    public function getChildren(node:Object,
    model:Object=null):ICollectionView
    try
    if (node is Object)
    if(node.children is ArrayCollection){
    return node.children;
    }else{
    return new ArrayCollection(node.children);
    catch (e:Error)
    trace("[Descriptor] exception checking for getChildren");
    return null;
    // The isBranch method simply returns true if the node is an
    // Object with a children field.
    // It does not support empty branches, but does support null
    children
    // fields.
    public function isBranch(node:Object,
    model:Object=null):Boolean
    try
    if (node is Object)
    if (node.children != null)
    return true;
    catch (e:Error)
    trace("[Descriptor] exception checking for isBranch");
    return false;
    // The getData method simply returns the node as an Object.
    public function getData(node:Object,
    model:Object=null):Object
    try
    return Object(node);
    catch (e:Error)
    return null;
    // The addChildAt method does the following:
    // If the node parameter is null or undefined, inserts
    // the child parameter as the first child of the model
    parameter.
    // If the node parameter is an Object and has a children
    field,
    // adds the child parameter to it at the index parameter
    location.
    // It does not add a child to a terminal node if it does not
    have
    // a children field.
    public function addChildAt(node:Object, child:Object,
    index:int, model:Object=null):Boolean
    var event:TreeModelChangedEvent = new
    TreeModelChangedEvent("modelChanged", false, false,
    TreeModelChangedEventDetail.ADD_NODE, child, node, index);
    if (!node)
    var iterator:IViewCursor = model.createCursor();
    iterator.seek(CursorBookmark.FIRST, index);
    iterator.insert(child);
    else if (node is Object)
    if (node.children != null)
    if(node.children is ArrayCollection) {
    node.children.addItemAt(child, index);
    if (model){
    model.dispatchEvent(event);
    model.itemUpdated(node);
    return true;
    else {
    node.children.splice(index, 0, child);
    if (model)
    model.dispatchEvent(event);
    return true;
    return false;
    I have read the docs and looked through some example on this
    form but I still can't figure it out .
    Thanks
    The code above is from:
    http://127.0.0.1:56812/help/topic/com.adobe.flexbuilder.help/html/Part2_DevApps.html
    Using hierarchical data providers

    I hav echnaged it and now I get :
    A file found in an source-path must have the same package
    structure 'customComp', as the definition's package,
    'customComp.MyCustomTreeDataDescriptor'.
    I tried different variations but nothing seems to work. I
    have the following folder structure:
    \Lessons
    \customComp
    .MyCustomTreeDataDescriptor.as
    treeEx1.mxml
    Thanks

  • How to resize watermark to be the same size for vertical/horizontal images?

    I am using File -> Place menu to place my watermark onto the images. 
    No matter what I try so far, the absolute size of the watermark comes out different Portrait/Landscape images.
    Watermark is smaller on Portrait and larger on Landscape images.  I tried resizing writing in the number of pixels during the File->place command, but no luck.  Photoshop resizes the watermark based on the percentages, and I don't know why image orientation matters. 
    ideally I want my watermark to be the same size, and I can use absolute pixel dimensions if needed.  How do I do this?

    Hi Doug - What exactly are you trying to do? Is the third
    child being added dynamically, and you want it added above the
    first child? If so, you can use the addChildAt() method when adding
    the child to the container. addChildAt() takes an index and the
    child object is added at that index and all other children are
    reshuffled to maintain the ordering. IE:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:TitleWindow layout="vertical" id="tw">
    <mx:Button id="a" />
    <mx:Button id="b" click="go();"/>
    </mx:TitleWindow>
    <mx:Script>
    <![CDATA[
    private function go():void
    var c:Button = new Button();
    c.label="new";
    tw.addChildAt(c, 0);
    ]]>
    </mx:Script>
    </mx:Application>
    Does that help, or am I misinterpreting what you're trying to
    do?

  • How can I get a container to be the same size as all its children

    In my TitleWindow, I have two children that size themselves
    dynamically.
    No problem, TitleWindow also sizes itself to completely show
    both children.
    Now I have an additional child that I can only position
    correctly if I set TitleWindow's layout parameter to absolute.
    The third child now positions itself correctly on top of the
    first child.
    But now TitleWindow is only as big as the first child and I
    have to scroll to see the second child.
    How can I force TitleWindow to be the size it was when layout
    was set to vertical?
    Doug

    Hi Doug - What exactly are you trying to do? Is the third
    child being added dynamically, and you want it added above the
    first child? If so, you can use the addChildAt() method when adding
    the child to the container. addChildAt() takes an index and the
    child object is added at that index and all other children are
    reshuffled to maintain the ordering. IE:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:TitleWindow layout="vertical" id="tw">
    <mx:Button id="a" />
    <mx:Button id="b" click="go();"/>
    </mx:TitleWindow>
    <mx:Script>
    <![CDATA[
    private function go():void
    var c:Button = new Button();
    c.label="new";
    tw.addChildAt(c, 0);
    ]]>
    </mx:Script>
    </mx:Application>
    Does that help, or am I misinterpreting what you're trying to
    do?

  • Removing a Video Stream From The Stage

    what I have:
    main.swf 1 frame
    btns load various external.swfs
    I have 3
    one swf (commercial.swf)has a slideshow inside using the SlideShowPro component Not the flv player
    problem: stream remains after swf is swapped out with new.
    AS code  main timeline
    var Xpos:Number = 0;
    var Ypos:Number = 0;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/home.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
        removeChild(loader);
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
        loader.load(newSWFRequest);
        loader.x = Xpos;
        loader.y = Ypos;
        addChild(loader);
    // Btn listeners
    home.addEventListener(MouseEvent.CLICK, btnClick);
    bio.addEventListener(MouseEvent.CLICK, btnClick);
    commercial.addEventListener(MouseEvent.CLICK, btnClick);
    NOW
    home and bio.swf's have _mc's inside
    the commercial.swf has the slideshow pro component inside
    once commercial.swf is on stage after another btn is clicked the audio remains.
    slide show pro is being used not an .flvPlayer
    I need to know where the code to stop the stream goes in the main.swf or the swf with the slideshow component?

    I did get somewhere, I have a few different main.swfs I used as I was experimenting. I have one that uses  UI loaders to load all the static (no videos inside) swfs to the main timeline those work fine
    Also in that main.swf I have one loader being called by the loader class which also works. But I still had the stream remaining problem. I was able to add another set of event listeners that call the "unload and stop" method on the same buttons for my main navigation that call the gotoandstops to frames and they now unload the commercial.swf (which is the only swf I have using the slideshow pro component AND stop the stream as well.
    Here's what I have
    in main.swf
    gotoAndStop("home");
    btn_home.addEventListener(MouseEvent.CLICK, btn_home_click);
    function btn_home_click(evt:MouseEvent):void {
        gotoAndPlay("home")
    btn_bio.addEventListener(MouseEvent.CLICK, btn_bio_click);
    function btn_bio_click(evt:MouseEvent):void {
        gotoAndPlay("bio")
    btn_commercial.addEventListener(MouseEvent.CLICK, btn_commercial_click);
    function btn_commercial_click(evt:MouseEvent):void {
        gotoAndStop(12)
    // event listeners for unloads
    btn_home.addEventListener("click",afterClick);
    btn_bio.addEventListener("click",afterClick);
    function afterClick(e:MouseEvent):void {
        ldr.unloadAndStop();
    as layer of frame 12 only loader class
    var ldr:Loader = new Loader();
    var url:String = "commercial.swf";
    var urlReq:URLRequest = new URLRequest(url);
    ldr.load(urlReq);
    addChild(ldr);
    this method will unload and stop commercial.swf when the home_btn or bio_btn buttons are clickedI did not try this using the UI Loader
    So I now will either need to use just the loader class to call all the swfs (like a variable) what I had used before and have the afterclick function in the home and bio in all the buttons (which I will add later)
    I hope this helps as there has to be a solution.
    thanks again for all your help by the way.
    rd

  • Can't remove a node from a tree

    I am using the custom tree dataDescriptor provided in Flex live
    doc. It works for creating the tree and add notes, however when I
    try to remove a node from the tree it cant work. Does anyone have
    any idea?
    This is the code for MyCustomeTreeDataDescriptor.as
    package
    import mx.collections.ArrayCollection;
    import mx.collections.CursorBookmark;
    import mx.collections.ICollectionView;
    import mx.collections.IViewCursor;
    import mx.events.CollectionEvent;
    import mx.events.CollectionEventKind;
    import mx.controls.treeClasses.*;
    public class MyCustomTreeDataDescriptor implements
    ITreeDataDescriptor
    // The getChildren method requires the node to be an Object
    // with a children field.
    // If the field contains an ArrayCollection, it returns the
    field
    // Otherwise, it wraps the field in an ArrayCollection.
    public function getChildren(node:Object,
    model:Object=null):ICollectionView
    try
    if (node is Object) {
    if(node.children is ArrayCollection){
    return node.children;
    }else{
    return new ArrayCollection(node.children);
    catch (e:Error) {
    trace("[Descriptor] exception checking for getChildren");
    return null;
    // The isBranch method simply returns true if the node is an
    // Object with a children field.
    // It does not support empty branches, but does support null
    children
    // fields.
    public function isBranch(node:Object,
    model:Object=null):Boolean {
    try {
    if (node is Object) {
    if (node.children != null) {
    return true;
    catch (e:Error) {
    trace("[Descriptor] exception checking for isBranch");
    return false;
    // The hasChildren method Returns true if the node actually
    has children.
    public function hasChildren(node:Object,
    model:Object=null):Boolean {
    if (node == null)
    return false;
    var children:ICollectionView = getChildren(node, model);
    try {
    if (children.length > 0)
    return true;
    catch (e:Error) {
    return false;
    // The getData method simply returns the node as an Object.
    public function getData(node:Object,
    model:Object=null):Object {
    try {
    return node;
    catch (e:Error) {
    return null;
    // The addChildAt method does the following:
    // If the parent parameter is null or undefined, inserts
    // the child parameter as the first child of the model
    parameter.
    // If the parent parameter is an Object and has a children
    field,
    // adds the child parameter to it at the index parameter
    location.
    // It does not add a child to a terminal node if it does not
    have
    // a children field.
    public function addChildAt(parent:Object, child:Object,
    index:int,
    model:Object=null):Boolean {
    var event:CollectionEvent = new
    CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
    event.kind = CollectionEventKind.ADD;
    event.items = [child];
    event.location = index;
    if (!parent) {
    var iterator:IViewCursor = model.createCursor();
    iterator.seek(CursorBookmark.FIRST, index);
    iterator.insert(child);
    else if (parent is Object) {
    if (parent.children != null) {
    if(parent.children is ArrayCollection) {
    parent.children.addItemAt(child, index);
    if (model){
    model.dispatchEvent(event);
    model.itemUpdated(parent);
    return true;
    else {
    parent.children.splice(index, 0, child);
    if (model)
    model.dispatchEvent(event);
    return true;
    return false;
    // The removeChildAt method does the following:
    // If the parent parameter is null or undefined, removes
    // the child at the specified index in the model.
    // If the parent parameter is an Object and has a children
    field,
    // removes the child at the index parameter location in the
    parent.
    public function removeChildAt(parent:Object, child:Object,
    index:int, model:Object=null):Boolean
    var event:CollectionEvent = new
    CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
    event.kind = CollectionEventKind.REMOVE;
    event.items = [child];
    event.location = index;
    //handle top level where there is no parent
    if (!parent)
    var iterator:IViewCursor = model.createCursor();
    iterator.seek(CursorBookmark.FIRST, index);
    iterator.remove();
    if (model)
    model.dispatchEvent(event);
    return true;
    else if (parent is Object)
    if (parent.children != undefined)
    parent.children.splice(index, 1);
    if (model)
    model.dispatchEvent(event);
    return true;
    return false;
    This is my tree definition:
    <mx:Tree width="143" top="0" bottom="0" left="0"
    height="100%"
    id="publicCaseTree"
    dataDescriptor="{new MyCustomTreeDataDescriptor()}"
    dataProvider="{ac}"
    defaultLeafIcon="@Embed('assets/caseIcon.png')"
    change="publicTreeChanged(event)"
    dragEnabled="true"
    dragMoveEnabled="false"/>
    This is how I remove the selected node from the tree. When
    Delete button is clicked, the doDeleteCase function is
    exectuted.
    public function publicTreeChanged(event:Event):void {
    selectedNode =
    publicCaseTree.dataDescriptor.getData(Tree(event.target).selectedItem,
    ac);
    public function doDeleteCase(event:Event):void{
    publicCaseTree.dataDescriptor.removeChildAt(publicCaseTree.firstVisibleItem,
    selectedNode, 0, ac);
    Any help would be appreciated.Thanks.

    Finally I removed nodes from tree, but not sure I did in the
    right way. Anybody encounter the same problem, please
    discuss.

  • Attach movie in as3

    Hey all, I'm fairly new to flash, but I can do a few things,
    I had a
    good flash program going in as1, which I'm trying to convert
    to as3.
    I had asked on irc for some help, but it was touching on
    subjects I have
    not covered on as, and even after looking up and applying,
    its causing
    countless problems.
    1) My application receives information currently from echoed
    information
    from a db onto a html page, which flash is able to feed in
    e.g. (echo
    &var+rowvar+&).
    I'm considering xml although I'm unsure about benefits or
    anything
    2)in as1 my application could simple do a for loop with the
    number being
    passed in via the number of rows in the database which was
    echoed onto
    the page then fed into flash.
    Do for loops act the same in as3?
    3)I was attaching a movie clip multiple times, which I need
    to get to
    act all independent of each other, so each one needs its own
    name, as1
    this was possible via "_root.attachMovie("button","btn"+i,
    100+i);"
    and this is where the main problem is, as I was asking about
    this,
    attachmovie no longer works, and I got told to sort out
    "linkage" which
    I have done, then setting up class and using addchild. which
    I have
    tried... but it does not work and I cannot get around.
    reading up on it, documents say addchild should enable the
    object to be
    displayed. which for me isnt happening.
    Here are the list of problems I have been getting:
    -An ActionScript file must have at least one externally
    visible
    definition. so I looked it up, and I figured I have to put up
    a
    package and public class (athough I do not understand
    class's)
    which resulted in the error
    -TypeError: Error #1006: addChild is not a function. at
    global$init()
    which sounds great...
    messing around got me to
    -5008: The name of definition 'test' does not reflect the
    location of
    this file. Please change the definition's name inside this
    file, or
    rename the file. z:\location\index.as
    so I changed the class "test" to "index" where I encountered
    more
    problems...
    [code]
    var page1:page_mc = new page_mc ();
    this.addChild(page1);
    [/code]
    [code]
    package
    import flash.display.MovieClip;
    public class index extends MovieClip
    public function index()
    trace('lol');
    [/code]
    and by the way, I have tried using addchild on frame1 of the
    fla, with
    no results.
    I'm sure I'm missing something at the biginning because
    looking up every
    problem and getting more errors seams silly for something
    that was so
    easy in as1, that I would need so much code to stop problems
    of 1
    function..)
    Thanks in advance
    Slpixe

    Slpixe,
    > 1) My application receives information currently from
    > echoed information from a db onto a html page, which
    > flash is able to feed in e.g. (echo
    &var+rowvar+&).
    I'm with ya so far.
    > I'm considering xml although I'm unsure about
    benefits>
    > or anything
    If you're passing in a handful of name/value pairs, you
    probably don't
    need XML. By what you're describing, it sounds like you're
    using FlashVars,
    or passing these variables into the SWF as a query in the
    HTML. The benefit
    to FlashVars is that the SWF has access to these values
    immediately upon
    load. You don't have to take measures to load the data
    yourself, and then
    to respond to onLoad events, and so on -- they're just
    magically there.
    Prior to AS3, those variables are scoped to the main
    timeline, as if you
    had declared them there in frame 1. In AS3, you can use the
    same technique,
    but the variables are scoped as properties of the parameters
    property of a
    LoaderInfo instance associated with the main timeline. Sounds
    like a
    mouthful, but all it means is that you have to path to the
    incoming
    variables:
    this.loaderInfo.parameters.myVar1;
    this.loaderInfo.parameters.myVar2;
    this.loaderInfo.parameters.myVar3;
    If you have tons of hierarchical data, or data that don't
    lend
    themselves to simple name/value pairs, XML will help
    considerably. Of
    course, you'll have to load the XML, then navigate among your
    nodes to
    retrieve the information, but AS3's E4X syntax makes this
    much easier than
    it was to do the same with XML in AS1/AS2.
    > 2)in as1 my application could simple do a for loop with
    the
    > number being passed in via the number of rows in the
    database
    > which was echoed onto the page then fed into flash.
    > Do for loops act the same in as3?
    Yes.
    > 3)I was attaching a movie clip multiple times, which I
    need to
    > get to act all independent of each other, so each one
    needs
    > its own name, as1 this was possible via
    "_root.attachMovie
    >("button","btn"+i, 100+i);"
    Okay.
    > and this is where the main problem is, as I was asking
    about this,
    > attachmovie no longer works, and I got told to sort out
    "linkage"
    > which I have done,
    Meaning, instead of a linkage identifier, a linkage class.
    > then setting up class and using addchild. which I have
    tried... but
    > it does not work and I cannot get around.
    Heh. Well, it does work, I promise you that. ;) So it should
    just be
    a matter of stepping through the approach you're using to see
    what's going
    awry when.
    > reading up on it, documents say addchild should enable
    the
    > object to be displayed. which for me isnt happening.
    The addChild() method originates with the
    DisplayObjectContainer class,
    which means you need an instance of that class as a reference
    when you
    invoke the method. Makes sense, right? You couldn't
    instantiate an an
    array, for example, and do this:
    var arr:Array = new Array();
    arr.addChild(someVisualObject);
    ... because the Array class doesn't support the addChild()
    method. It's the
    DisplayObjectContainer class that does, so you can only add
    objects to the
    display list of an object that supports display lists.
    Fortunately, the main timeline is (usually) an instance of
    the MovieClip
    class, and MovieClip inherits much of its functionality from
    the
    DisplayObjectContainer class. Even when the main timeline is
    configured as
    a sprite, it still inherits the functionality in question,
    because the
    family tree goes like this: DisplayObjectContainer -->
    Sprite -->
    MovieClip.
    So all you really need, in theory, is to invoke that method
    on any movie
    clip symbol's instance name, or on a reference to the main
    timeline, and
    your object should show up.
    > Here are the list of problems I have been getting:
    > -An ActionScript file must have at least one externally
    visible
    > definition. so I looked it up, and I figured I have to
    put up a
    > package and public class (athough I do not understand
    class's)
    I'm assuming, then, that your code -- at least, currently --
    all appears
    in keyframes?
    > which resulted in the error
    > -TypeError: Error #1006: addChild is not a function. at
    global$init()
    > which sounds great...
    Hrrrm.
    > messing around got me to
    > -5008: The name of definition 'test' does not reflect
    the location of
    > this file. Please change the definition's name inside
    this file, or
    > rename the file. z:\location\index.as
    So then, it sounds like you're putting your code inside a
    file named
    index.as, which means (by the rules of how Flash operates)
    that you're
    defining a class called index. If you're using the class
    keyword to define
    this class, it means you'll have to use the word "index" as
    the name of your
    class, because class names have to match the names of the
    files in which
    they're defined.
    > so I changed the class "test" to "index" where I
    encountered more
    > problems...
    >
    > [code]
    > var page1:page_mc = new page_mc ();
    > this.addChild(page1);
    > [/code]
    To me, it looks like you've put these first few lines ahead
    of your
    package and class declarations. That's now how class files
    work. All of
    your code must be sandwiched inside the package or (usually)
    class
    declaration. Otherwise, you're not writing a class at all
    (which is fine)
    ... but then, you need to use the include directive (just
    like AS1/AS2's
    #include), which simply pulls the code in at compile time as
    if it were
    typed in a timeline keyframe.
    In this code:
    > [code]
    > package
    > {
    > import flash.display.MovieClip;
    >
    > public class index extends MovieClip
    > {
    > public function index()
    > {
    > trace('lol');
    > }
    > }
    > }
    > [/code]
    You're defining a class named index that extends MovieClip.
    That means
    index *is* a movie clip, which means it has available to it
    all the
    functionality defined by the MovieClip class. If you were to
    invoke
    addChild() from some method *inside* this class declaration,
    it would work
    ... because the addChild() method is supported by movie
    clips.
    > and by the way, I have tried using addchild on frame1 of
    the fla,
    > with no results.
    Mixing and matching is fine. You can indeed use timeline
    code alone in
    AS3, or class code alone, or a combination of both. I wonder
    if you're just
    "in too deep" with the file you have? I recommend you brush
    away the
    distractions and start a fresh, new FLA file.
    In that file, draw a quick shape -- just a circle, say --
    and convert it
    to a movie clip. Right-click on that symbol in the Library
    and choose
    Linkage. Select "Export for ActionScript" and give this thing
    a linkage
    class (for example, Circle).
    When you click OK to close the dialog box, Flash will warn
    you that no
    such class (Circle) exists, and offers to write that class
    for you. Click
    OK.
    Now enter frame 1 and use the Actions panel to type these
    lines:
    var orb:Circle = new Circle();
    addChild(orb);
    The variable orb (just an arbitrary name) is typed as Circle
    -- which is
    the class Flash just wrote for you -- and set to an instance
    of that class.
    In the Linkage dialog box, you will have seen that the Circle
    class extends
    MovieClip, so this isn't much different from instantiating a
    new movie clip
    in AS3.
    Finally, the DisplayObjectContainer method, addChild(), adds
    your Circle
    instance to the display list of the main timeline. You could
    precede the
    addChild() reference with the "this" keyword, but even
    without it, Flash
    understands that you're refering to the timeline in which
    this code appears.
    And because that timeline is a descendent of the
    DisplayObjectContainer
    class, the method works.
    David Stiller
    Co-author, The ActionScript 3.0 Quick Reference Guide
    http://tinyurl.com/2s28a5
    "Luck is the residue of good design."

  • How do I do to add and remove Shape3D objects dynamically from TransfGroup?

    Hi, everyone,
    How do I do to add and remove Shape3D objects dynamically from TransformGroup?
    I have added two Shape3D objects in the TransformGroup and I wanted to remove one of it to add another. But, the following exception occurs when I try to use �removeChild� :
    �Exception in thread "AWT-EventQueue-0" javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be removed at javax.media.j3d.Group.removeChild(Group.java:345)�.
    Why can I add Shape3D objects and I can�t remove them? Do I need to add Shape3D object in the BranchGroup and work only with the BranchGroup? If I do, I think this isn�t a good solution for the scene graph, because for each Shape3D object I will always have to use an associated BranchGroup.
    Below, following the code:
    // The constructor �
    Shape3D shapeA = new Shape3D(geometry, appearance);
    shapeA.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeA.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeA.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeA.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    Shape3D shapeB = new Shape3D(geometry, appearance);
    shapeB.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeB.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeB.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeB.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    BranchGroup bg = new BranchGroup();
    bg.setCapability(ALLOW_CHILDREN_READ);
    bg.setCapability(ALLOW_CHILDREN_WRITE);
    bg.setCapability(ALLOW_CHILDREN_EXTEND);
    TransformGroup tg = new TransformGroup();
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    tg.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
    tg.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
    bg.addChild(tg);
    tg.addChild(shapeA);
    tg.addChild(shapeB);
    // The method that removes the shapeB and adds a new shapeC �
    Shape3D shapeC = new Shape3D(geometry, appearance);
    shapeC.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    shapeC.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
    shapeC.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    shapeC.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
    tg.removeChild(shapeB);
    tg.addChild(shapeC);Thanks a lot.
    aads

    �Exception in thread "AWT-EventQueue-0"
    javax.media.j3d.RestrictedAccessException: Group:
    only a BranchGroup node may be removed I would think that this would give you your answer -
    Put a branch group between the transform and the shape. Then it can be removed.
    Another thing you could try: This doesn't actually remove the shape, but at least causes it to hide. If you set the capabilities, I think you can write the appearance of the shapes. So, when you want to remove one of them, write an invisible appearance to it.

  • Xml gallery with thumbnails & next/previous buttons.

    hallo all the wise people,
    sorry to bother you, but i'm kind of desperate, and nobody around to ask, so....
    i've spend now three full days editing an xml gallery... to my needs, and always goes messy, so maybe it's time give up and make my own from the scratch, or looking from a one closer to my needs =/ (helpless).
    could anyone help - maybe any of you by some chance knows a link as close as possible to tutorial/source as3 fla to sthg as close as possible to this:
    a) xml gallery
    b) thumbnails
    c) when thumbnail clicked a big picture shows
    d) next/previous buttons possible
    otherwise, i can also post the code of my gallery where i absolutely can't add next/previous buttons without making a big mess =/
    i will be totally youbie doubie grateful for any help... any, if you only know any good link, 'll try to fugure out a tutorial or edit the source myself....
    thanks in advance

    heyyyo wise one,
    at least this is really  nice of you to ask -  this gallery really makes me by now feel twice as blond as i am 8-0. but this is kinda really nested.
    the xml structure goes like this (this is easy and more or, less standard)(Caption is neglectable, probabaly i will not even display it, unless i have some extra time):
    <MenuItem>
             <picnum>01</picnum>
             <thumb>thumbs/Image00001.jpg</thumb>  
             <picture>Image00001.jpg</picture>
       <Caption>Fist Title</Caption> 
    </MenuItem>
    uaaha, then the as goes. there is the URLloader, but also two different loaders inside (one for the thumbnails, one for the big picture). and this is all inside a for each loop -eh... i was always trying to change the pictLdr behavior - the loader, that loads the big picture.
    anyway the URL loader, and the main function, which is attached to it go like this:
    var myXML:XML = new XML();
    var XML_URL:String = "gallery_config.xml";
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    var myLoader:URLLoader = new URLLoader(myXMLURL);
    myLoader.addEventListener("complete", xmlLoaded);
    // Create the xmlLoaded function
    function xmlLoaded(event:Event):void
    // Place the xml data into the myXML object
        myXML = XML(myLoader.data);
        // Initialize and give var name to the new external XMLDocument
    var xmlDoc:XMLDocument = new XMLDocument();
    // Ignore spacing around nodes
        xmlDoc.ignoreWhite = true;
    // Define a new name for the loaded XML that is the data in myLoader
        var menuXML:XML = XML(myLoader.data);
    // Parse the XML data into a readable format
        xmlDoc.parseXML(menuXML.toXMLString());
        // Access the value of the "galleryFolder" node in our external XML file
    for each (var galleryFolder:XML in myXML..galleryFolder)
       // Access the value of the "pagenum" node in our external XML file
               var galleryDir:String = galleryFolder.toString();
    //trace (galleryDir);
    //trace (galleryFolder);//output taki sam jak powyżej
    // inicjuję variable flag, która bedzie trzsymac nazwę klikniętego thumbnail
    var flag2:String = null;
    // Set the index number of our loop, increments automatically
    var i:Number = 0;
    // Run the "for each" loop to iterate through all of the menu items listed in the external XML file
    for each (var MenuItem:XML in myXML..MenuItem)
    // Access the value of the "picnum" node in our external XML file
        var picnum:String = MenuItem.picnum.toString();
    // Access the value of the "pagetext" node in our external XML file
        var Caption:String = MenuItem.Caption.toString();
    // Access the value of the "thumb" node in our external XML file
        var thumb:String = MenuItem.thumb.toString();
    // Access the value of the "pagepicture" node in our external XML file
        var picture:String = MenuItem.picture.toString();
    // Just some trace I used for testing, tracing helps debug and fix errors
    //trace(picnum);
    var thumbLdr:Loader = new Loader();
        var thumbURLReq:URLRequest = new URLRequest(galleryDir + thumb);
        thumbLdr.load(thumbURLReq);
    // Create MovieClip holder for each thumb
    var thumb_mc = new MovieClip();
    thumb_mc.addChild(thumbLdr);
    addChildAt(thumb_mc, 1);
      // Create the rectangle used for the clickable button we will place over each thumb
      var rect:Shape = new Shape;
      rect.graphics.beginFill(0xFFFFFF);
      rect.graphics.lineStyle(1, 0x999999);
      rect.graphics.drawRect(0, 0, 80, 80);      
      // Create MovieClip holder for each button, and put that rectangle in it,
      // make button mode true and set it to invisible
      var clip_mc = new MovieClip();
      clip_mc.addChild(rect);
      addChild(clip_mc);
      clip_mc.buttonMode = true;
      clip_mc.alpha = .0;
         // The following four conditionals create the images where the images will live on stage
      // by adjusting math through each row we make sure they are laid out good and not stacked
      // all on top of one another, or spread out in one long row, we need 4 rows, so the math follows
      if (picnum < "05")
           line1xpos = line1xpos + distance; // These lines place row 1 on stage
        clip_mc.x = line1xpos;
        clip_mc.y = yPlacement;
        thumb_mc.x = line1xpos;
        thumb_mc.y = yPlacement;
       else  if (picnum > "04" && picnum < "11")
        line2xpos = line2xpos + distance; // These lines place row 2 on stage  
        clip_mc.x = line2xpos;
        clip_mc.y = 86;
        thumb_mc.x = line2xpos;
        thumb_mc.y = 86;
       else  if (picnum > "10" && picnum < "14")
        line3xpos = line3xpos + distance; // These lines place row 3 on stage
        clip_mc.x = line3xpos;
        clip_mc.y = 172;
        thumb_mc.x = line3xpos;
        thumb_mc.y = 172;
       else  if (picnum > "13" && picnum < "21")
       line4xpos = line4xpos + distance; // These lines place row 4 on stage
       clip_mc.x = line4xpos;
       clip_mc.y = 258;
       thumb_mc.x = line4xpos;
       thumb_mc.y = 258;
       // And now we create the pic loader for the larger images, and load it into "pictLdr"
       var pictLdr:Loader = new Loader();
       var pictURL:String = picture;
          var pictURLReq:URLRequest = new URLRequest(galleryDir + picture);
       //var pictURLReq:URLRequest = new URLRequest("gallery/Image00004.jpg");sprawia,ze zawsze wyswitla sie jeden obrazek
          pictLdr.load(pictURLReq);
       // Access the pic value and ready it for setting up the Click listener, and function
          clip_mc.clickToPic = pictLdr;
       // Access the text value and ready it for setting up the Click listener, and function
       clip_mc.clickToText = Caption;
       //var instName:String = flag();
       // Add the mouse event listener to the moviClip button for clicking
          clip_mc.addEventListener (MouseEvent.CLICK, clipClick);
          // Set the function for what happens when that button gets clicked
       function clipClick(e:Event):void
         // Populate the parent clip named frameSlide with all of the necessary data
         MovieClip(parent).frameSlide.gotoAndPlay("show"); // Makes it appear(slide down)
         MovieClip(parent).frameSlide.caption_txt.text = e.target.clickToText; // Adds the caption
         MovieClip(parent).frameSlide.frame_mc.addChild(e.target.clickToPic); // Adds the big pic
       } // This closes the "for each" loop
    } // And this closes the xmlLoaded function
    and the effect looks like this (it's a sketch, so big pictures are loaded randomly, don;t put too much attention to it): http://bangbangdesign.pl/xmlGallery/gallery29.swf
    but i guess it's a terrible stuff to go through all this. i would be totallly satisfied with a likng to a good tutorial to do it from scratch, or just a hint where to start rebuilding this.
    + in any case i send greetinngs to whereever you are =]

  • Align Stage to center of PasteBoard (or window when exported)

    Hi everyone!
    I think there's something wrong with my flash =/
    I'm doing some tests and I'm trying to create a simple presentation. It's not something I'll be using online. I just want it to present some things at school. Since I don't know the resolution of the monitor at school, I wanted something I could max the window and rest with the content (stage) centered.
    At start, everything was working fine but sudenly the stage started to be aligned to top left when exported and windows maximized.
    Here's my code:
    stop(); //LOADING BACKGROUND var myImage:URLRequest = new URLRequest ("bkg.swf"); var bkgLoader:Loader = new Loader (); var container:MovieClip = new MovieClip(); function imageLoaded (e:Event):void {      container.addChild(bkgLoader);      addChildAt(container,0); } bkgLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, imageLoaded); bkgLoader.load(myImage); //NEXT & PREVIOUS BUTTONS next_btn.addEventListener(MouseEvent.CLICK, goSlide); prev_btn.addEventListener(MouseEvent.CLICK, goSlide); function goSlide (e:MouseEvent):void { } 
    The bkg.swf is an external background I'm using... it ajusts it's size to fill all the window automaticaly.
    When I first wrote this code, it was working fine. Than I added some objects and MC's to the stage and now whenever I export the file it's aligned to the top left of my window.
    If I remove all the code (//LOADING BACKGROUND), it works fine =/
    Thanks!

    Oh my! You again?
    Andrei, I just saw your answer to our other thread, but I really need to solve this before getting back there.
    Well, the .swf I'm importing is already doing the "full screen" thing since it will adjust itself to the size of the window.
    The problem is that the content on the stage (or the stage itself) is aligned to TopLeft when I do a CTRL+Enter to export the movie from Flash.
    Normally, when I create any flash file, when I export it, the content is always at the center on the .swf preview window, no matter the size of this preview window.
    I'll take this little presentation to the university next week. I'll just open the .swf and maximize it to start the presentation. The problem is that when I do so, the background (imported swf) is there, filling all the background, but my content (stage) becomes aligned to TopLeft of the window.
    ps.: To solve this problem I can simply create a html file to load the background (imported swf) and than load just my presentation over it. But there must be a way to solve this problem inside Flash, without going to html... =/

  • 3D Carousel

    Hi everyone,
    Please help. I have script for a 3d Carousel everything works. But I want to get the images to stay facing the front.
    I can change most things but am having trouble with getting the images front facing.
    The property y.rotation I need to change is not in the same fuction as so I can't dinamically change the value using the eventlistner.
    I have tried to do this but have had no success.
    p.rotationY = 90; is the value I need to change dynamically but it is in the cacheimages section function initLoadCache(evt:Event):void. I need to be able to get this into the function render(e:Event):void from the addEventListener(Event.ENTER_FRAME, render); which is also in the function initLoadCache(evt:Event):void {
    I think I can figure the rest out but need some help to figure this out.  
    Script:
    var scene:Scene3D;
    var cam:Camera3D;
    var _numActiveImage:uint;
    var p_link:Boolean;
    var total:Number;
    var url_thumb:Array;
    var container:Sprite;
    container= new Sprite();
    addChild(container);
    var anglePer:Number;
    var p_dict:Dictionary
    var pc:Plane
    var numOfRotations:Number = 1;
    var yPos:Number;
    yPos= 0;
    var angle:Number;
    angle= 0;
    var angle2:Number;
    angle2= 0;
    var camX:Number;
    ///////////////////////////////////////////////////////// removeAllChildren ////////////////////////////////////////////////////////////////////////////////
    function removeAllChildren(_container : DisplayObjectContainer, _index : uint = 0):void{
       var _numChild : uint = _container.numChildren;
       if (_numChild > _index){
        for (var i:int = _index; i < _numChild; i++) {
         _container.removeChildAt(_container.numChildren - 1);
    buildCategory();
    create_thumbnail();
    /////////////////////////////////////////////////////// create_thumbnail //////////////////////////////////////////////////////////////
    function create_thumbnail():void {
    removeEventListener(Event.ENTER_FRAME, render);
    if(container) {
    if (Tweener.getTweenCount(container) > 0) Tweener.removeTweens(container);
    removeAllChildren(container, 0);
    removeChild(container);
    subpageInfo(_counterPage);
    url_thumb = [];
    total = subPageArr.length;
        for( var j:uint = 0; j < total; j++ ){
      url_thumb.push(subPageArr[j]._thumb);
    container = new Sprite();
    addChild(container);
    addChildAt(container, (getChildIndex(fullscreen_mc)-1));
    //addChildAt(fullscreen_mc, getChildIndex(container));
    scene = new MovieScene3D(container);
    cam = new Camera3D();
    p_dict= new Dictionary();
    pc= new Plane();
    pc.visible = false;
    cam.target = pc;
    yPos = 0;
    angle = 0;
    cam.zoom = 0.5;
    cam.y = 700;
        p_link = false;
    anglePer = ((Math.PI*2) * numOfRotations) / total;
        cacheImages(url_thumb);
    addChildAt(categoryMc,(getChildIndex(container)+1));
    function p_rollover(me:MouseEvent) {
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 1, 0.5, 0.6, true);
    function p_rollout(me:MouseEvent) {
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 0.5, 1, 0.6, true);
    function p_click(me:MouseEvent) {
    if(!p_link) {
    p_link = !p_link;
    var sp:Sprite = me.target as Sprite;
    var s_no:Number = parseInt(sp.name.slice(3,6));
    _numActiveImage = s_no;
    onResizeStageApp();
    new Tween(gallery1, 'alpha', Strong.easeOut, 0, 1, 1, true);
    gallery1.visible = true;
    openImage();
    //_page.visible = true;
    function render(e:Event):void {
    if(container) {
    container.x = stage.stageWidth/2;
    container.y = stage.stageHeight/2;
    var dist2:Number = ((stage.mouseX) - stage.stageWidth/2) * 0.0001;
    angle += dist2;
    //test
    p.rotationY += angle;
    //testEnd
    if(!p_link) {
    cam.y += ((stage.mouseY) * 0.04 - cam.y) * 0.08;
    cam.x += (- Math.cos(angle) * 350-cam.x) * 0.08;
    cam.z += (Math.sin(angle) * 350-cam.z) * 0.08;
    var new_zoom = 3 - stage.mouseY * 0.002;
    cam.zoom += ( new_zoom - cam.zoom ) * 0.06;
    for( var i:uint = 0; i < total; i++ ){
       container.getChildByName("btn_sh" + i).y += (0-container.getChildByName("btn_sh" + i).y)*0.1;
          container.getChildByName("btn_sh" + j).alpha = 0.1;
    }else{
      for( var j:uint = 0; j < total; j++ ){
       container.getChildByName("btn_sh" + j).y += (-120-container.getChildByName("btn_sh" + j).y)*0.1;
      container.getChildByName("btn_sh" + j).alpha = 0.05;
    cam.y += ( 0 - cam.y ) * 0.2;
    cam.zoom += ( 9 - cam.zoom ) * 0.06;
    scene.renderCamera(cam);
    /////////////////////////////////////////////////////// cacheImages /////////////////////////////////////////////////////////////////
    var totalImages:Number;
    var indexIm:Number;
    var _loaderCacheImages:ImageLoader;
    var _arrCacheImages:Array;
    var _currContentCache:MovieClip;
    function cacheImages(_arr:Array){
    _txtLoadInfo.visible = true;
    addChildAt(_txtLoadInfo,(getChildIndex(container)+1));
    totalImages = _arr.length;
    indexIm = 0;
    _arrCacheImages = [];
    _arrCacheImages = _arr;
    var targetIm:String = _arrCacheImages[indexIm];
    _loaderCacheImages = new ImageLoader(targetIm);
    _loaderCacheImages.addEventListener(ProgressEvent.PROGRESS, progressCacheImages);
    _loaderCacheImages.addEventListener(Event.INIT, initLoadCache);
    function initLoadCache(evt:Event):void {
    var _bitmapThumb:Bitmap = evt.target.urlImgData;
    _bitmapThumb.smoothing = true;
      var bfm:BitmapMaterial = new BitmapMaterial(_bitmapThumb.bitmapData);
      bfm.oneSide = false;
      bfm.smooth = true;
      var p:Plane = new Plane(bfm, 180, 110, 2, 2);
      scene.addChild(p);
      var p_container:Sprite = p.container;
      p_container.name = "btn" + indexIm;
      p_dict[p_container] = p;
      p_container.buttonMode = true;
      p_container.addEventListener( MouseEvent.ROLL_OVER, p_rollover );
      p_container.addEventListener( MouseEvent.ROLL_OUT, p_rollout );
      p_container.addEventListener( MouseEvent.CLICK, p_click );
      var p1:Plane = new Plane(bfm, 180, 110, 2, 2);
      scene.addChild(p1);
      var p_container1:Sprite = p1.container;
      p_container1.name = "btn_sh" + indexIm;
      p_container1.alpha = 0.1;
      p_dict[p_container1] = p1;
      p1.rotationY = (-indexIm*anglePer) * (180/Math.PI) + 90;
      p1.rotationX = 180;
      if(total >=10) {
      p1.x = Math.cos(indexIm * anglePer) * 29*total;
      p1.z = Math.sin(indexIm * anglePer) * 29*total;
      }else{
      p1.x = Math.cos(indexIm * anglePer) * 40*total;
      p1.z = Math.sin(indexIm * anglePer) * 40*total;
      p1.y = -110;
      p.rotationY = 90;
      if(total >=10) {
      p.x = Math.cos(indexIm * anglePer) * 29*total;
      p.z = Math.sin(indexIm * anglePer) * 29*total;
      }else{
      p.x = Math.cos(indexIm * anglePer) * 40*total;
      p.z = Math.sin(indexIm * anglePer) * 40*total;
    indexIm ++;
    if (indexIm < totalImages){
      var targetIm:String = _arrCacheImages[indexIm];
      _loaderCacheImages = new ImageLoader(targetIm);
      _loaderCacheImages.addEventListener(ProgressEvent.PROGRESS, progressCacheImages);
      _loaderCacheImages.addEventListener(Event.INIT, initLoadCache);
    }else{
    indexIm = 0;
    _txtLoadInfo.text = "";
    _txtLoadInfo.visible = false;
    _loaderCacheImages.removeEventListener(ProgressEvent.PROGRESS, progressCacheImages);
    _loaderCacheImages.removeEventListener(Event.INIT, initLoadCache);
    _loaderCacheImages = null;
    container.alpha = 0;
    onResizeStageApp();
    Tweener.addTween(container, {alpha:1, time:2});
    addEventListener(Event.ENTER_FRAME, render);
    if(!loadSite) gotoAndStop(6);
    function progressCacheImages(evt:ProgressEvent):void{
    var _progressDataArr:Array = evt.target.progressImgArr;
    var _bLoaded:Number = Number(_progressDataArr[0]);
    var _bTotal:Number = Number(_progressDataArr[1]);
    var loadPercent:int = Math.round(_bLoaded / _bTotal * 100);
    _txtLoadInfo.text = "Loading thumb ... " + indexIm + "  " + loadPercent + "%";
    _txtLoadInfo.x = Math.round((stage.stageWidth - _txtLoadInfo.width)/2);
    _txtLoadInfo.y = Math.round((stage.stageHeight - _txtLoadInfo.height)/2);

    SM6601: you obviously do not want to be helped here -
    dzedward and myself have been here for years
    and tens of thousands of helpful posts between us - if you
    are not satisfied with the quality/result
    of tutorials and samples after googling - do NOT take it out
    on us. How about you learn from the
    tons of tutorials we pointed to you and you make them better
    if you can? Then you can write your own
    tutorial and we can then point others to it who have the same
    level of perfection you do ok?
    If nothing else - please use another forum - there's no need
    for attitude like yours. Sorry for not
    meeting your expectations.
    Chris Georgenes
    Adobe Community Expert
    www.mudbubble.com
    www.keyframer.com
    www.howtocheatinflash.com
    SM6601 wrote:
    > Why waste your time if you don't have a solution. Go
    back to being a god at flashgods.org.

  • How do I set layers

    how can i set the layer priority as my action script mc plays
    over top of my 3d rendered movie
    all help appreciated

    yes, as i mentioned, as3 has other ways of dealing with
    z-ordering. in you situation, when you add a star to the display
    list, instead of using addChild(), use addChildAt() to control the
    z-ordering of your stars.
    now, if your planets are also children of "this", you should
    be ok. if planets are not children of "this", then you will need to
    alter the index of one of your planet ancestors and one of your
    start ancestors. those ancestors are the closest (to stars and
    planets, resp) that where both ancestors have the same parent
    ancestor.

Maybe you are looking for

  • CProjects 4.0 - SAP R/3 4.7 - Accounting Integration problem.

    Dear all, I have performed all steps necesaary for accounting integration in cProjects and SAP R/3 FI System. I can even see and assign the cost rate that I have created in cProjects to a project role. System also calculates the  cost for the role mu

  • Jdeveloper 10.1.2 creating jar files in user's temporary director

    Hi all, McAfee uses 100% of my PC CPU every once in a while when jdevw.exe creates jar files in C:\Documents and Settings\wase\Local Settings\Temp. They get created at seemingly random times while I am running the embedded OC4J in debug mode (Struts,

  • Recording Live Concerts from Soundboard (Macbook 2012)

    Hey there, new to the forum. Decided to sign in after discovering and reading on here that my Mac was built with out the option for input on the headphone jack. So I have an external sound card for home recording but I am looking for the easiest way

  • No delete options of an app folder in iCloud Drive

    I've install recently a File Manager app (File Hub), that created a folder in my iCloud Drive. I've deleted the app but the folder remains in iCloud Drive and the bin stays grey when the folder is selected. Any ideas?

  • Can you specify format mask for date or timestamp columns

    Hi, Recently when I'm developing a PL/SQL application, I find that any format mismatch between data in table and format mask specified in to_date/to_timestamp function will cause exceptions. However, I'd like to make my application more robust and im