Skip to main content
Participant
December 3, 2009
Question

Scaling and Image using ActionScript 3.0

  • December 3, 2009
  • 1 reply
  • 392 views

Hello, I need some help from the experts out here. I have created a thumbnail gallery and am using an external ActionScript 3.0 document to try and scale each of the thumbnails as I rollover them. There are 23 thumbnails. Rather than define all the variables and functions for all 23, is there a way I can create some sort of array so that each thumbnail will be scaled by the instance name defined in the variable array and same for the functions. The code below works for one image I have created. As you can see the idea is to hover over the image, it scales up, then you click on it and are taken to some other content stored locally or externally on a web server. Thanks in advance.

package {

import flash.display.Sprite;

import flash.display.MovieClip;

import flash.display.StageScaleMode;

import flash.events.Event;

import flash.events.MouseEvent;

import com.greensock.*;

import com.greensock.easing.*;

import flash.net.URLRequest;

import flash.net.URLVariables;

import flash.net.navigateToURL;

public class imageContainer extends MovieClip {

private var tween1:TweenLite;

private var tween2:TweenLite;

private var aigContent:URLRequest = new URLRequest("http://robertreich.blogspot.com/2009/03/obamas-first-priority.html");

public function imageContainer() {

aig.addEventListener(MouseEvent.ROLL_OVER, scaleIt1);

aig.addEventListener(MouseEvent.ROLL_OUT, scaleIt2);

aig.addEventListener(MouseEvent.CLICK, clickIt);

}

private function scaleIt1(event:MouseEvent):void{

tween1 = new TweenLite(aig, 1, {scaleX:1.5, scaleY:1.5});

   }

 

private function scaleIt2(event:MouseEvent):void{

tween2 = new TweenLite(aig, 1, {scaleX:1, scaleY:1});

   }

private function clickIt(event:MouseEvent):void{

navigateToURL(aigContent);

}

}

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 3, 2009

danialj wrote:

Hello, I need some help from the experts out here. I have created a thumbnail gallery and am using an external ActionScript 3.0 document to try and scale each of the thumbnails as I rollover them. There are 23 thumbnails. Rather than define all the variables and functions for all 23, is there a way I can create some sort of array so that each thumbnail will be scaled by the instance name defined in the variable array and same for the functions. The code below works for one image I have created. As you can see the idea is to hover over the image, it scales up, then you click on it and are taken to some other content stored locally or externally on a web server. Thanks in advance.

package {

import flash.display.Sprite;

import flash.display.MovieClip;

import flash.display.StageScaleMode;

import flash.events.Event;

import flash.events.MouseEvent;

import com.greensock.*;

import com.greensock.easing.*;

import flash.net.URLRequest;

import flash.net.URLVariables;

import flash.net.navigateToURL;

public class imageContainer extends MovieClip {

private var tween1:TweenLite;

private var tween2:TweenLite;

private var aigContent:URLRequest = new URLRequest("http://robertreich.blogspot.com/2009/03/obamas-first-priority.html");

public function imageContainer() {

 

aig.contentVar = "aigurl"; // use the correct url

aig.addEventListener(MouseEvent.ROLL_OVER, scaleIt1);

aig.addEventListener(MouseEvent.ROLL_OUT, scaleIt2);

aig.addEventListener(MouseEvent.CLICK, clickIt);

}

private function scaleIt1(event:MouseEvent):void{

tween1 = new TweenLite(event.currentTarget, 1, {scaleX:1.5, scaleY:1.5});

   }

 

private function scaleIt2(event:MouseEvent):void{

tween2 = new TweenLite(event.currentTarget, 1, {scaleX:1, scaleY:1});

   }

private function clickIt(event:MouseEvent):void{

navigateToURL(event.currentTarget.contentVar);

}

}

}