Trying to dynamically Rotate a Dynamically Created Movie Clip

Hi As3 Gods...
I want to rotate a movieClip that is created and animated by a function in the same Code window.
var electron:MovieClip=new MovieClip
createElectron(electron)
electron.rotation=90 ------> I expect the whole animated MovieClip to rotate. nothing happens though.
// I have a function that receives the electron and build / animates it
function createElectron( receives the MovieClip + more parameters ):MovieClip
{ bunch of codes
returns the MovieClip
It is achievable if I create an external MovieClip through library, and put the createElectron codes inside that movieClip and export it to ActionScipt and then rotate it, but then i donno how to assign Parameters to an external function in the movieClip when i call the electron, i want to be able to tell the function what is the radius, speed, etc. I have never tried creating Classes, donno if it helps me here or not. I think i m failing to sort of WRAP the MOvieClip and the animation inside, so i can rotate the whole thing when returned.

var electronsH:Array=new Array
var electron:Sprite = new Sprite();
buildElectronBeam(8,50,50)
function buildElectronBeam(atom,repeatHorizontal,wide)
             For loop{
                   var electron2:Sprite = new Sprite();
                  singleElectron(radius,4,electron2)  // here i send electron2 to be animated and built up in the called function
                  electron2.rotation=90 // This does rotate the electron but not the animation defined for it.
                   electronsH[h]= electron2
                   addChild(electronsH[h]) // shows that animation is still horizontal
function singleElectron(radius,pixel,electron:Sprite)
createPoint(pixel)
    function createPoint(radio:uint)
        electron.graphics.beginFill(0xFFFFFF,1)
        electron.graphics.drawRect(0,0,pixel,pixel)
        addChild(electron)
        electron.addEventListener(Event.ENTER_FRAME, movepixels) 
     function Animatepixels(e:Event)
     {   pixel starts to spin on a horizontal line}
I think my problem is I dont know how to attach this animation to be part of the MovieClip so i Can rotate the whole thing. What i was trying to achieve here is to say flash "Consider whatever going on in this singleElectron function as my MovieClip" but as we both see, electron is the movieClip and animate function just performs something without being a part of MovieClip itself.

Similar Messages

  • Problem with accessing dynamically created movie clips, returns null...

    Hopefully this is a stupid question with an easy answer, if my code is straight forward enough.
    I am using this snippet of code to create menu items, and then use the jCount variable below to give the clips an index number, like so (which seems to be working just fine):
    for(var j:Number=0;j<xmlSubMenuLength;j++){ 
        var mcSubMenuItem:mcSubMenu=new mcSubMenu();   
        addChild(mcSubMenuItem);    
        jCount++;   
        mcSubMenuItem.name = "mcSubMenuItem" + jCount;
        //traces out names correctly
        trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
        mcSubMenuItem.x=mcMenuHolder.x+20;
        mcSubMenuItem.y =mcMenuHolder.y;
        mcSubMenuItem.y+= nextBtnY;
        nextBtnY+=subtopicSpace;
        global_subi.text = String(jCount); //i see the proper count of 10 in the text field
    However, when I try to access the clips using this snippet:  
    for(var j:Number=0;j<Number(global_subi.text);j++)//
      trace("GLOBAL SUBI = "+ String(global_subi.text));  //traces out 10, which it should
      var scSubMenuItem:String = "mcSubMenuItem" + j;  
      var scSubContent:Object = this.getChildByName(scSubMenuItem);
      trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent); //returns null!
    My last trace statement returns null. Can anyone see my error, or explain why I can't access my clips after they have been created?
    Thank you muchly,
    ~Chipleh

    Hi kglad,
    Thanks for the response.
    "it's not clear from the shown code that jCount is initialized." - I've posted the relevant code below, which shows that I'm initializing jCount.
    "and it's not clear why you don't use j instead of jCount in that for-loop" - j is used as loop for creating the subtopic movie clips within the i for-loop. So, for each topic in i for-loop, create a group of suptopics using the j for-loop. The j for-loop re-initiates j every time the length of the subtopics is reached(if that makes any sense) - i.e. topic1>subtopic 1,2,3,4 : topic2>subtopic>1,2 : topic3>subtopic1,2,3,4
    jCount is used to keep a running count of the total number of subtopcs created - i.e. per the example above, jCount will display 10.
    var topicSpace:uint=button_mc.height;
    var subtopicSpace:uint = button_mc.height;
    var nextBtnY:uint = 0;//whatever;
    var jCount:Number = 0;
    function createXMLMenu(menuLength:Number,itemName:XMLList):void{
         var navItemText:XMLList = itemName;
          for(var i:Number=0;i<menuLength;i++)
               var mcMenuItem:mcMenu=new mcMenu();        
               addChild(mcMenuItem); 
               mcMenuItem.btnTxt.htmlText = i+1 +". " +navItemText[i];  
               mcMenuItem.ivar = i;  
               mcMenuItem.name = "mcMenuItem" + i;  
               mcMenuItem.x=mcMenuHolder.x;
               mcMenuItem.y =mcMenuHolder.y;
              //kglad's addition
               mcMenuItem.y+= nextBtnY;
               nextBtnY+=topicSpace; 
               var subVar:Number = i;//mcMenuItem.ivar 
               //Submenu content
               var xmlSubMenuLength:Number = xml.sim.bodyText.page[i].subpage.length()
               var menuItemAttachment:MovieClip = MovieClip(mcMenuItem); 
               for(var j:Number=0;j<xmlSubMenuLength;j++)
                     var xmlSubPageNumber:XMLList = xml.sim.bodyText.page[subVar].subpage;
                     var subNavLinkNumber:Number = xmlSubPageNumber[j];
                     var subTitleText:String = xml.sim.bodyText.page[subVar].subpage.subNavItem[j];
                     var mcSubMenuItem:mcSubMenu=new mcSubMenu();
                     trace("mcSubMenuItem.ivar = "+ j+1);
                     var mc2Attach2:MovieClip = MovieClip(menuItemAttachment);
                     mcSubMenuItem.btnTxt.htmlText = j+1 +". " +subTitleText;   
                     mcSubMenuItem.ivar = Number(subVar);
                     mcSubMenuItem.jvar = Number(j);
                     addChild(mcSubMenuItem);
                     jCount++;   
                     mcSubMenuItem.name = "mcSubMenuItem" + jCount;
                     trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
                     mcSubMenuItem.x=mcMenuHolder.x+20;
                     mcSubMenuItem.y =mcMenuHolder.y;
                     //kglad's addition
                     mcSubMenuItem.y+= nextBtnY;
                     nextBtnY+=subtopicSpace;    
                     global_subi.text = String(jCount);
                mcSubMenuItem.lExtend.visible = false;  
    global_i.text = String(i);
    Then I try to access the clips like so:
    -The first for-loop access the topic movie clips, no problem, and traces out scContent correctly.
    -The second for-loop traces out null everytime, when I would expect it to be tracing out the names of the subtopic movie clips.
    function accessClips(){
         //This will access the topic movie clips
         for(var i:Number=0;i<Number(global_i.text);i++)
               var scMenuItem:String = "mcMenuItem" + i;
               var scContent:Object = this.getChildByName(scMenuItem);            
               trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scContent:Object = "+ scContent);
         //This is supposed to access the subtopic movie clips
         for(var j:Number=0;j<Number(global_subi.text);j++)//
               var scSubMenuItem:String = "mcSubMenuItem" + j;
               var scSubContent:Object = this.getChildByName(scSubMenuItem);
               trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent);
    Hope this makes sense, Chipleh confused. If the code is not clear enough, let me know and I'll try to further clarify.
    Thanks again,
    ~Chipleh

  • Rotate a dynamilly created movie clip?

    I need to rotate this[PhotoMovieName]. But the registration
    point is the
    upper left corner. I want them to rotate on center.
    Is there a way to do this. Can I change the registration
    point with AS?
    PhotoArray = new
    Array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg");
    //trace(PhotoArray.length);
    for(i=0;i<PhotoArray.length;i++){
    trace(PhotoArray
    PhotoMovieName = "Photo"+i;
    var container:MovieClip =
    this.createEmptyMovieClip(PhotoMovieName,
    this.getNextHighestDepth());
    this[PhotoMovieName].loadMovie("Photo.swf");
    //this[PhotoMovieName].Photo_ldr._x=0;
    //this[PhotoMovieName].Photo_ldr._y=-50;
    this[PhotoMovieName]._rotation = 15*i;
    this[PhotoMovieName]._y = 200;
    this[PhotoMovieName]._x = 200;
    //this[PhotoMovieName].contentPath = PhotoArray;
    //this[PhotoMovieName].Photo_ldr.load();
    //trace(this[PhotoMovieName]._x+"----"+this[PhotoMovieName]._y);
    Thanks,
    Jason

    Jason,
    >I need to rotate this[PhotoMovieName]. But the
    registration point
    > is the upper left corner. I want them to rotate on
    center. Is there a
    > way to do this. Can I change the registration point with
    AS?
    ActionScript doesn't let you change an asset's registration
    point, but
    the workaround is pretty easy. In your case (ActionScript
    1.0/2.0) you'll
    create a containing clip first, then create another inside it
    -- as you're
    doing -- then offset the inner clip's midpoint to meet the
    registration
    point of the container.
    var container:MovieClip = this.createEmptyMovieClip(
    PhotoMovieName, this.getNextHighestDepth()
    So far, so good, right? Nothing has chnaged yet. Now,
    because you've
    created the variable container, and because the
    MovieClip.createEmptyMovieClip() method returns a reference
    to the newly
    created clip, may use the container variable in place of
    this[PhotoMovieName] -- because the reference to that clip is
    stored in
    container.
    container.loadMovie("Photo.swf");
    Again, that's functionally identical to the earlier version,
    this[PhotoMovieName].loadMovie("Photo.swf"); ... now, the
    important part at
    this point is to *wait* until Photo.swf has loaded. Until it
    does, you
    can't really continue, as you've done, with rotation, x, and
    y settings. If
    you go the route of loadMovie(), you basically have to set up
    a loop
    (setInterval(), say, or onEnterFrame) and repeatedly check
    the
    MovieClip.bytesLoaded() and bytesTotal() methods of your
    container clip
    until the loaded bytes meet the total. Here's some detail on
    that process
    http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded/
    ... Finally, you'll want to bump the loaded left by half its
    width and up by
    half its height -- then move the container to compensate. So,
    how do
    reference the loaded clip inside the container? Aha! Well,
    once Photo.swf
    is loaded, it's container effectively *is* the loaded asset.
    You'll need
    two containers, then. An outer and an inner.
    var outer:MovieClip = this.createEmptyMovieClip(
    PhotoMovieName, this.getNextHighestDepth();
    var inner:MovieClip = outer.createEmptyMovieClip("mcInner",
    0);
    inner.loadMovie("Photo.swf");
    outer.onEnterFrame = function():Void {
    if (inner.getBytesLoaded() >= inner.getBytesTotal()) {
    inner._x -= inner._width / 2;
    inner._y -= inner._width / 2;
    this._x += inner._width / 2;
    this._y += inner._width / 2;
    this._rotation = 45;
    delete this.onEnterFrame;
    A couple key things to note: again, the variable outer
    refers to
    whatever string is contained by the PhotoMovieName variable.
    This time,
    there's also an inner clip inside that one. The inner clip is
    basically
    taking the place of your original container. Once loading
    starts, a loop
    checks the loading SWF, as described in that blog link, and
    when the SWF has
    finished, inner is offset left and up, outer is offset right
    and down, and
    finally outer is rotated.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Need help returning correct name from a code created movie clip

    Hello. I am an AS3 n00b with hopefuly a simple question I am designing a simple game in flash. This code creates an array of movie clips and asigns a picture to each one. It is a map screen. What I need is when I click on one of the created movie clips, I need it to return either the index of the clip in the array or the name of the clip. Basicaly anything I can use to tell them apart in the code. Here is the code:
    import flash.display.MovieClip;
    var MapLoader:Array = new Array();
    var strJPGext:String = ".jpg";
    var intContTileNumber:int;
    var strContTilePath:String;
    var intDistStartX:int = 63;
    var intDistStartY:int = 64;
    var intDistMultiplyY:int = 0;
    var intDistMultiplyX:int = 0;
    var intDistCount:int = 0;
    var MapSquare:Array = new Array();
    for (var i:int = 0; i < 729; i++)
             //var MapSquare:MovieClip = new MovieClip();
            MapSquare.push (new MovieClip());
            MapSquare[i].x = intDistStartX + (intDistMultiplyX * 30);
            MapSquare[i].y = intDistStartY + (intDistMultiplyY * 30);
            MapSquare[i].name = "MapSquare" + i ;
            addChild(MapSquare[i]);
            intContTileNumber = i;
            MapLoader.push (new Loader);
            strContTilePath = intContTileNumber + strJPGext;
            MapLoader[i].load(new URLRequest(strContTilePath));
            MapSquare[i].addChild(MapLoader[i]);
            intDistCount++;
            intDistMultiplyX++;
            if (intDistCount > 26){
            intDistCount = 0;
            intDistMultiplyX = 0;
            intDistMultiplyY++;
    stage.addEventListener(MouseEvent.CLICK, reportClick);
    function reportClick(event:MouseEvent):void
        trace("movieClip Instance Name = " + event.target.name);   
    Now all this works fine, it creates the map and assigns the correct picture and places them in the correct X,Y position and it is the correct grid of 27x27 squares. The problem is with the name, when I click on the movie clip, it returns "Instance2" or "Instance5" or whatever. It starts with 2 and then increases each number by 3 for each clip, so the first one is 2, then 5 then 8 and so on. This is no good. I need it to return the name that I assigned it
    . If I put the code in trace(MapSquare[1]) it will return the name "MapSquare1" so I know the name was assigned, but it isnt returning.
    Please assist
    Thanks,
    -red

    Thanks for the resopnse,
    I know I dont really need the name, I just need the index number of the array, but I cant figure out how to get the index name without specificaly coding for it. That is why in the listener event I use event.target.name because I dont know what movie clip is being clicked until it has been clicked on. Basically when a movie clip is clicked it needs to return which index of the array was clicked.
    I could do it this way:
    MapSquare[0].addEventListener(
      MouseEvent.MOUSE_UP,
      function(evt:MouseEvent):void {
        trace("I've been clicked!");
    MapSquare[1].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    MapSquare[2].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    ... ect
    but that is unreasonable and it kind of defeats the purpose of having the array in the first place. The code that each movie clip executes is the same, eventualy that index will be passed into a database and the data at that primary key will be retrieved and returned to the program. So I just need to know, when one of those buttons is clicked, which one was clicked and what is its index in the array.
    I am a VB programer and in VB this is very easy, the control array automatically sends its own index into the function when one of the buttons is clicked. It seems simple enough, I just dont know how to do it in action script.
    Thanks again,
    -red

  • Dynamically placing movie clip at the angle and global position of a mouse click (button) which is constantly rotating.

    Does anyone know the code for finding the global positioning of  X & Y co-ordinates of a click of a button which is constantly rotating,
    and then secondly the code for when you click on the button it  displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it  (so underneath the buttons are still rotating so other people can click them where they are)
    to explain the context, I'm trying to design a mock up of a circular interactive table
    when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the top.
    I've included my .fla file which shows the four buttons moving and a little diagram
    explaining what I'm trying to do.

    yourbutton.addEventListener(MouseEvent.CLICK,f);
    function f(e:MouseEvent){
    var yourmc:MovieClip=new YourMC();
    yourmc.x=e.stageX;  // if you want the mouse position where the button was clicked.  else use e.currentTarget.x and e.currentTarget.y
    yourmc.y=e.stageY;
    yourmc.rotation=e.currentTarget.rotation;
    addChild(yourmc);

  • Dynamically call movie clips

    I am creating an animation that has a rotating globe that
    then fades out and that is attached dynamically. I created 3 movie
    clips that I need to bring in while the globe animation is going
    and before it fades out. I need the movie clips to come in AFTER
    the globe has started spinning, and then one at a time play. Then
    once the last logo has come in, the globe should fade out. I need
    to do this all dynamically in AS. I have the globe animation but it
    fades out automatically not when the logos are done, and I figured
    out how to bring in the movie clips but not at the right time. I'm
    very new to Flash and AS and I just can't figure out how to do it.
    Can anyone point me in the right direction?
    The script for the globe is as follows:

    If there is a loop function somewhere for the motion, then
    you could probably delay the logos loading by setting a counter
    that triggers their loading when it reaches x number of rotations,
    say counter = 1, load first logo, counter = 2, load second logo,
    etc... counter = 4, fade the earth.
    By the code you show above, the logos would be appearing
    instantly, so what you could do is have them added thru a function
    instead. That function gets called based on the counter value in
    the earth looping code.
    If the file is reasonably small, I'd be willing to give it a
    looking over to see if I can offer some suggestions specific to
    what you already have.

  • Center a dynamically generated movie clip

    Hello,
    I have created an empty movie clip in the root, I load
    dynamically some jpg to the empty movie clip, but now I want to
    center it and I can't :(
    I have this code, it centers the movie clip but on the
    registration point of 0,0 not in the middle of the movie clip so
    the movie clip will show up nice and centered.

    use:
    imageholder_mc._x = Stage.width - imageholder_mc._width / 2;
    EDIT: lmao kg :)

  • Detecting Rotation Amount to Control Movie Clips

    I created a movie clip consisting of a bar and a knob.  When you click and drag the knob, the bar rotates through 360 degrees.  I want to be able to detect the degree of rotation and use that metric to control other movie clips.  The code to make the drag/rotate object work is...
    handle.knob.onPress = function(){
    handle.onMouseMove = function(){
      var angle = Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
      this._rotation = angle*180/Math.PI;
      this.knob._rotation = -this._rotation;
      trace(angle);
      trace(angle*180/Math.PI);
    handle.onMouseUp = function(){
    if (this.onMouseMove) delete this.onMouseMove;
    I can trace the angle in radians and degrees but I don't know how to extract either value as a variable that can be used in a function to control a separate movie clip.

    assign a variable to have the value of the _rotation or angle in your onMouseMove function.   and use that variable's value wherever you like.

  • Accessing dynamically created movieclips

    I have an application that I am adding movieclips to a
    container movieclip through a for loop and repeatedly calling
    myClip.addChild(theNewClip). Now I have a dozen clips in my
    container and it seems like the only way to access the clip is to
    use the getChildByName() method and cast it into a temporary clip
    so I can get at the its properties.
    Is this the best and/or only way to do this? Does the old AS2
    myContainer["theName"].property not work with dynamically created
    movieclips? It doesn't seem to work for me anymore.
    Anyway I am getting the clips now, but I was hoping someone
    could show me a better way to access a dynamically created movie
    clip.

    In AS3, this is probably not much better, but you can
    generically loop through all movie clips:

  • Help! Remove Movie Clips

    OK...here's my problem... I am making a portfolio site and I
    have my thumbnails being created dynamically through XML...very
    similar to the galleries example in the Sample and Tutorials. Only
    problem is that I have multiple keyframes with different thumbnails
    that need to be displyed through a different XML file. I got it to
    work but the thumbnails from the first frame are still showing on
    the second frame...How do I remove the dynamically created movie
    clips?

    OK...here's the code...At thebottom of the document, I need
    to remove the clips created on the next button. This is the same
    code from the gallery sample file; I just added my own XML file.
    stop();
    import mx.transitions.*;
    _global.thisX = 30;
    _global.thisY = 70;
    _global.stageWidth = 600;
    _global.stageHeight = 400;
    var gallery_xml:XML = new XML();
    gallery_xml.ignoreWhite = true;
    gallery_xml.onLoad = function(success:Boolean) {
    try {
    if (success) {
    var images:Array = this.firstChild.childNodes;
    var gallery_array:Array = new Array();
    for (var i = 0; i<images.length; i++) {
    gallery_array.push({src:images
    .firstChild.nodeValue});
    displayGallery(gallery_array);
    } else {
    throw new Error("Unable to parse XML");
    } catch (e_err:Error) {
    trace(e_err.message);
    } finally {
    delete this;
    gallery_xml.load("gallery_practices2.xml");
    function displayGallery(gallery_array:Array) {
    var galleryLength:Number = gallery_array.length;
    for (var i = 0; i<galleryLength; i++) {
    var thisMC:MovieClip =
    this.createEmptyMovieClip("image"+i+"_mc", i);
    mcLoader_mcl.loadClip(gallery_array.src, thisMC);
    preloaderMC = this.attachMovie("preloader_mc",
    "preloader"+i+"_mc", 5000+i);
    preloaderMC.bar_mc._xscale = 0;
    preloaderMC.progress_txt.text = "0%";
    thisMC._x = _global.thisX;
    thisMC._y = _global.thisY;
    preloaderMC._x = _global.thisX;
    preloaderMC._y = _global.thisY+20;
    if ((i+1)%5 == 0) {
    _global.thisX = 20;
    _global.thisY += 80;
    } else {
    _global.thisX += 80+20;
    var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadStart = function() {
    mclListener.onLoadProgress = function(target_mc, loadedBytes,
    totalBytes) {
    var pctLoaded:Number =
    Math.round(loadedBytes/totalBytes*100);
    var preloaderMC =
    target_mc._parent["preloader"+target_mc.getDepth()+"_mc"];
    preloaderMC.bar_mc._xscale = pctLoaded;
    preloaderMC.progress_txt.text = pctLoaded+"%";
    mclListener.onLoadInit = function(evt:MovieClip) {
    evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
    var thisWidth:Number = evt._width;
    var thisHeight:Number = evt._height;
    var borderWidth:Number = 2;
    var marginWidth:Number = 8;
    evt.scale = 8;
    evt.lineStyle(borderWidth, 0x000000, 100);
    evt.beginFill(0xFFFFFF, 100);
    evt.moveTo(-borderWidth-marginWidth,
    -borderWidth-marginWidth);
    evt.lineTo(thisWidth+borderWidth+marginWidth,
    -borderWidth-marginWidth);
    evt.lineTo(thisWidth+borderWidth+marginWidth,
    thisHeight+borderWidth+marginWidth);
    evt.lineTo(-borderWidth-marginWidth,
    thisHeight+borderWidth+marginWidth);
    evt.lineTo(-borderWidth-marginWidth,
    -borderWidth-marginWidth);
    evt.endFill();
    evt._xscale = evt.scale;
    evt._yscale = evt.scale;
    evt._rotation = Math.round(Math.random()*-10)+5;
    evt.onPress = function() {
    this.startDrag();
    this._xscale = 30;
    this._yscale = 30;
    this.origX = this._x;
    this.origY = this._y;
    this.origDepth = this.getDepth();
    this.swapDepths(this._parent.getNextHighestDepth());
    this._x = (_global.stageWidth-evt._width+30)/2;
    this._y = (_global.stageHeight-evt._height+30)/2;
    mx.transitions.TransitionManager.start(this,
    {type:mx.transitions.Photo, direction:0, duration:1,
    easing:mx.transitions.easing.Strong.easeOut, param1:empty,
    param2:empty});
    evt.onRelease = function() {
    this.stopDrag();
    this._xscale = this.scale;
    this._yscale = this.scale;
    this._x = this.origX;
    this._y = this.origY;
    evt.onReleaseOutside = evt.onRelease;
    mcLoader_mcl.addListener(mclListener);
    next_btn.onRelease= function() {
    gotoAndStop(2);
    back_btn.onRelease= function() {
    gotoAndStop(1);
    }

  • Adding f:Attribute dynamically to a dynamically created Button

    Hi ,
    I am trying to dynamically create a CommandButton and attach a f:Attribute to the same. But somehow I am not able to get hold of the correct API to do the same -
    >RichCommandButton button=new RichCommandButton();
    >button.setText("Ok");
    >AttributeTag attr=new AttributeTag();
    >attr.setValue("DC_OPERATION_BINDING", "bindings.DENY");
    >button.getChildren().add(attr);
    The issue is that the add method expects a UIComponent and attr is of type com.sun.faces.taglib.jsf_core.AttributeTag

    gues u can use it like
    button.getAttributes().put(DC_OPERATION_BINDING", "bindings.DENY");
    {code}
    http://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/component/UIComponent.html#getAttributes%28%29                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to dynamically create sqlldr control file using stored procedure

    I am trying to dynamically create the control file (.ctl) and execute the same using a stored procedure.I would be passing the file name as a parameter to this procedure. How do I go about doing this?
    The control file has the following structure. The file name (mktg) varies and is passed as an input to the stored procedure.
    SPOOL mktg.ctl
    LOAD DATA
    INFILE 'mktg.csv'
    INTO TABLE staging
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    (COMPANY_NAME,
    ADDRESS,
    CITY,
    STATE,
    ZIP)
    SPOOL OFF ;
    sqlldr scott/tiger CONTROL= mktg.ctl LOG=mktg.log BAD=mktg.bad

    We are using oracle 9i rel 2.
    I have not had much success with the creation of log and bad files using external tables when they are being used within a dynamic sql.
    Plz check this:
    Re: problems related to data loads from excel, CSV files into an oracle 9i db

  • Dynamically Create Repeater Element in ActionScript

    Hi,
    I'm trying to dynamically create a repeater control with an
    image and a label control. I can do it directly in the MXML file
    but when I try and covert it into ActionScript it's not working.
    Can anyone see what the problem is with my code?
    public function GetPalettes():void{
    removeChild(document.FrontPage);
    Palettes.method = "GET";
    params = {"method": "GetPalettes", "BodyPartNo":
    document.PalettesMenu.selectedItem.@partNo};
    Palettes.cancel();
    Palettes.send(params);
    var VerticalBox:VBox = new VBox();
    VerticalBox.x = 10;
    VerticalBox.y = 10;
    VerticalBox.id = "VerticalBox";
    var PaletteRepeater:Repeater = new Repeater();
    PaletteRepeater.dataProvider =
    "{Palettes.lastResult.Palette}";
    PaletteRepeater.startingIndex = 0;
    PaletteRepeater.id = "PaletteRepeater";
    var PaletteImage:Image = new Image();
    PaletteImage.setStyle("HorizontalAlign", "left");
    PaletteImage.source = "
    http://localhost/Flex/Personalised%20Palettes-debug/{PaletteRepeater.currentItem.@PictureS rc}Med.png";
    PaletteImage.useHandCursor = true;
    PaletteImage.buttonMode = true;
    PaletteImage.mouseChildren = false;
    PaletteImage.id = "PaletteImage";
    var PaletteDescription:Label = new Label();
    PaletteDescription.text =
    "{PaletteRepeater.currentItem.@Description}";
    PaletteDescription.id = "PaletteDescription";
    document.MainPage.addChild(VerticalBox);
    VerticalBox.addChild(PaletteRepeater);
    PaletteRepeater.addChild(PaletteImage);
    PaletteRepeater.addChild(PaletteDescription);
    Thanks

    "katychapman85" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hey Amy,
    >
    > I've put a thread up about this but thought I'd ask you
    as well as you've
    > been
    > a great help to me so far.
    >
    > I have this function:
    > public function GetOptions(Menu:int):void{
    > document.MenuOptions.url =
    > "
    http://localhost/Flex/Personalised%20Palettes-debug/MenuOptions.php?Menu=";
    > document.MenuOptions.url += Menu;
    > document.MenuOptions.send();
    > }
    >
    > What I'm trying to do is when a user clicks on a Radio
    button this
    > function is
    > called and the number of the Menu required is sent to
    the function.
    >
    > I've added this Event Listener to my Radio Button:
    >
    >
    document.RadioButtons2.addEventListener(MouseEvent.CLICK,
    > function():void{GetOptions(2);});
    >
    > However, it's not working. Everything I've read suggests
    using an
    > anonymous
    > function in the Event Listener to pass the menu
    parameter but for some
    > reason
    > it's not working.
    What version of Flex are you using? The Help for Flex 3 has
    this to say:
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=events_05.html
    Defining event listeners inline
    The simplest method of defining event handlers in Flex
    applications is to
    point to a handler function in the component's MXML tag. To
    do this, you add
    any of the component's events as a tag attribute followed by
    an ActionScript
    statement or function call.
    You add an event handler inline using the following syntax:
    <mx:tag_name event_name="handler_function"/>
    For example, to listen for a Button control's click event,
    you add a
    statement in the <mx:Button> tag's click attribute. If
    you add a function,
    you define that function in an ActionScript block. The
    following example
    defines the submitForm() function as the handler for the
    Button control's
    click event:
    <mx:Script><![CDATA[
    function submitForm():void {
    // Do something.
    ]]></mx:Script>
    <mx:Button label="Submit" click="submitForm();"/>
    Event handlers can include any valid ActionScript code,
    including code that
    calls global functions or sets a component property to the
    return value. The
    following example calls the trace() global function:
    <mx:Button label="Get Ver" click="trace('The button was
    clicked');"/>
    There is one special parameter that you can pass in an inline
    event handler
    definition: the event parameter. If you add the event keyword
    as a
    parameter, Flex passes the Event object and inside the
    handler function, you
    can then access all the properties of the Event object.
    The following example passes the Event object to the
    submitForm() handler
    function and specifies it as type MouseEvent:
    <?xml version="1.0"?>
    <!-- events/MouseEventHandler.mxml -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
    import mx.controls.Alert;
    private function myEventHandler(event:MouseEvent):void {
    // Do something with the MouseEvent object.
    Alert.show("An event of type '" + event.type + "'
    occurred.");
    ]]></mx:Script>
    <mx:Button id="b1" label="Click Me"
    click="myEventHandler(event)"/>
    </mx:Application>
    It is best practice to include the event keyword when you
    define all inline
    event listeners and to specify the most stringent Event
    object type in the
    resulting listener function (for example, specify MouseEvent
    instead of
    Event).
    You can use the Event object to access a reference to the
    target object (the
    object that dispatched the event), the type of event (for
    example, click),
    or other relevant properties, such as the row number and
    value in a
    list-based control. You can also use the Event object to
    access methods and
    properties of the target component, or the component that
    dispatched the
    event.
    Although you will most often pass the entire Event object to
    an event
    listener, you can just pass individual properties, as the
    following example
    shows:
    <?xml version="1.0"?>
    <!-- events/PropertyHandler.mxml -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
    import mx.controls.Alert;
    private function myEventHandler(s:String):void {
    Alert.show("Current Target: " + s);
    ]]></mx:Script>
    <mx:Button id="b1" label="Click Me"
    click="myEventHandler(event.currentTarget.id)"/>
    </mx:Application>
    Registering an event listener inline provides less
    flexibility than using
    the addEventListener() method to register event listeners.
    The drawbacks are
    that you cannot set the useCapture or priority properties on
    the Event
    object and that you cannot remove the listener once you add
    it.
    don't see anything in there about anonymous functions...?

  • Alpha properties in a dynamically generated movie

    the situation:
    i have to dynamically generate a movie clip
    inside the already created movie clip i have two event
    controllers which ( SHOULD) set the _alpha state of two instances(
    which happen to be 2 diff key frames of one animation sequence
    turns out im unable to get anything to happen with either one
    of the instances -- the variables which control the MC are
    accessible to the function b/c a trace(var); statment will trace
    the correct value -- but the movie clip wont set its _alpha to that
    passed value.
    any suggestions???

    that is correct
    the trace statement is directly above the _alpha assignment
    statement
    the newer post i just put up is a little less convoluted --
    so it might make a little more sence

  • Dynamically creating charts

    i am trying to dynamically create a chart but it isn't
    working. can someone look at my code and tell me what i am doing
    wrong.
    private function addGraph(event:Event):void {
    var gr:ColumnChart = new ColumnChart();
    gr.id="graph2";
    gr.dataProvider="{feedRequest.lastResult.videos.video}";
    var series:Object = gr.series[0]; ////(i tried var
    series:Object = graph2.series[0]; but this returns error:undef
    property graph2)
    series.yField = "views";
    hbox1.addChild(gr);
    i tried modelling the code after the 3rd example at:
    http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001212.html
    here is the httpservice:
    <mx:HTTPService id="feedRequest" url="
    http://ws.jamesward.org/youtube.xml"
    useProxy="false"/>

    i also tried taking out the event:Event so the function
    reads...
    private function addGraph():void {...

Maybe you are looking for

  • Don't know how to fix this - status says no internet connection, yet I'm on the internet.

    So this is a weird one. I got this new MacBook Air and the WiFi started up without a hitch.  I had finished migrating from my old computer to my new one and all of a sudden the status bar signal went from full bars to an exclamation point.  The info

  • Off topic: General comment

    All, I know this is totally off-topic but this is the best way to send a very important message. One of those days, someone called to us to offer Solaris support services, because that person was reading this forum and saw our entries. I guess, if we

  • Client Configuration

    i have two controllers 4402and 15 WAP 1250s with both radio AGN i need to configure the client to support maximum Speed please advice what is the best Practice configuration for Both WLC and client (the maximum speed for 2.4Ghz GN-radio) the Laptop a

  • Aggregation plan/Skip level aggregation for model with a cumulative measure

    I have planning data in the following format. Project     Department Name     Task     Date          Units of work completed PRO1     DEPARTMENT1          Task1     01/01/2008     12 PRO1     DEPARTMENT1          Task1     01/21/2008     3 PRO1     D

  • A cmr-field and a cmp-field on the bean are using the same name. The names

    Hi: I am using weblogic 8.1 and MyEclipse 5.1.1. I am deploying my ear application through MyEclipse 5.1.1 as an ear file. When I ran the following EJB QL: SELECT OBJECT(p) FROM Product p.category = ?1 I get the following error: n relation Category-P