Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3390672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:43:07+00:00 2026-05-18T03:43:07+00:00

I have these images that will load when I input a certain string of

  • 0

I have these images that will load when I input a certain string of text but I don’t know how to combine functions to make a generic one that will work for all of the images.
These are just two and they’re basically the same thing except I have to make each function (something)1 and then (something)2 for the next image.
I need some help on doing this.

function onInput(event:TextEvent):void {
if(ti.text.search('a')!=-1) addChild(ottefct);
else if(ti.text.search('b')!=-1) addChild(rnd);

var oeffect:Loader = new Loader();
oeffect.load(new URLRequest("http://i54.tinypic.com/anom5d.png"));
oeffect.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
var ottefct:Sprite = new Sprite();
 function onLoadingComplete(event:Event):void
 {
    ottefct.addChild( event.currentTarget.loader.content );
    ottefct.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    ottefct.addEventListener(MouseEvent.MOUSE_UP, drop);
    ottefct.doubleClickEnabled = true;
    ottefct.addEventListener(MouseEvent.MOUSE_WHEEL, rotate)
    ottefct.addEventListener(MouseEvent.DOUBLE_CLICK, unrotate)
    ottefct.height=180
    ottefct.width=124
 }
 function drag(event:MouseEvent):void{
     ottefct.startDrag()
  }
 function drop(event:MouseEvent):void{
     ottefct.stopDrag()
 }
 function rotate(event:MouseEvent):void{
     ottefct.rotation = 90
     }
 function unrotate(event:MouseEvent):void{
     ottefct.rotation = 0
     }
//---------------------------

var rednova:Loader = new Loader();
rednova.load(new URLRequest("http://i53.tinypic.com/2dv7dao.png"));
rednova.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete1);
var rnd:Sprite = new Sprite();
 function onLoadingComplete1(event:Event):void
 {
    rnd.addChild( event.currentTarget.loader.content );
    rnd.addEventListener(MouseEvent.MOUSE_DOWN, drag1);
    rnd.addEventListener(MouseEvent.MOUSE_UP, drop1);
    ottefct.addEventListener(MouseEvent.MOUSE_WHEEL, rotate1)
    ottefct.addEventListener(MouseEvent.DOUBLE_CLICK, unrotate1)
    rnd.height=180
    rnd.width=124
 }
 function drag1(event:MouseEvent):void{
     rnd.startDrag()
  }
 function drop1(event:MouseEvent):void{
     rnd.stopDrag()
 }
 function rotate1(event:MouseEvent):void{
     rnd.rotation = 90
     }
 function unrotate1(event:MouseEvent):void{
     rnd.rotation = 0
     }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:43:07+00:00Added an answer on May 18, 2026 at 3:43 am

    Got bored. Here ya go. However this should really be in a class….

    //Dictionary to store images (can use Array)
    var loaded_images:Dictionary = new Dictionary();
    
    function load_image(url:String, id_name:String)
    {
        var loader:Loader = new Loader();
        loader.name = id_name;
        var url_req:URLRequest = new URLRequest(url);
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
        loader.load(url_req);
    }
    
    function onLoadingComplete(evt:Event):void
    {
        var img_name:String = evt.currentTarget.loader.name
        var spr_box:Sprite = new Sprite();
        spr_box.addChild(evt.currentTarget.loader);
    
        spr_box.mouseChildren = false;
        spr_box.doubleClickEnabled = true;
    
        spr_box.addEventListener(MouseEvent.MOUSE_DOWN, drag);
        spr_box.addEventListener(MouseEvent.MOUSE_UP, drop);
        spr_box.addEventListener(MouseEvent.MOUSE_WHEEL, rotate);
        spr_box.addEventListener(MouseEvent.DOUBLE_CLICK , unrotate);
    
        //Shouldn't really hard code this here
        spr_box.width = 180;
        spr_box.height = 124;
    
        // - Since this isn't a class, I'd do this instead:
        //spr_box.addEventListener(Event.ADDED_TO_STAGE, resize_img);
    
        this.addChild(spr_box);
        loaded_images[img_name] = spr_box;
    }
    
    //Because this event function lets you control individual image dimensions
    /*
    function resize_img(evt:Event):void
    {
        switch (evt.currentTarget.name)
        {
            case "ImageOne":
                evt.currentTarget.width = 250;
                evt.currentTarget.height = 250;
                break;
            default:
                evt.currentTarget.width = 180;
                evt.currentTarget.height = 124;
                break;
        }
    }
    */
    
    function drag(evt:MouseEvent):void
    {
        evt.currentTarget.startDrag()
    }
    
    function drop(evt:MouseEvent):void
    {
        evt.currentTarget.stopDrag()
    }
    
    function rotate(evt:MouseEvent):void
    {
        evt.currentTarget.rotation = 90
    }
    
    function unrotate(evt:MouseEvent):void
    {
        evt.currentTarget.rotation = 0
    }
    
    //Few examples of use...
    load_image("http://www.google.co.nz/images/nav_logo26.png", "ImageOne");
    load_image("http://l.yimg.com/ao/i/nzunihead/logo-yahooxtra_1_4.png", "RandomName");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really cool website that allows people to upload images. Sometimes there
There is a data file and some image files that I have to download
Is there any simple way to programatically colorize images in .NET? Basically we have
I have these two pieces of code, wich one is more readable? foreach decimal
I have these 3 tables + data: items : itemId, itemName data: 1, my
I have these 2 vectors: alpha = 1 1 1 1 1 1 1
I have these container objects (let's call them Container) in a list. Each of
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key
Imagine I have these python lists: keys = ['name', 'age'] values = ['Monty', 42,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.