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 7828921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:32:29+00:00 2026-06-02T10:32:29+00:00

I am from a php jquery background and i am currently getting to grips

  • 0

I am from a php jquery background and i am currently getting to grips with flash as3 just not sure how to pass values to eventlistner function say i have the following.

for (var i:uint = 0; i < asteroids.length; i++)
{                   
    asteroids[i].x = Math.random() * 450;
    asteroids[i].y = Math.random() * 450;
    asteroids[i].addEventListener(MouseEvent.MOUSE_UP, changeValue);            
}

public function changeValue(event:MouseEvent):void
{
    playSound(anote);
    trace(event.currentTarget);
}

each asteroid that i addeventlistner in the loop i need to pass a different value to the function the var anote?

jquery i would do.

$(".asteroids").click(function() {

     // or something similar 
     var anote = $(this).attr('href');
     playSound(anote);

     return false;

});

Can someone point me in the right direction.

  • 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-06-02T10:32:30+00:00Added an answer on June 2, 2026 at 10:32 am

    I suggest making a class for your Asteroid instances (assuming that’s what’s in the asteroids array). Each of those Asteroids could have an anote property with different values (this closely reflects your .asteroids elements href attribute.

    public class Asteroid extends Sprite
    {
        public var anote:String = "";
    }
    

    And then:

    for each(var i:Asteroid in asteroids)
    {                   
        i.x = Math.random() * 450;
        i.y = Math.random() * 450;
        i.addEventListener(MouseEvent.MOUSE_UP, changeValue);            
    }
    
    public function changeValue(event:MouseEvent):void
    {
        playSound((event.currentTarget as Asteroid).anote);
    }
    

    Ideally, your Asteroid class would also contain the code in your example and reference whichever class deals with the playSound() method.


    The other option is to create your own event class with the anote property that you can set at dispatch and work with. The process is quite lengthy, so here’s a link to one of my previous answers with an in-depth explanation of implementing that:

    • How to pass arguments into event listener function in flex/actionscript?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting a response from my php jquery / json / ajax.
I just get the parameters from PHP GET method and use them using jQuery.
From: Pro PHP and jQuery: ■ Tip The values returned are CSS shorthand properties.3
I try to send json array to ajax (from PHP to jQuery) in my
How can I do this in Javascript/jQuery from PHP? I am trying to populate
Am new to jquery. Have json response from php in this format. { div1:{data:minute=0,hour=27,day=649,month=19K,smallSize=0,
I am using a bespoke Jquery/PHP gallery script which pulls images from a Flickr
I am working on a jquery plugin which takes json data from the php
I have different php output in jQuery-based tabs. This output is formed from database
I am creating this url from jquery with an access token www.mysite.com/xyz.php?access_token=valid_access_token&id=1 and to

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.