• 0

ActionScript 3 Help


Question

I really don't get something.

How come when I define a variable that's movie clip type but it's actually just an image of something, i.e.

var a:aMC;

a = new aMC();

addChild(a);

And when I initially set its value to its x, y, alpha position, i.e.

a.x = 1;

a.y = 1;

a.alpha = 0;

Alright, then I did an alpha tween from 0 to 1 to it (aTween is defined already),

aTween = new Tween(a, "alpha", Regular.easeOut, a.alpha, 1, 5, true);

Later on when I make a MouseEvent where if you click on this object, the function is called and inside the function, this alpha tween runs:

aTween = new Tween(a, "alpha", Regular.easeOut, a.alpha, 0, 5, true);

OK, so the tween works fine, but then it doesn't stay 0 after it's done. It's like the flash has restarted or something and the alpha goes back to 1.

What am I missing here? Hope this makes sense.

dL

Link to comment
https://www.neowin.net/forum/topic/732706-actionscript-3-help/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I think I know why, but don't know how to fix it.

Since the function inside changes to 0, but because once the function finishes the values go back to the stage value, which was changed to 1 from the first tween.

How do I go about and forcing that to 0 after the function is called?

dL

  • 0

If you guys are confused of what I just said, this is the file

http://www.sfu.ca/~dsl2/iat235/asn3/iat235_asn3_final.fla

Play the movie and click on the "What" cloud button and you'll get what I mean.

All the items should disappear after alpha tweening to 0, but then it appears again which it shouldn't. Why is that?

The function is called "what".

Your help is much appreciated!!

dL

  • 0
  dL said:
I think I know why, but don't know how to fix it.

Since the function inside changes to 0, but because once the function finishes the values go back to the stage value, which was changed to 1 from the first tween.

How do I go about and forcing that to 0 after the function is called?

dL

If that is indeed the problem, then all you should have to do is add a listener to listen for the end of the tween, and explicitly set the value of a to 0

aTween.onMotionFinished  = function()  {
a.alpha = 0;
}

But you shouldn't have to do it this way. The alpha should stay at 0 when the tween is done. Nevertheless, I'm sure there is a reasonable explanation. When the value goes back to 1, does it tween to 1 within your 5 seconds, or does it happen instantly?

Edited by Mr. Bean
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I am not seeing a huge difference there.
    • This is what I came here to say even if just for a dedicated Windows PC gaming box. Gaming is the only use case have to use Windows these days.
    • The Outer Worlds 2 gets an October release date, reveals companion details by Pulasthi Ariyasinghe After Avowed, Obsidian Entertainment's next grand RPG was already revealed to be releasing in 2025, but during the Xbox Games Showcase today, it finally received a firm release date: October 29. Check out the new story trailer above. While the original was set in Halcyon, this time, the story is set in Arcadia, a brand-new setting that's described as a lawless frontier. Also cut off from Earth, this land is pressured by human conflicts as well as mysterious space-time rifts. "You’ve been sent in as an Earth Directorate agent, but how you handle the mission – who you help, hinder, or exploit – is entirely your call," says Obsidian today. "Build your character with expanded traits, flaws, and backgrounds that shape every decision and unlock new ways to fight, sneak, talk, or blow things up." The RPG will let players get involved with three clashing factions this time: The Protectorate, Auntie’s Choice, and The Order of the Ascendant. Each of them is attempting to advance their own version of humanity's optimal future. Each of these factions has tout own hub areas, followers, audio design, and propaganda elements, with the war between the trio changing all of these as the story progresses depending on player choices. "RPG systems have been reimagined for this sequel to give players more freedom and more flavor," adds the company. "For example, traits and flaws dynamically evolve based on how you play. Steal enough and you’ll be offered Kleptomaniac, which boosts loot sales but risks auto-theft when you so much as glance at an item." Obsidian also detailed the companions players will be able to meet and ally with in their journeys: Niles: Another Earth Directorate recruit torn between duty and defection. Inez: A former experiment from Auntie’s Choice with a grafted combat edge and a moral core. Aza: A chaos-loving Rift worshipper with a taste for violence and room to grow – maybe. Marisol: A stoic killer from the Order of the Ascendant with calculations to settle. Tristen: A walking tank and judge from the Protectorate, looking to dispense justice – or redefine it. Valerie: A floating, chirping support unit with unexpected upgrades and untapped potential. The Outer Worlds 2 is releasing on October 29, 2025 across PC, Xbox Series X|S, and PlayStation 5. As usual for an Xbox game, it will be available to Game Pass subscribers on day one for no extra cost. Don't forget that Obsidian also has Grounded 2 releasing next month into early access too.
    • I love space RPGs, and this one will no doubt scratch that itch. Im still modding the crap out of Starfiled. Can't wait.
    • Nah, the problem is still Windows. If you install Linux on a gaming PC, you will get better performance in games.
  • Recent Achievements

    • Reacting Well
      BlakeBringer earned a badge
      Reacting Well
    • Reacting Well
      Lazy_Placeholder earned a badge
      Reacting Well
    • Dedicated
      Epaminombas earned a badge
      Dedicated
    • Veteran
      Yonah went up a rank
      Veteran
    • First Post
      viraltui earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      472
    2. 2
      +FloatingFatMan
      265
    3. 3
      ATLien_0
      234
    4. 4
      snowy owl
      224
    5. 5
      Edouard
      174
  • Tell a friend

    Love Neowin? Tell a friend!