Adding Image to Simple button dynamically using AS3

Hello

I need help trying to figure out how to dynamically add an image (PNG or JPEG) I can put in a button library also dynamically created in AS3.

Is there a way to (1) add the image instead of using a label text and centered it in the button?

Here's the AS3 for the simple button without the image (currently uses the text label, but I would prefer if possible replace with an image for the text):

        
        var mc2:MovieClip = new MovieClip();
        mc2.addChild( bgRed2 );
        mc2.addChild( txt2 );//currently uses text label; would prefer to use an image istead of text

        var mc2a:MovieClip = new MovieClip();
        mc2a.addChild( bgRed2a );
        mc2a.addChild( txt2a );currently uses text label; would prefer to use an image istead of text

        var clearBtn:SimpleButton = new SimpleButton();
        clearBtn.upState = mc2;
        clearBtn.overState = mc2a;
        clearBtn.downState = clearBtn.upState;
        clearBtn.hitTestState = clearBtn.upState;
        clearBtn.x = 0;
        clearBtn.y = 0;
        addChild( clearBtn );
        clearBtn.x = 55;
        clearBtn.y = stage.stageHeight-clearBtn.height;

Any help appreciated.

assign a class name to your image (for example, Img1). You can then use:

var img1D:BitmapData = new BitmapData();

var img1:Bitmap = new Bitmap (img1D);

cleanBtn.upState = img1; for example, the northern part of the State of the button is the image.

If you want general information and the image centered on the background, create your background (movieclip or sprite), using addChild to add img1 to your context and Center it.  Then assign upState your button to be your background etc.

Tags: Adobe Animate

