how can i parse and foreach json tree on objective c - objective-c

2015-10-13 16:42:55.391 JsonProject[30384:1471391]
requestReply: (
{
DNumb = 512421421;
DTempData = "";
DUUID = 12;
Id = 1;
},
{
DTempData = "";
Id = 2;
},
{
DTempData = "";
Id = 3;
},
{
DTempData = "";
Id = 4;
},
{
DTempData = "";
Id = 5;
},
{
DTempData = "";
Id = 6;
},
{
DTempData = "";
Id = 7;
},
{
DNumb = String;
DTempData = "";
DUUID = String;
Id = 8;
},
{
DNumb = 1234;
DTempData = "";
DUUID = 4567;
Id = 9;
},
{
DTempData = "";
Id = 10;
},
{
DTempData = "";
Id = 11;
},
{
DTempData = "";
Id = 12;
},
{
DNumb = Message;
DTempData = "";
DUUID = isNotReal;
Id = 13;
} )
This is json data after post method,
NSDictionary* responseA = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
NSLog(#"requestReply: %#", responseA[#"GetVerifiedDevices"]);
how can i reach members? also check is available any number or character?
i was working on C# and i do use foreach, is there parse this data?
Thanks

Related

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]

My XML response:
{
"S:Envelope" = {
"S:Body" = {
"ns2:getMatchListResponse" = {
item = (
{
answerTime = {
text = 30;
};
challengerAppealsGranted = {
text = "0 of 16";
};
challengerHandle = {
text = manish;
};
challengerMatchesPlayed = {
text = 93;
};
challengerPic = {
text = "image.png";
};
challengerScore = {
text = 0;
};
challengerlosses = {
text = 0;
};
challengerwins = {
text = 4;
};
handle1 = {
text = sahni;
};
handle1AppealsGranted = {
text = 5;
};
handle1MatchesPlayed = {
text = 84;
};
handle1Response = {
text = Pending;
};
handle1Score = {
text = 0;
};
handle1losses = {
text = 0;
};
handle1wins = {
text = 1;
};
handle2MatchesPlayed = {
text = 0;
};
handle2Score = {
text = 0;
};
handle2losses = {
text = 0;
};
handle2wins = {
text = 0;
};
handle3MatchesPlayed = {
text = 0;
};
handle3Score = {
text = 0;
};
handle3losses = {
text = 0;
};
handle3wins = {
text = 0;
};
idMatch = {
text = 750;
};
isAppeal = {
text = false;
};
isFreeForm = {
text = false;
};
isMultichoiceQuestion = {
text = false;
};
isPublic = {
text = false;
};
matchName = {
text = ewtwert;
};
matchStartThresholdTime = {
text = "4 days 7 hrs";
};
matchStatus = {
text = wait;
};
matchType = {
text = Private;
};
noOfPlayers = {
text = 2;
};
priorityInList = {
text = 0;
};
scoreToWin = {
text = 5;
};
timeDuration = {
text = "5 days";
};
turnChangesIn = {
text = 0;
};
},
{
answerTime = {
text = 30;
};
challengerAppealsGranted = {
text = "0 of 16";
};
challengerHandle = {
text = manish;
};
challengerMatchesPlayed = {
text = 93;
};
challengerPic = {
text = "image.png";
};
challengerScore = {
text = 0;
};
challengerlosses = {
text = 0;
};
challengerwins = {
text = 4;
};
handle1MatchesPlayed = {
text = 0;
};
handle1Score = {
text = 0;
};
handle1losses = {
text = 0;
};
handle1wins = {
text = 0;
};
handle2MatchesPlayed = {
text = 0;
};
handle2Score = {
text = 0;
};
handle2losses = {
text = 0;
};
handle2wins = {
text = 0;
};
handle3MatchesPlayed = {
text = 0;
};
handle3Score = {
text = 0;
};
handle3losses = {
text = 0;
};
handle3wins = {
text = 0;
};
idMatch = {
text = 749;
};
isAppeal = {
text = false;
};
isFreeForm = {
text = false;
};
isMultichoiceQuestion = {
text = false;
};
isPublic = {
text = false;
};
matchName = {
text = gfhf;
};
matchStartThresholdTime = {
text = "4 days 6 hrs";
};
matchStatus = {
text = wait;
};
matchType = {
text = Public;
};
noOfPlayers = {
text = 2;
};
priorityInList = {
text = 0;
};
scoreToWin = {
text = 5;
};
timeDuration = {
text = "5 days";
};
turnChangesIn = {
text = 0;
};
}
);
"xmlns:ns2" = "http://services.tgs.com/";
};
};
"xmlns:S" = "http://schemas.xmlsoap.org/soap/envelope/";
};
}
I need value of key "matchStartThresholdTime".
I do:
NSDictionary *dictResult = [XMLReader dictionaryForXMLString:responseString error:nil];
NSDictionary *Enveloper = [dictResult objectForKey:#"S:Envelope"];
NSDictionary *Body = [Enveloper objectForKey:#"S:Body"];
NSDictionary *profileDetails = [Body objectForKey:#"ns2:getMatchListResponse"];
NSMutableArray *items = [profileDetails objectForKey:#"item"];
// NSLog(#"items===>%#",items);
NSDictionary *temp1;
for(temp1 in items)
{
thresholdTime = [NSString stringWithFormat:#"%#",[[temp1 objectForKey:#"matchStartThresholdTime"]objectForKey:#"text"]];...thresholdTime is NSString object.......and this line causes exception
//NSLog(#"time is===>%#",[[temp1 objectForKey:#"matchStartThresholdTime"]objectForKey:#"text"]);
}
What is the problem here?
Temp1 contains an NSString Object and not the NSDictionary, that you expect.
When dealing with JSON it is wise always to (double) check if a received object is really of the type that you expect. Always use
if ([temp1 isKindOfClass:[NSDictionary class]]) ...
or so.

how to get pi_image from array in table view

(
{
property = {
"p_address" = sdfsdf;
"p_asking_price" = "50000.00";
"p_category_type" = 1;
"p_created" = "0000-00-00 00:00:00";
"p_description" = sdfsdf;
"p_id" = 2;
"p_is_new_property" = 1;
"p_modified" = "2013-04-08 15:40:25";
"p_no_of_bedroom" = 1;
"p_no_of_otherroom" = 1;
"p_no_of_wc" = 2;
"p_title" = sadf;
"p_type" = demo;
};
"property_images" = (
);
"property_local_information" = (
{
"li_label" = "Nearby Transport";
"li_order" = 1;
"pli_distance" = "";
"pli_logo" = "";
"pli_title" = "";
}
);
"property_sale_history" = (
{
"psh_history" = sdsdfsd;
},
{
"psh_history" = sdfdfds;
}
);
"property_videos" = (
);
},
{
property = {
"p_address" = dfgsdfg;
"p_asking_price" = "44222.00";
"p_category_type" = "";
"p_created" = "0000-00-00 00:00:00";
"p_description" = "Updated by a staff meber (demo2#gmail.com)";
"p_id" = 3;
"p_is_new_property" = 1;
"p_modified" = "2013-04-09 03:05:09";
"p_no_of_bedroom" = 0;
"p_no_of_otherroom" = 0;
"p_no_of_wc" = 0;
"p_title" = "Test Update";
"p_type" = sdfgsdfgsdg;
};
"property_images" = (
{
"pi_image" = "prop_img_1594785781_3.png";
}
);
"property_local_information" = (
{
"li_label" = "Nearby College";
"li_order" = 4;
"pli_distance" = utyutyu;
"pli_logo" = "";
"pli_title" = tyutyu;
}
);
"property_sale_history" = (
{
"psh_history" = testing;
},
{
"psh_history" = tyutyutut;
}
);
"property_videos" = (
{
"pv_video" = "prop_vid_730342365_3.flv";
}
);
},
Try this if your using json concept
NSString *urlString = [NSString stringWithFormat:"your url link"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSMutableArray *json = (NSMutableArray*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSMutableArray *piimage=[json valueForKey:#"pi_image"];
NSLog(#"%#",piimage);

extracting information from NSDictionary

I have a NSDictionary response from a Flickr api request and it's description looks like this:
self.userInfo: {
"_text" = "\n\n";
person = {
"_text" = "\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n";
description = {
};
iconfarm = 0;
iconserver = 0;
id = "83943196#N02";
ispro = 0;
location = {
};
"mbox_sha1sum" = {
"_text" = 7b61c5d24f12345678be82c31234567830540;
};
mobileurl = {
"_text" = "http://m.flickr.com/photostream.gne?id=12345678";
};
nsid = "12345678#N02";
"path_alias" = "";
photos = {
"_text" = "\n\t\t\n\t\t\n\t\t\n\t\t\n\t";
count = {
"_text" = 2;
};
firstdate = {
"_text" = 12345678;
};
firstdatetaken = {
"_text" = "2012-08-01 12:46:38";
};
views = {
"_text" = 0;
};
};
photosurl = {
"_text" = "http://www.flickr.com/photos/12345678#N02/";
};
profileurl = {
"_text" = "http://www.flickr.com/people/12345678#N02/";
};
realname = {
"_text" = "Me TheUser";
};
timezone = {
label = "Pacific Time (US & Canada); Tijuana";
offset = "-08:00";
};
username = {
"_text" = metheuser;
};
};
stat = ok;
}
I'm having truoble figuring out how to extract the realname value into a NSString.
I've tried:
NSString * temp = [self.userInfo valueForKey:#"realname"];
NSLog (#"FL: nameOfSignedInUser. nameself.userInfo: %#", temp.debugDescription);
but that comes back as nil.
thank you!
NSString *name = [self.userInfo valueForKeyPath:#"person.realname._text"];
NSString *realName = [[[self.userInfo objectForKey:#"person"] objectForKey:#"realname"] objectForKey:#"_text"];

How best to traverse API information with iOS

Is there any easier way of traversing array/dictionaries without creating a lot of separate NSArrays/NSDictionaries? I know you can traverse nested dictionaries with dot notation and value at keypath, but what about when arrays are involved?
For example:
At the moment if I want to get at the object at feed.entry.link[4].href in the API result below, I have to define an array at keypath "feed.entry", then assign its first entry as a dictionary, then define an array at keypath "link" and access its fourth entry as a dictionary, and then access its value at "href".
Is this normal?
received {
encoding = "UTF-8";
feed = {
entry = (
{
author = (
{
name = {
"$t" = swdestiny;
};
uri = {
"$t" = "https://gdata.youtube.com/feeds/api/users/swdestiny";
};
}
);
category = (
{
scheme = "http://schemas.google.com/g/2005#kind";
term = "http://gdata.youtube.com/schemas/2007#video";
},
{
label = Entertainment;
scheme = "http://gdata.youtube.com/schemas/2007/categories.cat";
term = Entertainment;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = Star;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = Wars;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = Episode;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = 3;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = Revenge;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = of;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = the;
},
{
scheme = "http://gdata.youtube.com/schemas/2007/keywords.cat";
term = Sith;
}
);
content = {
"$t" = "sw-destiny.net Trailer for Revenge of the Sith";
type = text;
};
"gd$comments" = {
"gd$feedLink" = {
countHint = 1567;
href = "https://gdata.youtube.com/feeds/api/videos/9kdEsZH5ohc/comments";
rel = "http://gdata.youtube.com/schemas/2007#comments";
};
};
"gd$rating" = {
average = "4.7729683";
max = 5;
min = 1;
numRaters = 1132;
rel = "http://schemas.google.com/g/2005#overall";
};
id = {
"$t" = "http://gdata.youtube.com/feeds/api/videos/9kdEsZH5ohc";
};
link = (
{
href = "https://www.youtube.com/watch?v=9kdEsZH5ohc&feature=youtube_gdata";
rel = alternate;
type = "text/html";
},
{
href = "https://gdata.youtube.com/feeds/api/videos/9kdEsZH5ohc/responses";
rel = "http://gdata.youtube.com/schemas/2007#video.responses";
type = "application/atom+xml";
},
{
href = "https://gdata.youtube.com/feeds/api/videos/9kdEsZH5ohc/related";
rel = "http://gdata.youtube.com/schemas/2007#video.related";
type = "application/atom+xml";
},
{
href = "https://m.youtube.com/details?v=9kdEsZH5ohc";
rel = "http://gdata.youtube.com/schemas/2007#mobile";
type = "text/html";
},
{
href = "https://gdata.youtube.com/feeds/api/videos/9kdEsZH5ohc";
rel = self;
type = "application/atom+xml";
}
);
"media$group" = {
"media$category" = (
{
"$t" = Entertainment;
label = Entertainment;
scheme = "http://gdata.youtube.com/schemas/2007/categories.cat";
}
);
"media$content" = (
{
duration = 151;
expression = full;
isDefault = true;
medium = video;
type = "application/x-shockwave-flash";
url = "https://www.youtube.com/v/9kdEsZH5ohc?version=3&f=videos&app=youtube_gdata";
"yt$format" = 5;
},
{
duration = 151;
expression = full;
medium = video;
type = "video/3gpp";
url = "rtsp://v2.cache4.c.youtube.com/CiILENy73wIaGQkXovmRsURH9hMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";
"yt$format" = 1;
},
{
duration = 151;
expression = full;
medium = video;
type = "video/3gpp";
url = "rtsp://v2.cache5.c.youtube.com/CiILENy73wIaGQkXovmRsURH9hMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";
"yt$format" = 6;
}
);
"media$description" = {
"$t" = "sw-destiny.net Trailer for Revenge of the Sith";
type = plain;
};
"media$keywords" = {
"$t" = "Star, Wars, Episode, 3, Revenge, of, the, Sith";
};
"media$player" = (
{
url = "https://www.youtube.com/watch?v=9kdEsZH5ohc&feature=youtube_gdata_player";
}
);
"media$thumbnail" = (
{
height = 360;
time = "00:01:15.500";
url = "http://i.ytimg.com/vi/9kdEsZH5ohc/0.jpg";
width = 480;
},
{
height = 90;
time = "00:00:37.750";
url = "http://i.ytimg.com/vi/9kdEsZH5ohc/1.jpg";
width = 120;
},
{
height = 90;
time = "00:01:15.500";
url = "http://i.ytimg.com/vi/9kdEsZH5ohc/2.jpg";
width = 120;
},
{
height = 90;
time = "00:01:53.250";
url = "http://i.ytimg.com/vi/9kdEsZH5ohc/3.jpg";
width = 120;
}
);
"media$title" = {
"$t" = "Star Wars Episode 3 Revenge of the Sith Trailer";
type = plain;
};
"yt$duration" = {
seconds = 151;
};
};
published = {
"$t" = "2007-05-23T03:31:54.000Z";
};
title = {
"$t" = "Star Wars Episode 3 Revenge of the Sith Trailer";
type = text;
};
updated = {
"$t" = "2012-02-20T17:14:37.000Z";
};
"yt$statistics" = {
favoriteCount = 763;
viewCount = 796719;
};
}
);
xmlns = "http://www.w3.org/2005/Atom";
"xmlns$gd" = "http://schemas.google.com/g/2005";
"xmlns$media" = "http://search.yahoo.com/mrss/";
"xmlns$yt" = "http://gdata.youtube.com/schemas/2007";
};
version = "1.0";
}

How to manage depth in AS2

How do I change the movie clip (mainClip) in AS2 code below so that is behind all graphics in the flash file?
Code is below:
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.geom.Point;
var imageBmp:BitmapData;
//setting the width of blind parts.
var widthB:Number = 40;
//setting the speed of blind parts movement;
var speedChart = 5;
//time to wait lo load another image
var nbSpeedPhoto:Number = 3000;
//Setting the minimum and maximum alpha for controls container and updating timer
var nbACMin:Number = 10;
var nbACMax:Number = 65;
var nbACUpd:Number = 40;
//Setting the minimum and maximum alpha for textField Container
var nbATMin:Number = 0;
var nbATMax:Number = 100;
var nbABMin:Number = 0;
var nbABMax:Number = 65;
//Setting the color for textField Container and font title
var nbATBackColor:Number = 0xD0C8CD;
var nbATFontColor:Number = 0x1F0010;
//Setting the right margin and top margin for controls
var nbRightMC:Number = 2;
var nbTopMC:Number = 2;
//Setting the bottom margin for title and its height
var nbBottomMT:Number = 5;
var nbHeightMT:Number = 50;
//Init Slider viewer
var bbPlay:Boolean = true;
//Setting left to right (1), right to left (2), paralell(3), or random(4) transition
var nbForm:Number = 4;
//if you don't choose parallel, setting the time lag.
var nbLag:Number = 1;
//initial state of FullScreen and AutoPlaying buttons
var bbFull:Boolean = false;
var bbAnimating:Boolean = false;
var bbEnableTitle:Boolean = false;
var bbActiveTitle:Boolean = false;
//setting the first image number to load
var imageNum:Number = 0;
var imageLast:Number;
//initial Photo
var nbPhoto:Number = 0;
//timer variables
var nbTimerNow:Number = 0;
var nbTimerNext:Number = nbSpeedPhoto;
/*********Arrays*******************/
//used for load XML values
var arPhotoPath:Array = new Array();
var arPhotoTitle:Array = new Array();
/**Setting listener to load images**********/
var listener:Object = new Object();
listener.onLoadComplete = function(imageClip:MovieClip):Void {
if (imageNum>0) {
imageBmp = new BitmapData(mainClip["image"+imageLast]._width, mainClip["image"+imageLast]._height);
imageBmp.draw(mainClip["image"+imageLast],new Matrix());
var sqBmp:BitmapData;
var x:Number = 0;
var y:Number = 0;
if (nbForm == 1 || nbForm == 2 || nbForm == 3) {
form = nbForm;
} else {
rnd=Math.random()
if (rnd>0.66) {
form = 1;
} else if (rnd>0.33){
form = 2;
}else{
form = 3;
}
}
for (var j:Number = 0; j<cols; j++) {
x = j*widthB;
if (j>=cols-1) {
var ww = Stage.width-j*widthB;
} else {
var ww = widthB;
}
sqBmp = new BitmapData(ww, mcMask._height);
sqBmp.copyPixels(imageBmp,new Rectangle(x, y, ww, mcMask._height),new Point(0, 0));
cloneClip.createEmptyMovieClip("clone"+imageLast,cloneClip.getNextHighestDepth());
makeSq(sqBmp,j,form);
}
}
unloadMovie(mainClip["image"+imageLast]);
bbAnimating = false;
bbEnableTitle = true;
nbTimerNext = getTimer()+nbSpeedPhoto;
nbOK = 0;
mcText.tfToolTip.text = "Photo "+String(nbPhoto+1)+" of "+String(xmlLength)+": "+arPhotoTitle[nbPhoto];
mcText.tfToolTip.setTextFormat(myformat);
imageNum++;
};
var imageLoader:MovieClipLoader = new MovieClipLoader();
imageLoader.addListener(listener);
/***Creating Squares*******/
function makeSq(sqBmp:BitmapData, jValue:Number, fvalue:Number):Void {
var sqClip:MovieClip = cloneClip["clone"+imageLast].createEmptyMovieClip("sq"+jValue, cloneClip["clone"+imageLast].getNextHighestDepth());
sqClip.attachBitmap(sqBmp,1);
sqClip._x = jValue*widthB;
if (fvalue == 1) {
sqClip.lag = jValue;
} else if(fvalue == 2) {
sqClip.lag = cols-jValue;
}else{
sqClip.lag = 0;
}
sqClip.init = 0;
sqClip.onEnterFrame = function() {
if (this.init>this.lag) {
this._xscale = this._xscale-speedChart;
}
this.init += nbLag;
if (this._yscale<0 || this._xscale<0) {
unloadMovie(this);
}
};
}
//setting the main movieclip and its clone.
//the clone will store the parts of the main image.
this.createEmptyMovieClip("mainClip",this.getNextHighestDepth());
this.createEmptyMovieClip("cloneClip",this.getNextHighestDepth());
this.createEmptyMovieClip("mcMask",this.getNextHighestDepth());
this.createEmptyMovieClip("mcMask2",this.getNextHighestDepth());
//Creating the text container and setting its properties
this.createEmptyMovieClip("mcText",this.getNextHighestDepth());
mcText.createEmptyMovieClip("mcBackText",this.getNextHighestDepth());
makeARectangle(mcText.mcBackText,0,Stage.height-nbBottomMT-nbHeightMT,Stage.width,nbHeightMT,nbATBackColor,100);
mcText.mcBackText._alpha = 0;
//Creating the mc text container
mcText.createTextField("tfToolTip",mcText.getNextHighestDepth(),0,Stage.height-nbBottomMT-nbHeightMT,Stage.width,nbHeightMT);
mcText.tfToolTip._alpha = 0;
//Creating the masks
var bmpMask:BitmapData = new BitmapData(Stage.width, Stage.height, false, 0xCCCCCC);
mcMask.attachBitmap(bmpMask,this.getNextHighestDepth());
mcMask2.attachBitmap(bmpMask,this.getNextHighestDepth());
mainClip.createEmptyMovieClip("image"+imageNum,this.getNextHighestDepth());
//setting the number of columns and files
var cols = Math.ceil(mcMask._width/widthB);
//setting the main and clone masks
mainClip.setMask(mcMask2);
cloneClip.setMask(mcMask);
//setting buttons behaviors
if (bbPlay) {
mcControl.mcPausePlay.gotoAndStop("onPlay");
} else {
mcControl.mcPausePlay.gotoAndStop("onPause");
}
mcControl.mcBackControls.onRollOver = mcControl.mcFull.onRollOver=mcControl.mcLast.onRollOver=mcControl.mcFirst.onRollOver=mcControl.mcPrevious.onRollOver=mcControl.mcPausePlay.onRollOver=mcControl.mcNext.onRollOver=function () {
clearInterval(activeID);
activeID = setInterval(activeControl, nbACUpd, true);
};
mcControl.mcBackControls.onRollOut = mcControl.mcFull.onRollOut=mcControl.mcLast.onRollOut=mcControl.mcFirst.onRollOut=mcControl.mcPrevious.onRollOut=mcControl.mcPausePlay.onRollOut=mcControl.mcNext.onRollOut=function () {
clearInterval(activeID);
activeID = setInterval(activeControl, nbACUpd, false);
};
function activeControl(bb:Boolean) {
if (bb) {
if (mcControl._alpha>=nbACMax) {
clearInterval(activeID);
} else {
mcControl._alpha += 4;
}
} else {
if (mcControl._alpha<nbACMin) {
clearInterval(activeID);
} else {
mcControl._alpha -= 4;
}
}
}
mcControl.mcFull.onRelease = function() {
if (bbFull) {
Stage.displayState = "normal";
this.gotoAndStop("onNormal");
bbFull = false;
} else {
Stage.displayState = "fullScreen";
this.gotoAndStop("onFull");
bbFull = true;
}
};
mcControl.mcPausePlay.onRelease = function() {
if (bbPlay) {
this.gotoAndStop("onPause");
bbPlay = false;
clearInterval(initPhoto);
} else {
if (!bbAnimating) {
this.gotoAndStop("onPlay");
bbPlay = true;
clearInterval(initPhoto);
initPhoto = setInterval(initPlay, 200);
}
}
};
mcControl.mcLast.onRelease = mcControl.mcFirst.onRelease=mcControl.mcPrevious.onRelease=mcControl.mcNext.onRelease=function () {
if (bbAnimating == false) {
clearInterval(initPhoto);
mcControl.mcPausePlay.gotoAndStop("onPause");
bbPlay = false;
mcControl.mcPausePlay.onRelease;
switch (this._name) {
case "mcFirst" :
nbPhoto = 0;
break;
case "mcPrevious" :
nbPhoto = (xmlLength+nbPhoto-1)%xmlLength;
break;
case "mcNext" :
nbPhoto = (nbPhoto+1)%xmlLength;
break;
case "mcLast" :
nbPhoto = xmlLength-1;
break;
default :
break;
}
imageLast = imageNum-1;
mainClip.createEmptyMovieClip("image"+imageNum,mainClip.getNextHighestDepth());
imageLoader.loadClip(arPhotoPath[nbPhoto],mainClip["image"+imageNum]);
bbAnimating == true;
}
};
/********************************/
function makeEnabled(bbEnable:Boolean) {
with (mcControl) {
mcPausePlay.enabled = bbEnable;
mcLast.enabled = bbEnable;
mcFirst.enabled = bbEnable;
mcPrevious.enabled = bbEnable;
mcNext.enabled = bbEnable;
}
}
function makeVisible(bbVisible:Boolean) {
with (mcControl) {
mcPausePlay.enabled = bbVisible;
mcLast.enabled = bbVisible;
mcFirst.enabled = bbVisible;
mcPrevious.enabled = bbVisible;
mcNext.enabled = bbVisible;
}
}
function initPlay() {
if (bbAnimating == false) {
if (bbPlay) {
if (getTimer()>=nbTimerNext) {
nbPhoto = (nbPhoto+1)%xmlLength;
imageLast = imageNum-1;
mainClip.createEmptyMovieClip("image"+imageNum,mainClip.getNextHighestDepth());
imageLoader.loadClip(arPhotoPath[nbPhoto],mainClip["image"+imageNum]);
bbAnimating = true;
nbTimerNext += nbSpeedPhoto;
}
}
}
}
var myformat:TextFormat = new TextFormat();
myformat.font = "myFont";
myformat.color = nbATFontColor;
myformat.size = 18;
mcText.tfToolTip.embedFonts = true;
mcText.tfToolTip.wordWrap = true;
mcText.onRollOver = function() {
if (bbEnableTitle && !bbAnimating) {
alphaTitle(nbATMax,nbABMax);
bbActiveTitle = true;
}
};
mcText.onRollOut = function() {
if (bbEnableTitle) {
alphaTitle(nbATMin,nbABMin);
bbActiveTitle = false;
}
};
function alphaTitle(nbTextAlpha:Number, nbBackAlpha) {
mcText.mcBackText._alpha = nbBackAlpha;
mcText.tfToolTip._alpha = nbTextAlpha;
mcText.tfToolTip.setTextFormat(myformat);
}
//drawing a square
function makeARectangle(mc:MovieClip, x:Number, y:Number, w:Number, h:Number, nbColor:Number, nbAlpha:Number) {
mc.lineStyle(1,nbColor,0);
mc.beginFill(nbColor,nbAlpha);
mc.moveTo(x,y);
mc.lineTo(x+w,y);
mc.lineTo(x+w,y+h);
mc.lineTo(x,y+h);
mc.lineTo(x,y);
mc.endFill();
}
//for loading external XML
var xmlPhotos:XML = new XML();
xmlPhotos.onLoad = function() {
xmlLength = this.firstChild.childNodes.length;
for (var i:Number = 0; i<xmlLength; i++) {
arPhotoPath[i] = (this.firstChild.childNodes[i].attributes.path);
arPhotoTitle[i] = (this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue);
}
imageLoader.loadClip(arPhotoPath[0],mainClip["image"+imageNum]);
bbAnimating = true;
initPhoto = setInterval(initPlay, 200);
};
/****Run XML*****************************************/
xmlPhotos.ignoreWhite = true;
xmlPhotos.load("photos.xml");
mainClip.swapDepths(1);
you need to make sure that all the movieclips are on the same layer on the timeline.