Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1405 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Flash and Actionscript :

Swapping Pictures

Thread title: Swapping Pictures
Closed Thread    
    Thread tools Search this thread Display Modes  
03-14-2008, 08:06 PM
#1
mason.sklut is offline mason.sklut
mason.sklut's Avatar
Status: Junior Member
Join date: Mar 2007
Location: North Carolina
Expertise: Photography
Software:
 
Posts: 73
iTrader: 0 / 0%
 

mason.sklut is on a distinguished road

  Old  Swapping Pictures

I have a word game that shows 4 pics per slide and the title changes each time. You must choose the corresponding picture. Instead of having the pics show up in the same arrangement each slide, how can I swap pictures in my Flash game?

Here's the ActionScript I've used for the game:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;

stop();

var questionNumber:Number = 1;
var level:Number = 0;
var self:MovieClip = this;

var checkAnswer:Function = function ( num:Number ) {
	var mc:MovieClip = self [ "check_" + num ];
	mc._visible = true;
	
	var isCorrect:Boolean = false;
	
	
	
	
	if ( num == answerList [ "level"+level ] [ questionNumber-1 ]  ) {
		for ( var i=1; i<=4; i++ ) { self [ "btn_" + i].enabled = false; }
		isCorrect = true;
		mc.gotoAndStop ( "correct" );
	} else {
		mc.gotoAndStop ( "wrong" );
	}
	
	var myTween:Tween = new Tween ( mc, "_alpha", Regular.easeOut, 100, 0, 1, true );
	if ( isCorrect && lastFrame) {
		myTween.onMotionFinished = function () { gotoAndStop(6); }
	}
	else if(isCorrect) {
		myTween.onMotionFinished = function () { nextQuestion(); }
	}
}

var nextQuestion:Function = function () {
	for ( var i=1; i<=4; i++ ) { self [ "btn_" + i].enabled = true; }
	gotoAndStop ( "level_" + level + "_q" + ++questionNumber );
}

var prevQuestion:Function = function () {
	for ( var i=1; i<=4; i++ ) { self [ "btn_" + i].enabled = true; }
	gotoAndStop ( "level_" + level + "_q" + --questionNumber );
}

var selectLevel:Function = function ( num:Number ) {
	level = num;
	var txt:String = "Level" + num + "Completed";
	
	gotoAndStop ( "level_" + num + "_q1" );
}

var answerList:Object = {};
answerList.level1 = [ 1, 3, 2, 4, 1, 2, 3, 4];
answerList.level2 = [];
answerList.level3 = [];
answerList.level4 =[];

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed