Making a loaded external image into a button in Actionscript

My name is Steve Oatman I am a student at
AIO for a Web Design Diploma
class: Interactive Telecommunications IMD412 XA
Professors to bussy!
I have a flash web site that I am putting together. I am using AS to load some images from an external source. These images are being loaded into a movieclip. These images need to become buttons once they are loaded. The images will link to the particular menu category pages beef, chicken, etc.
The images are loading fine they just are not responding like a button or link.
I am getting two error referencing the buttonMode and usehandCursor. Below is just one image that I am working on till I get it to work.
I am getting these two Compiler error code:
1119: Access of possibly undefined property buttonMode through a reference with static type flash.display:Loader.
1119: Access of possibly undefined property useHandCursor through a reference with static type flash.display:Loader.
This is what I have.
var myLoader01:Loader = new Loader();
myLoader01.load(new URLRequest("entrees_images/beef/beef01.gif"));
addChild(myLoader01);
myLoader01.x = -269;
myLoader01.y = -164;
myLoader01.buttonMode = true;
myLoader01.useHandCursor = true;
myLoader01.addEventListener(MouseEvent.CLICK, beefClick);
function beefClick(event:MouseEvent):void{
gotoAndStop("beef");
From me searching online I thought the
name.buttonMode = true;
turned the element into a button!
I have included the fla file. This is in the menuItems_mc which is located in the pageContent_mc frame 40 layer page Image or of course the library.
I know this is a little in depth sorry and any help would be greatly appreciated.
Steve
713/742-3325

Try something along the following lines:
var myLoader01:Loader = new Loader();
function addIt(evt:Event):void{
   var aBtn:MovieClip = new MovieClip();
   aBtn.x = -269;
   aBtn.y = -164;
   aBtn.buttonMode = true;
   addChild(aBtn);
   aBtn.addChild(myLoader01);
   aBtn.addEventListener(MouseEvent.CLICK, beefClick);
myLoader01.contentLoaderInfo.addEventListener(Event.COMPLETE, addIt);
myLoader01.load(new URLRequest("entrees_images/beef/beef01.gif"));
function beefClick(event:MouseEvent):void{
   gotoAndStop("beef");

Similar Messages

  • Unable to load external image into iOS app with AS3

    Just trying out Flash Builder for iOS app development and have run into a problem right off the bat with loading an external image into an iOS app.  The actionscript is very simple (this was basically my Hello World attempt), and I'm hoping someone here can explain where I'm going wrong.  This code works in Flash Pro, and works when launched on the desktop from Flash Builder, but doesn't work on my iOS devices.
    Here's the code:
                                  var container:MovieClip = new MovieClip();
                                  addChild(container);
                                  var imageLoader:Loader = new Loader();
           imageLoader.load(new URLRequest("http://www.google.ca/intl/en_ALL/images/logos/images_logo_lg.gif"));
                                  imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, startListener);
      function startListener (e:Event):void{
                                                 container.addChild(imageLoader);
    Any thoughts on why this won't work would be greatly appreciated!

    I had the same issue, and modified my domain policy file as specified  in http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.html#_Configuring_URL_M eta-Policies but the loader is not loading the file. Any ideas on how to fix this issue?

  • I cannot seem to load raw images into LR 2.5.  I've been using this for years.  I always load from memory card, but it gives me an unknown error message.  I tried to load from camera, hard drive, & external drive and still will not work.  I checked import

    I cannot seem to load raw images into LR 2.5.  I've been using this for years.  I always load from memory card, but it gives me an unknown error message.  I tried to load from camera, hard drive, & external drive and still will not work.  I checked import menu and nothing has changed.  I loaded the photos onto my tablet and images are fine, so do not feel it is the memory card.  Any thoughts?

    The error message probably said "unsupported or damaged"
    The T3 requires Lightroom 3.4.1 or later. You can either upgrade to a more current version of Lightroom (version 5.6 is the most recent) or you can use the free Adobe DNG Converter to convert the RAWs to DNG, which should import into Lightroom properly.

  • Best Practice - load external image including rollovers

    I am attempting to use the loader component to load an
    external jpg, but experience issues having my flash app
    successfully load a roll-over image from an external source when
    the user rolls over the intital jpg. I am not a flash developer
    (actually a .net developer trying to help a graphics guy out).
    I started with the loader component, converted it to a movie
    clip and then utilized the on(rollover) and on(rollout) events to
    change the loader component's contentPath property at runtime via
    ActionScript. I am not getting consistent results with this
    strategy - what is the best way to accomplish this? Also note I
    tried converted to a button, which seemed more logical, but the
    loader component doesn't seem to like being converted to a button.
    Regards,
    Daflookie

    Daflookie,
    > I started with the loader component, converted it to a
    movie
    > clip and then utilized the on(rollover) and on(rollout)
    events
    > to change the loader component's contentPath property at
    > runtime via ActionScript. I am not getting consistent
    results
    Check out the Loader class in the Components Language
    Reference. Loader
    extends MovieClip, so there's no need to convert to a movie
    clip symbol. In
    addition, I recommend scrapping on() in favor of MovieClip
    events, which
    will probably be closer to your .NET point of view that the
    older
    on/onClipEvent approach to event handling (those are Flash
    5-era).
    Honestly, though, if you simply want to load images, I would
    forego the
    Loader component (no need for all that overhead) and use
    MovieClipLoader to
    load your images into the user's Internet cache. You'll see a
    good handful
    of events under that class listing as well (see the
    ActionScript 2.0
    Language Reference).
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Load external images

    Im wanting to make a photo gallery that I can update easy, I
    thought if I could have a movieclip load external images for my
    thumbnails it would be nice but Im not sure how to set it up. I
    would make a file for my images and then another for my thumbnails,
    then if or when I want to switch out pictures I'd just have to drop
    new images into my folders and not even touch the FLA. Could anyone
    point me in the right direction with the right action script to use
    or a tutorial that explains how this is done..
    And when I say load external I want it so I dont have to
    click on the image for it to load, I want it to just load
    automatically , I would put an invisible button or something to
    that efect over the images for a animated effect.
    Thanks for your help.

    I don't know if you are super enthusiastic about building it,
    or if you just want the utility. If the later is the case, I just
    purchased (cheap) a really great product that does all of what you
    want, fairly automatically, including scaling large pictures down
    to smaller size so that they load quickly.
    I am not sure of the policy of recommending third-party
    applicatons here. So, if you are interested, send an email (private
    message) to me and I will show you the simple site I put together
    using it and where to get it.

  • Load external image and animate?

    This may be a naive question, but -
    What is the best method to draw external content (an image
    file) into a Flash movie, AND then ANIMATE that content?
    I assumed I would need to use the LOADER COMPONENT to draw an
    image file from an external URL, but is there a way to then perform
    a simple animation (e.g., slide the image across the stage) with
    the loaded image? I cannot seem to figure out how to manipulate an
    image once loaded (using the LOADER COMPONENT).
    Yes, I am new to Flash, so there may be six other ways to do
    this of which I am not aware.
    Suggestions/solutions?

    use the MovieClipLoader class to load the image into a holder
    movie clip, then use the onLoadInit function to animate the holder
    clip.

  • Fastest way to load an image into memory

    hi, ive posted before but i was kinda vague and didnt get much of a response so im going into detail this time. im making a java program that is going to contol 2 robots in a soccer competition. ive decided that i want to go all out and use a webcam instead of the usual array of sensors so the first step is to load an image into the memory. (ill work on the webcam once ive got something substanical, lol) since these robots have to be rather small (21cm in diameter) i can only use some pretty crappy processors. the robots are going to be both running gentoo linux on a 600 mhz processor, therefore it is absoleutely vital i have a fast method of loading and analyzing images. i need to be able to both load the image quickly, and more importainly analyze it quickly. ive looked at pixelgrabber which looks good, but ive read several things about javas image handling beging crap. these articles are a few years old, and im therefore wonding if there anything from the JAI that will do this for me. thx in advance.

    well i found out why i was having so much trouble
    installing JAI. im now back on windows and i cant
    stand it, so hopefully the bug will be fixed soon. oIt's not so bad. I mean, that's why we love Java! Once your linux problem is fixed you can just transfer your code there as is.
    well. i like the looks of JAI.create() but im not so
    sure how to use it. at this stage im tying to load an
    image from a file. i no to do this with pixelgrabber
    you use getcodebase(), but i dont know how to do it
    with JAI.create. any advice is appreciated. thx.Here are some example statements for handling a JAI image. There are other ways, I'm sure, but I've no idea which are faster, sorry. But this is quite fast on my machine.
    PlanarImage pi = JAI.create("fileload", imgFilename);
    WritableRaster wr = Raster.createWritableRaster(pi.getSampleModel(), null);
    int width = pi.getWidth(); // in case you need to loop through the image
    int height = pi.getHeight();
    wr = pi.copyData(); // copy data from the planar image to the writable one
    wr.getPixel(w,h,pixel); //  pixel is an int array with three elements.
    int red = pixel[0];     // to find out what's the red component
    int[] otherPixel = {0,0,0}
    wr.setPixel(w,h,otherPixel); // make pixel at location (w,h) black.                And here's a link with sample code using JAI. I've tried several of the programs there and they work.
    https://jaistuff.dev.java.net/

  • Load external images and video in edge

    Hi.
    I am looking into edge instead of flash.
    My question is how do you load external images and videos from an external server?
    To clarify, I need to insert a link from where the images can load into the stage, so they don´t take up any of the final weight.
    Thanks in advance.
    Best,
    Stig.

    The above solution I provided works if you already have the images in your composition and than if you want form load images from another server rather than the relative location to your html file.
    Now if you want to load images dynamically into a rectagle containter you will have to code it.
    below is a sample for that
    Create a 'rectangle' with name 'Rectagle'.
    Add the snippet in the compositon ready or on other user actiosn based on your requirement
    var myImagetag = '<img src="http://wwwimages.adobe.com/include/style/default/SiteHeader/logo-2x.png">'
    sym.$("Rectangle").append(myImagetag);

  • Load external jpeg into flash movie

    Hi, how do i load external jpeg into flash movie?
    Can someone show me the actionscript? Thanks

    hi, i pasted the code on a mc but it didn't work.
    However, when i put in on frame action, it works.
    However, i realised the image flickered (more like refreshed)
    after afew sec...
    Is this normal? Is it the loop problem? how do i get rid of
    that?

  • Loading an image into an Applet from a JAR file

    Hello everyone, hopefully a simple question for someone to help me with!
    Im trying to load some images into an applet, currently it uses the JApplet.getImage(url) method just before registering with a media tracker, which works but for the sake of efficiency I would prefer the images all to be contained in the jar file as oppossed to being loaded individually from the server.
    Say I have a class in a package eg, 'com.mydomain.myapplet.class.bin' and an images contained in the file structure 'com.mydomain.myapplet.images.img.gif' how do I load it (and waiting for it to be loaded before preceeding?
    I've seen lots of info of the web for this but much of it is very old (pre 2000) and im sure things have changed a little since then.
    Thanks for any help!

    I don't touch applets, so I can't help you there, but here's some Friday Fun: tracking image loading.
    import java.awt.*;
    import java.awt.image.*;
    import java.beans.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.imageio.event.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class ImageLoader extends SwingWorker<BufferedImage, Void> {
        private URL url;
        private JLabel target;
        private IIOReadProgressAdapter listener = new IIOReadProgressAdapter() {
            @Override public void imageProgress(ImageReader source, float percentageDone) {
                setProgress((int)percentageDone);
            @Override public void imageComplete(ImageReader source) {
                setProgress(100);
        public ImageLoader(URL url, JLabel target) {
            this.url = url;
            this.target = target;
        @Override protected BufferedImage doInBackground() throws IOException {
            ImageInputStream input = ImageIO.createImageInputStream(url.openStream());
            try {
                ImageReader reader = ImageIO.getImageReaders(input).next();
                reader.addIIOReadProgressListener(listener);
                reader.setInput(input);
                return reader.read(0);
            } finally {
                input.close();
        @Override protected void done() {
            try {
                target.setIcon(new ImageIcon(get()));
            } catch(Exception e) {
                JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
        //demo
        public static void main(String[] args) throws IOException {
            final URL url = new URL("http://blogs.sun.com/jag/resource/JagHeadshot.jpg");
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch(url);
        static void launch(URL url) {
            JLabel imageLabel = new JLabel();
            final JProgressBar progress = new JProgressBar();
            progress.setBorderPainted(true);
            progress.setStringPainted(true);
            JScrollPane scroller = new JScrollPane(imageLabel);
            scroller.setPreferredSize(new Dimension(800,600));
            JPanel content = new JPanel(new BorderLayout());
            content.add(scroller, BorderLayout.CENTER);
            content.add(progress, BorderLayout.SOUTH);
            JFrame f = new JFrame("ImageLoader");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(content);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            ImageLoader loader = new ImageLoader(url, imageLabel);
            loader.addPropertyChangeListener( new PropertyChangeListener() {
                 public  void propertyChange(PropertyChangeEvent evt) {
                     if ("progress".equals(evt.getPropertyName())) {
                         progress.setValue((Integer)evt.getNewValue());
                         System.out.println(evt.getNewValue());
                     } else if ("state".equals(evt.getPropertyName())) {
                         if (SwingWorker.StateValue.DONE == evt.getNewValue()) {
                             progress.setIndeterminate(true);
            loader.execute();
    abstract class IIOReadProgressAdapter implements IIOReadProgressListener {
        @Override public void imageComplete(ImageReader source) {}
        @Override public void imageProgress(ImageReader source, float percentageDone) {}
        @Override public void imageStarted(ImageReader source, int imageIndex) {}
        @Override public void readAborted(ImageReader source) {}
        @Override public void sequenceComplete(ImageReader source) {}
        @Override public void sequenceStarted(ImageReader source, int minIndex) {}
        @Override public void thumbnailComplete(ImageReader source) {}
        @Override public void thumbnailProgress(ImageReader source, float percentageDone) {}
        @Override public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {}
    }

  • Loading External Images Causes Memory Leak

    I have been working on an Actionscript 2.0 project that basically loads external images.
    Everytime i load and unload a new image, memory increases to 1 or 2 MBs
    If all the images are in cache, then it increased to 4 or 8 KBs
    In the unloading of images, I have removed loader and the container of the image.
    Any thoughts why it is behaving like that?
    Please find the sample code snippet below.
    btn_load.onRelease = function()
    loadImage();
    btn_unLoad.onRelease = function()
    unLoadImage();
    var mcListener:Object = new Object();
    var container1:MovieClip;
    var mcLoader:MovieClipLoader;
    var loader_reference = this;
    var n=0;
    function loadImage(){
    var image_arr = ["http://xyz.com/image1.png","http://xyz.com/image2.png","http://xyz.com/image3.png","http:/ /xyz.com/image4.png","http://xyz.com/image5.png"];
    var image_url = image_arr[n];
    if(n==image_arr.length-1) {
      n=0;
    }else{ 
      n++;
    container1 = loader_reference.createEmptyMovieClip("container1", loader_reference.getNextHighestDepth());
    mcLoader = new MovieClipLoader();
    mcLoader.removeListener(mcListener);
    mcLoader.addListener(mcListener);
    mcListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
    mcListener.onLoadInit = function(target_mc:MovieClip):Void {
      target_mc._x = 300;
      target_mc._y = 200;
      target_mc._width = 300;
      target_mc._height = 250;
    mcLoader.loadClip(image_url, container1);
    function unLoadImage(){
      mcLoader.unloadClip(container1);
      mcLoader = null;
      container1 = null;
      removeMovieClip(loader_reference.container1);
    Thanks in advance.

    that code should only execute once.  fix that.

  • Error loading an image into an image icon

    Im having trouble with a gui that has to load external images, and ive isolated the loading to one spot. When I ask the Image icon for its status it always returns errored, but i dont know what error or how to fix it.
    Pulling My Hair Out
    JTuba
    import java.awt.*;
    import javax.swing.*;
    public class test
         public static void main(String[] args)
              JFrame.setDefaultLookAndFeelDecorated(true);
              JFrame frame = new JFrame("FrameDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container c = frame.getContentPane();
              JPanel panel = new JPanel()
                   public void paintComponent(Graphics g)     
                        ImageIcon img = new ImageIcon("CA.jpg");
         System.out.println(String.valueOf(img.getImage()==null));
                        ///These bouth output 4\\\\\
                   System.out.println(img.getImageLoadStatus());
                   System.out.println(MediaTracker.ERRORED);
                        ///The iomage is NEVER drawn\\\
                   g.drawImage(img.getImage(), 0, 0, null);
                        super.paintComponent(g);
              panel.setOpaque(true);
              c.add(panel);
              //panel.validate();
              //panel.repaint();
              //panel.pack();
              frame.setSize(750,450);
              frame.setVisible(true);
    }

    Hello,
    you should paint the background(super.paintComponent) before all other:JPanel panel = new JPanel()
    Image img Toolkit.getDefaultToolkit().getImage(yourCorrectPath);
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              g.drawImage(img, 0, 0, this);
    };regards,
    Tim

  • Converting an Image into a Button

    Hello all,
    I'm a very new user to Adobe Flash, and am trying to figure out some of the small things. I was wondering if anyone could help me out with how to convert an image into a button (with a URL).
    Thank you!
    Dave

    Let's say you created a button symbol. The first thing you need to do to make it useful code-wise is to assign it a unique instance name.  So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
    In AS3, to make a button work with code, you need to add an event listener and event hamdler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
    btn1.addEventListener(MouseEvent.CLICK, btn1Click);
    The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
    function btn1Click(evt:MouseEvent):void {
       var url:String = "http://www.awebsite.com/awebpage.html";
       var req:URLRequest = new URLRequest(url);
       navigateToURL(req);

  • How to load an image into blob in a custom form

    Hi all!
    is there some docs or how to, load am image into a database blob in a custom apps form.
    The general idea is that the user has to browse the local machine find the image, and load the image in a database blob and also in the custom form and then finally saving the image as blob.
    Thanks in advance
    Soni

    If this helps:
    Re: Custom form: Take a file name input from user.
    Thanks
    Nagamohan

  • Load external image & text into SWF

    Can someone point me to a tutorial on how to create a
    template that will load an external image file,.css styled text
    & a .css style sheet into a .swf by using .xml?
    Thank you for your time.
    CK

    You can use the MovieClipLoader class to load multiple images sequentially (one at a time), but you wouldn't use a 'for' type of loop...instead you would use a recursive loop, where a loading function is called after each load completion until all loading in done.  This is done by utilizing a load-complete listener to trigger loading of the next image.  So you start the loading process by loading one file, when that file is determined to be loaded, the listener proceses that file in whatever way you need to prepared (resizing, etc) and triggers the loading of the next file.
    If you look up the MovieClipLoader.addListener method in the Flash help documents there is an example there that uses the onLoadInit event.  You would be wanting to use the onLoadComplete event.

Maybe you are looking for

  • How long does it take for Verizon to activate a new device?

    I got an iPad 4 for Christmas. Today I screwed up my courage and decided to go online and add a tablet to my Share Everywhere service. Went thru all the screens giving them the EMEI #, the SIM card number and all the other requested info. I got a lin

  • In and EXISTS??which is better and why

    hi... Performance wise which is better IN or EXISTS and why..

  • RSS Viewer not working with the BBC Weather Service

    Hi all   I  am unable to display an anonymous RSS feed on my  publishing site. I have checked similar posts but mine seems subtly different  in ULS Cannot find site lookup info for request Uri http://open.live.bbc.co.uk/weather/feeds/en/??????/3dayfo

  • How to find User's LastLoggedonDate on SAP CE Portal 7.4

    Dear Experts, I just want to know how to find the User's LastLoggedonDate/Time in SAP CE Portal 7.4. As the two below standard methods has been deprecated. getPreviousSuccessfulLogonDate() getLastSuccessfulLogonDate() Is there any alternate standard

  • How to automate DDL statements in batch or stored procedure?

    I'd like to write a start file or stored procedure to create synonyms for all tables owned by the current user as well as any to which the user has been granted access. However, no DDL statement like create synonyms is allowed in stored procedures. H