Similar Questions

  • Draw a line from any Point to any Point B dynamically using AS3

    I'm doing an animation where there are several places (for example A, B, C, D,...) on a map. If a person clicks a location A and then B elsewhere, I wanted to draw a dotted line from point A (from the destination of the aircraft) to point B (to destination of the flat) using AS3. Please help me...

    Here's a quick timeline and dirty code it does (class is below):

    var line:Shape;
    var lineGraphics:Graphics;
    var clickSwitch:int = 0;
    var mousePositions:Array = [];
    var conversion:Number = 180 / Math.PI;
    
    init();
    function init():void {
         drawBackground();
         line = new Shape();
         addChild(line);
         lineGraphics = line.graphics;
         stage.addEventListener(MouseEvent.CLICK, onClick);
    }
    
    function onClick(e:MouseEvent):void
    {
         clickSwitch = 1 - clickSwitch;
         mousePositions[clickSwitch] = new Point(mouseX, mouseY);
         if (clickSwitch == 0) {
              drawLine();
         }
         else {
              removeLine();
         }
    }
    
    function removeLine():void
    {
         lineGraphics.clear();
         line.rotation = 0;
    }
    
    function drawLine():void
    {
         lineGraphics.lineStyle(1, 0xff0000);
         lineGraphics.moveTo(0, 0);
         var dotDistance:Number = 2;
         var nextX:Number = dotDistance;
         while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
              lineGraphics.lineTo(nextX, 0);
              nextX += dotDistance;
              lineGraphics.moveTo(nextX, 0);
              nextX += dotDistance;
         }
         line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
         line.x = mousePositions[1].x;
         line.y = mousePositions[1].y;
    }
    
    function drawBackground():void
    {
         var s:Shape = new Shape();
         var g:Graphics = s.graphics;
         g.beginFill(0xC0C0C0);
         g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
         g.endFill();
         addChild(s);
    }
    

    Class:

    package
    {
         import flash.display.Graphics;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.geom.Point;
    
         public class DottedLine extends Sprite
         {
              private var line:Shape;
              private var lineGraphics:Graphics;
              private var clickSwitch:int = 0;
              private var mousePositions:Array = [];
              private var conversion:Number = 180 / Math.PI;
    
              public function DottedLine()
              {
                   init();
              }
    
              private function init():void {
                   drawBackground();
                   line = new Shape();
                   addChild(line);
                   lineGraphics = line.graphics;
                   stage.addEventListener(MouseEvent.CLICK, onClick);
              }
    
              private function onClick(e:MouseEvent):void
              {
                   clickSwitch = 1 - clickSwitch;
                   mousePositions[clickSwitch] = new Point(mouseX, mouseY);
                   if (clickSwitch == 0) drawLine();
                   else removeLine();
              }
    
              private function removeLine():void
              {
                   lineGraphics.clear();
                   line.rotation = 0;
              }
    
              private function drawLine():void
              {
                   lineGraphics.lineStyle(1, 0xff0000);
                   lineGraphics.moveTo(0, 0);
                   var dotDistance:Number = 2;
                   var nextX:Number = dotDistance;
                   while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
                        lineGraphics.lineTo(nextX, 0);
                        nextX += dotDistance;
                        lineGraphics.moveTo(nextX, 0);
                        nextX += dotDistance;
                   }
                   line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
                   line.x = mousePositions[1].x;
                   line.y = mousePositions[1].y;
              }
    
              private function drawBackground():void
              {
                   var s:Shape = new Shape();
                   var g:Graphics = s.graphics;
                   g.beginFill(0xC0C0C0);
                   g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                   g.endFill();
                   addChild(s);
              }
    
         }
    
    }
    
  • Support for the creation of menus in which is the center of the screen using AS3, with MovieClip that contains buttons

    Hello beautiful ActionScript Guru-

    I'm new on learn AS3 and have run obstacle after roadblock to getting what, in my view, should be a simple thing to work. I'm trying to create a menu on many levels using a MovieClip that contains simple buttons. I'm facing 2 problems while posting what I've built.

    1. my Menu.as (code below), says it takes "5000: the class 'Menu' must subclass"flash.display.SimpleButton"because it is linked to a symbol in the library of this type.» That's fine, except when I don't change the code to reflect the change the error message wants to difficulty, my beautiful menu driven with options turns into an absolutely useless image, with no opportunity to serve a menu at all. I have read other forums that I have what Miss me is to create a MovieClip that contains buttons, but I think that's exactly what I did. I'm not sure how to fix this error.

    2. when I compile my main class (ConsStartMenu.as) did not finish the compilation error 1119: line 29 and 46, claiming that my link to my subclass (Menu.as) called a potentially indefinite property Menu through a reference with static type ConsStartMenu. After searching on Google and the forums navigation for long hours, I do have absolutely no idea what means this error, or what he wants me to difficulty. I think that this is also the reason why my sizing and centering code does not work. It's as if he can't quite find my Menu.as. Maybe a quick glance at my code will shed some light on this?

    Thank you very much in advance for your help.

    -connor

    errors.png

    ConsStartMenu.as-

    package {}

    import flash.display.MovieClip;

    import stuff from the lib of valve

    Import ValveLib.Globals;

    Import ValveLib.ResizeManager;

    SerializableAttribute public class ConsStartMenu extends MovieClip {}

    These three variables are required by the engine

    public var gameAPI:Object;

    public var globals: Object;

    public var elementName:String;

    public void ConsStartMenu(): void {}

    }

    This function is called when the user interface is loaded

    public void onLoaded(): void {}

    make this visible user interface

    Visible = true;

    Let customer across the user interface

    Globals.instance.resizeManager.AddListener (this);

    trace ("Cons Start Menu loaded!");

    This. Menu.Setup (this.gameAPI, this.globals);

    }

    public void onResize(re:ResizeManager): * {}

    var scaleRatioY:Number = re. ScreenHeight/900;

    If (re. ScreenHeight > 900) {}

    scaleRatioY = 1;

    }

    This. Menu.screenResize (re. ScreenWidth, re. ScreenHeight, scaleRatioY);

    }

    }

    }

    Menu.As-

    package {}

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    Import fl.transitions.Tween;

    Fl.transitions.easing import. *;

    to import flash.display.SimpleButton;

    SerializableAttribute public class Menu extends MovieClip {}

    var gameAPI:Object;

    globals var: Object;

    public void Menu() {}

    }

    public void Setup (api: Object, globals: Object) {}

    define our variables

    api = this.gameAPI;

    Globals = This.Globals;

    }

    public void screenResize (stageX:int, stageY: int, scaleRatio:Number) {}

    'this', the position being this module, in the center of the screen

    This.x = stageX/2;

    This.y = stageY/2;

    Save the original scale of this movieClip

    If (this ["originalXScale"] is nothing)

    {

    This ["originalXScale"] =-this.scaleX;

    This ["originalYScale"] = this.scaleY;

    }

    This module/movieClip to scale the scaleRatio

    this.scaleX = this.originalXScale * scaleRatio;

    this.scaleY = this.originalYScale * scaleRatio;

    }

    }

    }

    you are missing a fundamental knowledge of classes and how they work.

    the bottom line: you cannot reference Menu unless it's a static class.

    You must create an instance of your class of Menu:

    menu: Menu of var = new Menu();

    and then you can add to your addChild (menu) for the use of ConsStartMenu, or maybe that you don't have.  I can't.

    is ConsStartMenu your document class?

  • Photo Gallery dynamic in Flash using AS3.0 and XML, but it does not work and failed in my application.

    Hello

    I'm creating an iPad app using AS3. The application contains three sections.

    10-21-2013 6-44-13 PM.jpg

    These items (chocolate sources) contains dynamic library using XML. Photos, pictures and text in this section are loaded from XML.

    I did face may I tried to run this application to issue:

    • The photos of the Gallery did not show
    • Thumbnails (buttons to navigate through the photo gallery) does not appear at all. (Thumbnails should appear in the box photo gallery).
    • The text does not (the text must be declared in each photo as describtion)
    • I want to understand Swipe in the photo gallery, how can I do this?
    • When I click on button 'Chocolate Sources', the photo gallery will appear in each section, this is print screens describe what I mean:

    Screen shot 2013-11-19 at 1.05.15 PM.png

    Screen shot 2013-11-19 at 1.05.28 PM.png

    Screen shot 2013-11-19 at 1.05.31 PM.png

    Photo gallery covers the home screen too.

    Screen shot 2013-11-19 at 1.05.35 PM.png

    This is my XML:

    <? XML version = "1.0" encoding = "utf-8"? >

    < sources >

    < section >

    < details >

    Cocoa is in the tropics, such as Central America and the southern region.

    < / details >

    < image >

    < url > coca1.jpg < / url >

    < / image >

    < / section >

    < section >

    < details >

    Cocoa is provided in many countries as the Indonesia, Ghana, Brazil, Ecuador and Cameroon.

    < / details >

    < image >

    < url > coca2.jpg < / url >

    < / image >

    < / section >

    < section >

    < details >

    Dark chocolate helps to relax and reduce the stress and blood pressure because it includes antioxidant elements, which helps the vasodilator process.

    < / details >

    < image >

    < url > coca3.jpg < / url >

    < / image >

    < / section >

    < section >

    < details >

    Chocolate provides energy and hyperactive sometimes because it contains a high level of caffeine and sugar.

    < / details >

    < image >

    < url > coca4.jpg < / url >

    < / image >

    < / section >

    < section >

    < details >

    Chocolate could be mixed with many different flavors such as Mint, strawberry, orange, banana, vanilla, hazelnut, almond, coconut and etc.

    < / details >

    < image >

    < url > coca5.jpg < / url >

    < / image >

    < / section >

    < section >

    < details >

    Chocolate is expressing hospitality well and good time because of its pleasant taste.

    < / details >

    < image >

    < url > coca6.jpg < / url >

    < / image >

    < / section >

    < / sources >

    -------------------------------------------------------------

    And here's my Action Script for the section "Sources of chocolate:

    Stop();

    function Choco1(evt:MouseEvent): void {}

    gotoAndStop('16');

    }

    choco_btn.addEventListener (MouseEvent.Click, Choco1);

    function Souc1 (evt:MouseEvent): void {}

    Stop ('31');

    }

    souc_btn.addEventListener (MouseEvent.Click, Souc1);

    function ShopIn1 (evt:MouseEvent): void {}

    gotoAndStop('46');

    }

    shops_btn.addEventListener (MouseEvent.Click, ShopIn1);

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.events.Event;

    import flash.display.MovieClip;

    import flash.display.Loader;

    Import fl.motion.MotionEvent;

    import flash.events.MouseEvent;

    import flash.sampler.NewObjectSample;

    import flash.text.TextFormat;

    var xmlLoader: URLLoader = new URLLoader (new URLRequest ("sources.xml"));

    xmlLoader.addEventListener (Event.COMPLETE, finishedXmlLoader);

    var xmlFile:XML;

    var xextend:int = 10;

    var gal: galary = new galary ();

    GAL.x = 85;

    GAL.y = 165;

    addChild (gal);

    var txfe: TextField = new TextField ();

    txfe.x = 25;

    txfe.y = 45;

    var tformat:TextFormat = new TextFormat ();

    TFORMAT. Bold = true;

    TFORMAT. Color = 0xFFFFFF;

    TFORMAT. Size = "18";

    TFORMAT.font = "Arial";

    txfe.defaultTextFormat = tformat;

    addChild (txfe);

    function finishedXmlLoader (e: Event): void {}

    xmlFile = new XML (xmlLoader.data);

    var leng:int = xmlFile.image.length ();

    txfe. Text = xmlFile.image.details [0];

    for (var i: int = 0; i < leng; i ++) {}

    var b:thumbs = new (inches);

    b.x = xextend;

    b.y = 480;

    b.buttonMode = true;

    b.Details = (i + 1) m:System.NET.SocketAddress.ToString ();

    addChild (b);

    b.addEventListener (MouseEvent.MOUSE_OVER, theMosover);

    b.addEventListener (MouseEvent.MOUSE_OUT, theMosout);

    b.addEventListener (MouseEvent.CLICK, onMosClick);

    var bloader:Loader = new Loader();

    bloader. Load (new URLRequest ("thumbs /" + (i + 1) + ".jpg"));

    b.addChild (bloader);

    xextend += b.width + 50;

    }

    var loader: Loader = new Loader ();

    Loader.Load (new URLRequest ("pictures/coca1.jpg"));

    gal.addChild (loader);

    }

    function theMosover(m:MotionEvent):void {}

    m.currentTarget.alpha = 0.5;

    }

    function theMosout (m:MouseEvent): void {}

    m.currentTarget.alpha = 1.0;

    }

    function onMosClick(m:MouseEvent):void {}

    var loader: Loader = new Loader();

    Loader.Load (new URLRequest ("images /" + m.currentTarget.details + '.jpg'));

    gal.addChild (loader);

    txfe. Text = xmlFile.image.details [int (m.currentTarget.details)-1];

    }

    -------------------------------

    I need urgent assistance to correct errors and make this section work well.

    Thank you.

    Try:

    txfe. Text = xmlFile.section [int (m.currentTarget.details)-1]. Details;

    Instead of

    txfe. Text = xmlFile.image. [int (m.currentTarget.details)-1];

    and add your thumbs to the lag, not the scene.  When you are finished with the Gallery, remove the lag.

  • Buttons of... Reach... I use AS3, and I am a designer AS2. =(

    Hey there,

    I have a problem and I have scoured Youtube, Adobe, Lynda and the help of Flash... but my simple brain can't understand.

    I'm used to the selection of items, whether it's a button or movieclip and AS2 it tagging with going to the scene or frame. It seems that this is not an option more when you work in AS3 (I use Flash CS4).

    So I found some samples but it involed script a keyframe... beyond what makes no sense to me, it seems that designers need to be more programmatic approach to these things.

    So aparently you name case now and then there is what we called an event listener... after that, I was lost.

    I tried the new mix with the old code (old code, which means going to setting, etc.) and I just got a lot of mistakes.

    Long story short, I would like to just find a code for a movieclip or button to make it go on a chassis, and or the scene.

    Thanks for your help.

    Things have changed, although using instance names and coding on the timeline in frames has been around for a long time, so I don't see how you missed it.  The good news is, if you do not want to use AS3, you don't have to and you can set your files rather use AS2.  You cannot mix the two languages in one file and have something works well.  If you want to use AS3 programming, then you have a learning curve to overcome, especially if you have never used coding in AS2 timeline.

    As far as do a job of button/movieclip as a button...

    Assume that you create a button symbol.  Since this is a button, it is already a car animation object that will react to mouse interactions, but only visually at this stage.  The first thing you need to do to make it useful down must assign a unique instance name.  If you drag a copy of it on the stage of the library, and while it is still selected, enter you this unique instance for her name in the Panel properties... say you name "btn1.

    In AS3, to make a button with the code, you must add a listener of events and event handler for it function.  You may need to add a little (for different events, like reversal, deployment, by clicking on it, but for now let's just say you want to be able to click on it to go to a particular frame.)  In the scenario that contains this button, a layer of separate actions that you create in a similar framework where this button exists, numbered, you must add the event listener:

    Btn1.addEventListener (MouseEvent.CLICK, btn1Click);

    The name of the unique function for the treatment, the click of this button is specified at the end of the assignment of event listener, so now you just have to write this function:

    function btn1Click(evt:MouseEvent):void {}

    gotoAndPlay ("frameLabel"); or number of image without quotes

    }

    The gotoAndPlay function has changed a bit in AS3, so you shoiuld who look it up if you intend to try to use the scenes... but one recommendation is to not use scenes.

  • How to create a play button to the video clip using AS3

    Hello.

    This new bit and searched the forums adobe and google. I am trying to create a button that will play an any MovieClip.

    I have a clip that I imported into its own layer of rebar (layer1) 1.  I gave the MovieClip an instance name of foundationMovie.

    I created a button and that on its own layer (Layer2) above layer1, is also in the picture 1.

    I added a

    Stop (); action of layer2

    The video is not set to AutoPlay.

    I want the video to start playing when the viewer clicks the button.  I know I have to put some sort of event using AS3 listener in my calendar somewhere.

    I found a code and I tried to work with her.  I'm sure I've mutilated it beyond usability, but it's what I have.

    Stop ();

    player.addEventListener (MouseEvent.CLICK, play);

    function play(event:MouseEvent)

    {

    gotoAndPlay ("foundationMovie");

    }

    If someone could point me in the right direction or help me with my code I would really appreciate it.  Thank you.

    If you use the FLVPlayback instance it should be on your scene, or you should have the code added to the scene. If you use the FLVPlayback instance, you don't need to import the video file, you have to have the component dynamically load by assigning the file to its source property.

    That said, the code that I showed earlier would continue to operate if the component FLVPlayback instance name of the instance 'foundationMovie '.  It's because the component has a play() and stop() supporting method.  What you need to do probably, is looking for the FLVPlayback class in the help documentation of Flash to see all that is avialable for her regarding the properties, methods and events.  You will probably find there examples as well to help you configure things.

  • How to change the highlight color, click the button image and text and sound.  are there packages of buttons for use in my project?

    How to change the highlight color, click the button image and text and sound. are there packages of buttons for use in my project?

    Hello

    Even if the point of things based Web links buttons created using them is of simple images. Captivate uses simple images. If you need to put your creative hat and not to let the fact that you see the word 'web' scared you somehow. An image is an image. Use on the web, use Captivate. Same case!

    If you change the properties of the button, you can activate the legend of success. Fix any sound that you like with the legend of success and it will play when you click the button. If you do not want to see the legend of success, delete the text and configure it as transparent.

    See you soon... Rick

    Useful and practical links

  • Button "Exit", used in several images of the sequence

    I hope that there is a more elegant way to do...

    See the VI attached for a much simplified program that is typical of what I am trying to accomplish.  Basically I have a button that I want available in several images in the sequence.  In this case, I used a button "quit".  When you press on, the program passes by remaining sequence frames until it ends.  The last image "unclicks" the button "Exit".  This last image is necessary because I had to put the mechanical action of the Exit button for "switch when released" because I used local variables in all the images in the sequence after the first.

    Is there a way I can accomplish the same functionality of this program without using local variables and/or during the definition of the mechanical action of the 'exit' switch to ' lock releasing?  Specifically, I'm looking for solutions that will work in several images of a structure of stacked sequence (I realized there are ways for the three lights without using a structure of stacked sequence, but I'm not interested in doing).

    Any help would be greatly appreciated!  Thank you!

    Something where you're looking at a sequence of steps, you really recommended using a state machine architecture.  (Search the forums for examples).

    Having several structures event with cases duplicated in different settings of a structure of stacked sequence (it would be a little better if you used a structure rather flat sequence), only to request trouble on the road.

  • How to assign URLs dynamically using button/link on the page of peoplesoft? Please provide detailed instructions.

    How to assign URLs dynamically using button/link on the page of peoplesoft? Please provide detailed instructions.

    1. define the URL, the Z_URL1 or the Z_URL2 definitions

    2. in the change of field button:

    If true Condition then

    ViewURL (URL. Z_URL1);

    On the other

    ViewURL (URL. Z_URL2);

    End - if

  • I want to use two different images for a button state...

    I want to use two different images for a button state... [Normal] grayscale media social icon outline [rollover] color media social status icon.

    Option 1:

    Create a status button which becomes transparent in the mouse above.

    Have the other underneith of the image.

    Option 2:

    Create a status button with a background image.

    Then select a different background image for each State.

    You can also do cool stuff like Sprite buttons too.

    Example: Adobe Muse Social Sprites by MuseThemes

    Widget page: Adobe Muse Social Sprites by MuseThemes

    Themes of Muse had a great video about these doing just now.

  • How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    The SWF file can be used in the same way as the CFC, which means that you don't need to "visually show" anything when it is loaded. Your code can use the classes and assets incorporated into the SWF, just as a SWC file. So if someone just to load the SWF file to see what was in it that they see nothing. They could however access programmatically to what anyone on the inside just like you, if they went to that level. But it is not as easy as just racing as SWF to see what is inside.

    I hope that all packaging several separate sovereigns will allow you to load and unload only what you need to keep the RAM usage as low as possible with a minimum load SWF.

    If you are ready, please mark all useful/correct so we can filter without response. You're welcome and good luck!

  • simple pop-up with AS3?... .not using javascript

    It is EXACTLY what I want... but in AS2

    http://www.flashkit.com/tutorials/ActionScripting/creating-Elizabet-889/index.php

    a simple click on a button, a popup appears in the image, then the image, an exit button. Help?

    to do this, you need to place this popUp on the mainTimeline on a layer separate above anything else.

    After that it defined in the main timeline to visible = false; and you can reference it like this:

    MovieClip (root).popUp.visible = true;

  • How to make an image, a radio button?

    I'm trying to create a drag and drop game using Adobe Flash, AS3. I have a "Select sex" page where I have both a male, a female model. I want users to be able to select either the image of male or female, but then a next button in order to take on the next page; However, the next page varies depending on which gender is selected.

    I am able to do this or would I need to change the images of radio buttons or just remove the next button so that the images are buttons?

    Please help with my dilemma?

    select gender.png

    in this case:

    function maleHandler(e:MouseEvent):void {}

    do male stuff

    var mPage:MaleDragAndDropTopsPage = new MaleDragAndDropTopsPage();

    addChild (mPage);

    }

    If you absolutely must have a nextButton, you can either go for two different instances of the key you call

    maleButton or femaleButton and join managers in these

    When you click on the male/femaleFigure

    you will have to somehow store state in a dynamic property, or a variable (no matter what ypu prefer).

    so at the beginning

    maleModel.clicked = false;

    femaleModel.clicked = false;

    both will have an extra clickHandler which defines their clicked Properties.

    The simplest and IMO more userfriendly way would be to use the numbers as buttons themselves.

  • app iOS using AS3 don't fit the screen dimensions

    I am building an iOS application using as3 and air to package the app on my iPhone 6. My problem is that I get a black bar above and below the app, the app itself is not full screen. Step screen is set to the dimensions of 6 iPhone screen.

    I tried adding the following images of launch in the app folder. [email protected], [email protected] and [email protected]. But it is not displayed correctly.

    Does anyone have fixes for this?

    Hi messarimohamed

    iPhone 6 & iPhone6 + require different Images of launch of older phones:

    For example,.

    The iPhone 6: Default-375w-667h@2x~iphone.png

    And iPhone6 +: Default-414w-736h@3x~iphone.png

    For more details in this regard, read the article below:

    http://blogs.Adobe.com/airodynamics/2015/03/09/launch-images-on-iOS-with-Adobe-Air/

    -Tushar,

    Adobe AIR Team

  • data call a loader dynamically using variables

    I'll call some data from php, which simply retrieves some data from MySQL.  The recovered paintings are called dynamically and so I have a list of tables sent to actionscript below and called by event.target.data.its and event.target.data.ces.  They will have a list of called tables.  I then sends the name/value pairs to actionscript php dynamically using these table names (all inside php here).

    $sql3 = ' SELECT * 'SPECIALTY "";

    $getit = mysql_query ($sql3);

    While ($row2 = {mysql_fetch_array ($getit))}

    for ($i = 0; $i < sizeof ($itlist); $i ++) {}

    $itones = $row2 [$itlist [$i]];

    $fullstr. = '& '. $itlist [$i]. ' = $itones; »

    }

    for ($l = 0; $l < sizeof ($celist); $l ++) {}

    $ceones = $row2 [$celist [$l]];

    $fullstr. = '& '. $celist [$l]. ' = $ceones; »

    }

    }

    $fullstr. = "& a = $itrow & these = $cerow;

    Print "$fullstr";

    As you can see, the names in the name/value pairs are created dynamically.  So in order to know which names the name/value pairs to call ActionScript, I have send their list to actionscript.  The problem is the following.  In actionscript, I have the names of the name/value pairs of. data.its and. data.CES. those who are like a comma-delimited string.  I put those in a table so you can loop through the array and call the appropriate data to php.  However, they are strings and cannot access the data in php.  What I need to know, is what is the evet.target.data. ??? .  What kind of data can I use to convert the string to a vocation little matter.  The string itself will not work.  It does not convert the string to an object.  How can I access specific information (name/value) in .data. When I have a string that represents the name of the name/value data, I try to access?

    Glo.bal.ServerPath = "http://localhost/unspro/" ;//http://localhost/unspro/ ""

    var contentArray:Array = theContent.split(",");

    var rodp:URLVariables = new URLVariables();

    var getps:URLRequest = new URLRequest(glo.bal.serverpath+"prep/getspecs.php");

    getps. Method = URLRequestMethod.POST;

    getps. Data = WSGP.

    var leer: URLLoader = new URLLoader();

    leer.dataFormat = pouvez;

    leer.addEventListener (Event.COMPLETE, rtrieve);

    var txet:String = "true";

    rodp.wantcol = Txete;

    Leer.Load (getps);

    function rtrieve(event:Event):void

    {

    trace (Event.Target.Data.its);

    trace (Event.Target.Data.ces);

    var itarr:Array = event.target.data.its.split(",");

    var cearr:Array = event.target.data.ces.split(",");

    for (var i: int = 0; i < itarr.length; i ++) {}

    var st:String = itarr [i];

    trace (St);

    trace (Event.Target.Data.St);

    trace (Event.Target.Data.Network);

    }

    IT IS FAIR TEST, I CAN ALSO PRINT AS A SIMPLE STRING.  I CAN PROBABLY WORK WITH THE DATA AS A STRING, BUT IT IS A PAIN THE *.

    / * var dataXML:XML = XML (event.target.data);

    trace (DataXML.ToXmlString ());

    var somest: String = (dataXML.toXMLString ());

    var fullarr:Array = somest.split ("&");

    for (var u: int = 0; u < fullarr.length; u ++) {}

    trace (fullarr [u]);

    } */

    }

    In fact, I found the answer.  XML would not have been simpler in my opinion.  Because it would add an additional step (or two) first of all, create the xml in php code, once I got the MySQL data, and then analyze the XML in as3.  XML is a useful tool, but it's more of a replacement or a substitute for a dabase in my opinion.  When I use a database I shouldn't need XML and when I use XML (for the storage of data smaller unless I create xml dynamic text files) I wouldn't need MySQL.

    The solution is below for those who may fall on a specific need to dynamically call the names that represent the values passed from php in as3.

    function rtrieve(event:Event):void

    {

    trace (Event.Target.Data.its);

    trace (Event.Target.Data.ces);

    var itarr:Array = event.target.data.its.split(",");

    var cearr:Array = event.target.data.ces.split(",");

    for (var i: int = 0; i<>

    var st:String = itarr [i];

    trace (St);

    trace (Event.Target.Data [ST]); / / / event.target.data ["String_representing_name_for_name_value_pair"];

    }

    }

Maybe you are looking for